Hi
I have this matrix, one column GO term, one column genes enriched for that term and fold gene of that gene
GO_term Gene_Name Log2FC
cell adhesion IGFBP7 1.38
cell adhesion PVRL4 -1.40
cell adhesion NCAM1 -1.35
cell-matrix adhesion ITGA7 -1.20
cell-matrix adhesion ITGA4 0.75
positive regulation of cell migration ITGA5 -1.36
positive regulation of cell migration RRAS2 -0.59
cellular oxidant detoxification FABP1 2.35
cellular oxidant detoxification LTC4S -0.59
muscle contraction ACTA2 -1.21
muscle contraction VCL -1.06
How I can convert my matrix to something like this
> head(chord)
heart development phosphorylation vasculature development
PTK2 0 1 1
GNA13 0 0 1
LEPR 0 0 1
APOE 0 0 1
CXCR4 0 0 1
RECK 0 0 1
blood vessel development tissue morphogenesis cell adhesion
PTK2 1 0 0
GNA13 1 0 0
LEPR 1 0 0
APOE 1 0 0
CXCR4 1 0 0
RECK 1 0 0
plasma membrane logFC
PTK2 1 -0.6527904
GNA13 1 0.3711599
LEPR 1 2.6539788
APOE 1 0.8698346
CXCR4 1 -2.5647537
RECK 1 3.6926860
>
A binary matrix for genes in each term with corresponding logfFC
Basically, it's a pivot table transformation. Remove 'logFC' column- pivot table- add 'logFC' column back.