Use topGOdata in devtools package
1
0
Entering edit mode
@emisecherre-23089
Last seen 4.4 years ago

Hello ! I'm trying to build a R devtools package, with this code :

ensembl = biomaRt::useMart("ensembl",dataset="hsapiens_gene_ensembl")
  goterm=biomaRt::getBM(attributes=c("hgnc_symbol",'go_id'), mart = ensembl) #mapping genes-go termes
  goterm=subset(goterm, !(goterm$go_id==""))
  goterm=subset(goterm, !(goterm$hgnc_symbol==""))

  gc=biomaRt::getBM(attributes=c("hgnc_symbol","entrezgene_id"),mart=ensembl) #mapping genes symbol - entrez genes id
  ensfull=gc$entrezgene_id[!is.na(gc$entrezgene_id))] #entrez genes existant pour l'humain
  ens=gprofiler2::gconvert(genes, organism="hsapiens", target='ENTREZGENE_ACC')$target #entrez gene de nos genes

  ensint=factor(as.integer(ensfull %in% ens))#preparation des donnees pour l'analyse GO
  names(ensint)=ensfull
  ensint
  #go termes enrichis BP
  GOdataBP <- methods::new("topGOdata", ontology = "BP", allGenes = ensint, annot = topGO::annFUN.org, mapping="org.Hs.eg.db", ID="entrez")
  resultFisBP <- topGO::runTest(GOdataBP, algorithm = "classic", statistic = "fisher")
  allResBP <- topGO::GenTable(GOdataBP, classic = resultFisBP, orderBy = "classic", ranksOf = "classic",topNodes=20)

The thing is, methods::new doesn't recognize the topGOdata Class, and add topGO::topGOdata doesn't fix the issue. Anyone know how to fix it ?

topGO devtools R • 1.2k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 1 day ago
United States

You need to show the error you get. If it's something like this:

>  GOdata <- new("topGOdata",
                   ontology = "BP",
                   allGenes = geneList,
                   geneSel = topDiffGenes,
                   description = "GO analysis of ALL data: Differential Expression between B-cell and T-cell",
                   annot = annFUN.db,
                   affyLib = affyLib)
Error in getClass(Class, where = topenv(parent.frame())) : 
  "topGOdata" is not a defined class

That indicates that you haven't loaded the topGO package yet.

ADD COMMENT
0
Entering edit mode

It's exactly this error, the thing is that i can't use "library" to load topGO and i don't know an other way which works with devtools...

ADD REPLY
0
Entering edit mode

Are you using roxygen2 to describe the imports of your package? If so, add

#' import topGO

to one of your source files, and add

Imports: topGO

to your descriptino file. Be sure to run devtools::document() to update the NAMESPACE, which should automatically include a line import(topGO).

ADD REPLY

Login before adding your answer.

Traffic: 501 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