How to download genes from MSigdb in R?
2
1
Entering edit mode
2.4 years ago
Amr ▴ 180

How to download all genes inside all gene sets in C6 (oncogenic signature gene sets, 189 gene sets) in Molecular signature database (Msigdb) I want to download the all genes inside 189 gene sets in R in a data frame?

Thanks in advance

MsigDB GSEA geneset • 2.1k views
ADD COMMENT
2
Entering edit mode
2.4 years ago

With the msigdbr R library

library("msigdbr")
library("tidyverse")

df <- bind_rows(msigdbr("Homo sapiens", "C6"))
ADD COMMENT
2
Entering edit mode
2.4 years ago
Amr ▴ 180
library(msigdbr)

genesets = msigdbr(species = "Homo sapiens", category = "C6",subcategory = NULL)
View(genesets)

unique_genes <- genesets%>% distinct(gene_symbol)
View(unique_genes)
ADD COMMENT
2
Entering edit mode

IMO View is not a good command as it is specific to GUI applications such as RStudio. Use head() or str() as appropriate instead.

ADD REPLY
0
Entering edit mode

Thanks a lot for your comment :)

ADD REPLY
1
Entering edit mode

Please accept all answers that work for you. Asking a question, then ignoring existing answers to accept your own answer is bad etiquette. rpolicastro's answer is more to the point than yours.

ADD REPLY
0
Entering edit mode

Actually I wanted my answer :) plus I tried his answer but did not work with me, Also, I am new here and don't know that I should accept all answers, but I also accepted his answer.

ADD REPLY
0
Entering edit mode

Actually I wanted my answer

What do you mean by that?

I tried his answer but did not work with me

Please give feedback to rpolicastro so he can improve his answer/debug your code. Comparing your answers, his answer should work. Did you want just the unique gene symbols (available as a column in the df data.frame in his answer?

I am new here and don't know that I should accept all answers

No problem, you're encouraged to accept all answers that are given to you in a timely fashion if they work for you. On the other hand, ignoring a timely answer (especially one that gets you > 80% of the way) and then adding your own is not good etiquette. Please don't think that you need to accept all answers - you should ideally give feedback to good responses and even feel free to ignore useless responses, but not engaging with someone that put effort into your problem is a little rude.

ADD REPLY
0
Entering edit mode

I mean that I wanted to extract the unique genes by firstly, putting all genes inside all genes sets same as I asked. I implemented this :

dfox <- msigdbr("Homo sapiens", "C6") |>
+   map(as_tibble_col, column_name="gene") |>
+   bind_rows(.id="geneset_name")
Error in map(msigdbr("Homo sapiens", "C6"), as_tibble_col, column_name = "gene") : 
  could not find function "map"

I don't know if got confused and saw it in another website or it's changed plus I also don't know what is the advantages that someone gets if I vote for his/her answer that's why I didn't voted for it, and when I clicked on right mark I did that because I thought that this means that this answer is what I wanted to know for my question.

In addition, as someone new, I don't have the intention to ignore someone or act rude or anything like that, simply I just didn't know what should be done and what are the rules. Please don't judge people so fast :)

ADD REPLY
0
Entering edit mode

I fixed the code shortly after posting, so you just had the bad luck of trying the code in that short timespan between edits.

ADD REPLY
0
Entering edit mode

I apologize for my rude comments - I've seen users ask a question, ignore answers by other people and add their own answer (often the exact same as the other person's answer) and accept their added answer.

The upvotes/points for accepted answers are minimal, that's not why you need to accept all answers that work for you; it's a matter of closure/record. You have a question that could have multiple answers. In the future, someone may have a similar question but the answer you accepted may not work for them. The approach in a different answer might. For this reason, accepting all answers that work + providing feedback to answers that don't results in a transparent log of things that work and don't work in your problem area. This benefits the community at large.

ADD REPLY
0
Entering edit mode

@Ram No problem :) Wish you a good day :)

ADD REPLY

Login before adding your answer.

Traffic: 2151 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6