I am trying to convert data from following Table into another summarized data.
Sample | Position | Reference | Alternate | No. of Reads |
---|---|---|---|---|
P6 | 10017884 | C | G | 2 |
P7 | 10017884 | C | G | 1 |
P8 | 10017884 | C | A | 7 |
P98 | 10017884 | C | T,A | 4 |
P114 | 10020433 | A | C | 1 |
P98 | 10020433 | A | C | 4 |
I am looking for output like following table. In some of the samples, there are data which are missing/empty, so it should be filled with 0 (zero). Any type of hint to solve this problem will be helpful in Linux/R or Python.
Position | Reference | Aletrnate | P1 | P2 | P3 | P4 | P5 | P6 | P7 | P8 | P98 | P114 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
10017884 | C | G | 0 | 0 | 0 | 0 | 0 | 2 | 1 | 0 | 0 | 0 |
A | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 7 | 0 | 0 | ||
T,A | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 0 | ||
10020433 | A | C | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 1 |