Question: clusterprofiler: How to extract genes of a specific GO-term/pathway
gravatar for ccha97
7 weeks ago by
ccha9720 wrote:

I was wondering how to get the list of genes grouped in a particular GO-Term of Biological Pathway. I have an enrichGO output (using the clusterprofiler package). From this result, I've into a bar plot (see below). For example, my top enriched pathway is T cell activation, how do I obtain the genes which have been grouped into this pathway?

My code is taken from the clusterProfiler book:

ego2 <- enrichGO(gene         = gene.df$ENTREZID,
            OrgDb         =,
            keyType       = 'ENTREZID',
            ont           = "BP",
            pAdjustMethod = "BH",
            pvalueCutoff  = 0.01,
            qvalueCutoff  = 0.05)

barplot(ego2, showCategory=10)

Here are some screenshots of what my data looks like in R:

enter link description here enter image description here

ADD COMMENTlink modified 7 weeks ago by jared.andrews076.9k • written 7 weeks ago by ccha9720
gravatar for jared.andrews07
7 weeks ago by
Memphis, TN
jared.andrews076.9k wrote:

ego2@result$geneID should give you a vector of strings containing the Entrez IDs for each gene in each pathway, delimited by "/". You could then split that string into a list via strsplit.

ADD COMMENTlink written 7 weeks ago by jared.andrews076.9k

Thanks so much! This seemed to work, as I'm able to see the number of genes as well as their IDs. Is it possible to also have the name of the pathway they are involved in (right now they are numbered, where I assume pathway 1 = T cell activation) or do I just assume they are in the same order as my bar plot?

ADD REPLYlink modified 7 weeks ago • written 7 weeks ago by ccha9720

They will be ranked by p-value by default, so yes, they should match up correctly. Though you could create a named vector by assigning description as the names for your vector to make things a bit easier , i.e:

go_genes <- ego2@results$geneID
names(go_genes) <- ego2@results$description
ADD REPLYlink written 7 weeks ago by jared.andrews076.9k

Thank you very much!

ADD REPLYlink written 6 weeks ago by ccha9720
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 710 users visited in the last hour