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?
Thanks in advance!
You should check out
rowSums()
instead ofrowsum()
. See: https://stackoverflow.com/questions/55171125/what-is-the-difference-between-rowsum-and-rowsums-in-rThanks for your response. I've checked the
rowSums()
function combined withdplyr
to solve my issue.Did that work?
I'm still working on it