Thank you so much, it worked.
• 0 views
•
link
Hi, I have a list differentially expressed genes and I wanted to do GO enrichment analysis using topGO. I am having trouble making a geneID2GO annotation file, I extracted GO terms corresponding to each gene ID using the following script. How to make the 'geneID2GO' object from the following script compatible with topGO? Thanks.
library("biomaRt")
#collect gene names from biomart
mart <- biomaRt::useMart(biomart = "plants_mart",
dataset = "athaliana_eg_gene",
host = 'plants.ensembl.org')
# Get ensembl gene ids and GO terms
GTOGO <- biomaRt::getBM(attributes = c( "ensembl_gene_id",
"go_id"), mart = mart)
#examine result
head (GTOGO)
#Remove blank entries
GTOGO <- GTOGO[GTOGO$go_id != '',]
# convert from table format to list format
geneID2GO <- by(GTOGO$go_id,
GTOGO$ensembl_gene_id,
function(x) as.character(x))
#examine result
head (geneID2GO)
Hi Sreeraj,
you can create 'topGOdata' object by calling
go.obj = new("topGOdata", ontology='BP'
, allGenes = int.genes
, annot = annFUN.gene2GO
, gene2GO = geneID2GO)
where int.genes is a factor containing the information which genes are interesting (in your case, differentially expressed).
Here a small working example (run after your lines):
all.genes <- sort(unique(as.character(GTOGO$ensembl_gene_id)))
int.genes <- sample(x = all.genes, size = 200) # some random genes
int.genes <- factor(as.integer(all.genes %in% int.genes))
names(int.genes) = all.genes
go.obj <- new("topGOdata", ontology='BP'
, allGenes = int.genes
, annot = annFUN.gene2GO
, gene2GO = geneID2GO
)
results <- runTest(go.obj, algorithm = "elim", statistic = "fisher")
results.tab <- GenTable(object = go.obj, elimFisher = results)
The results.tab contains the table of enriched GO terms.
HTH
Thank you so much, it worked.
Log in to answer this question.