Sum of rows for GSEA analysis
0
0
Entering edit mode
15 months ago

Hi,

I have an issue which looks like easy to solve, but I'm stuck. I have a dataframe composed of columns (significant pathways retrieved from GSEA) and rows (entrez gene ids). In this data frame there are 1 if a gene is present in a pathway or 0 when not. This is my data frame:

                      Path_A      Path_B       Path_C
Gene_1                   0           1            0
Gene_2                   1           1            0
Gene_3                   0           0            1
Gene_4                   1           1            1


I want to sum the rows (genes) to calculate how many times a gene is present in distinct pathways, and thus get something like this:

                      Path_A      Path_B       Path_C
Gene_1                   0           1            0
Gene_2                   2           2            0
Gene_3                   0           0            1
Gene_4                   3           3            3


I have figured out that uising rowsum() might solve my issue. However, when checking R documentation for the function I had some troubles and I couldn't retrieve my desired output.

Is there any way to perform this sum?

GSEA leading-edge R fGSEA • 659 views
1
Entering edit mode

You should check out rowSums() instead of rowsum(). See: https://stackoverflow.com/questions/55171125/what-is-the-difference-between-rowsum-and-rowsums-in-r

0
Entering edit mode

Thanks for your response. I've checked the rowSums() function combined with dplyr to solve my issue.

0
Entering edit mode

Did that work?

0
Entering edit mode

I'm still working on it