Skip to content

Instantly share code, notes, and snippets.

@radaniba
Created November 29, 2012 17:13
Show Gist options
  • Select an option

  • Save radaniba/4170476 to your computer and use it in GitHub Desktop.

Select an option

Save radaniba/4170476 to your computer and use it in GitHub Desktop.
GO term enrichment analysis with the GeneAnswers package, use the bioconductor annotation packages for the ID mapping. The GeneAnswers documentation has improved since the package came out. And once you get the hang of the annotation packages, they seem f
library("GeneAnswers")
library("org.Dm.eg.db")
library("GO.db")
# get named vector of entrez ids
fb.entrez <- unlist(as.list(org.Dm.egFLYBASE2EG))
# for a data frame x with flybase ids (column 1) and data values (column 2)
# match the flybase names against the vector of entrez ids
iv <- match(x[,1], names(fb.entrez))
# add a column for entrez ids
x <- cbind(x,rep(NA, nrow(x)))
# fill it in by mapping the entez ids onto the matching flybase ids
x[,3] <- fb.entrez[iv]
# now you can do some GO analysis
# for an index vector "myTopHits" of your top data
topset <- x[myTopHits,3]
# remove entries that had no matching entrez id(NA)
topset <- topset[!is.na(topset)]
# Get BP enrichment
foo <- geneAnswersBuilder(topset, 'org.Dm.eg.db', categoryType='GO.BP', testType='hyperG')
go.bp <- foo@enrichmentInfo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment