I have a dataframe named dflike this:
Genes ID Type
CFH MB-0002 Gain
CFHR3 MB-0002 Gain
DEFB131 MB-0003 Gain
UNC93B5 MB-0003 Loss
CCDC125 MB-0004 Loss
CCNB1 MB-0002 Gain
CFH MB-0004 Loss
CCNB1 MB-0003 Gain
I want to build a matrix, say Mat, and write it to a file csv, where I will have genes in the form of rows and columns IDs. I want to put:
1if appropriate type Gain-1if appropriate type Loss0 in all other places.
And an example of my matrix would be:
MB-0002 MB-0003 MB-0004
CFH 1 0 -1
CFHR3 1 0 0
DEFB131 0 1 0
UNC93B5 0 -1 0
CCDC125 0 0 -1
CCNB1 1 1 0
source
share