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)
Thank you so much, it worked.