问题
I have trouble creating topGO object using my own data. Wondering if someone can help me with this!
I'm following a couple of tutorials and steps mentioned in the original ViSEAGO paper. Here are chunks from the tutorial and their links.
From the publication: ViSEAGO offers all statistical tests and algorithms developed in the Bioconductor topGO R package, taking into account the topology of GO graph by using ViSEAGO::create_topGO- data method followed by the topGO::runTestmethod.
Under 'Functional GO enrichment' in the tutorial, the following piece of code is used to generate the topGO object.
# create topGOdata for BP
BP<-ViSEAGO::create_topGOdata(
geneSel=selection,
allGenes=background,
gene2GO=myGENE2GO,
ont="BP",
nodeSize=5
)
I also referred to topGO's tutorial to make sure my data types are correct. Yet, there are some errors, that I have trouble dealing with.
For my data, I have the following code.
> ##################
> # create topGOdata for BP
> BP<-ViSEAGO::create_topGOdata(
+ geneSel=geneList_g1,
+ allGenes=topDiffGenes(geneList_g1),
+ gene2GO=myGENE2GO,
+ ont="BP",
+ nodeSize=5
+ )
#error message:
allGenes contain genes redondancy.
duplicate elements were removed.
Error in .local(.Object, ...) : allGenes must be a factor with 2 levels
In my case, geneList_g1 is a named num with gene symbols and p-values (length 23 differentially expressed genes as shown below). The organism being studies is Mus musculus.
> dput(geneList_g1)
c(Klf4 = 0.596, Pdk2 = 0.278, Pink1 = 0.192, Hsp90ab1 = 0.142,
Cdkn1a = 0.132, App = 0.0197, Lep = 0.0165, Igf1 = 0.00138, Bcl6 = 0.001,
Pfkm = 0.000264, Rbp4 = 0.000175, Pck1 = 0.000162, Adipoq = 9.13e-05,
B2m = 1.63e-05, Pde4d = 1.8e-06, Ppargc1a = 1.04e-07, Igfbp4 = 1.01e-07,
Apod = 5.52e-08, Foxo1 = 7.05e-12, Ide = 1.29e-12, Nr1d1 = 7.68e-17,
Apoe = 1.48e-25, Pdk4 = 4.5e-57)
Using another command to creat topGO object, I get the following error.
> mysampleGOdata <- new("topGOdata",
+ description = "my Simple session",
+ ontology = "BP",
+ allGenes = geneList_g1,
+ geneSel = topDiffGenes,
+ nodeSize = 1,
+ annot = annFUN.db,
+ affyLib = affyLib)
Building most specific GOs .....
( 0 GO terms found. )
Build GO DAG topology ..........
( 0 GO terms and 0 relations. )
Error in if (is.na(index) || index < 0 || index > length(nd)) stop("vertex is not in graph: ", :
missing value where TRUE/FALSE needed
Any help is much appreciated!! Thanks in advance! :)
回答1:
You need to provide the correction annotation and in your case, a vector of TRUE / FALSE. So to start:
geneList_g1 = c(Klf4 = 0.596, Pdk2 = 0.278, Pink1 = 0.192, Hsp90ab1 = 0.142,
Cdkn1a = 0.132, App = 0.0197, Lep = 0.0165, Igf1 = 0.00138, Bcl6 = 0.001,
Pfkm = 0.000264, Rbp4 = 0.000175, Pck1 = 0.000162, Adipoq = 9.13e-05,
B2m = 1.63e-05, Pde4d = 1.8e-06, Ppargc1a = 1.04e-07, Igfbp4 = 1.01e-07,
Apod = 5.52e-08, Foxo1 = 7.05e-12, Ide = 1.29e-12, Nr1d1 = 7.68e-17,
Apoe = 1.48e-25, Pdk4 = 4.5e-57)
Load libraries, org.Mm.eg.db is the mouse annotation:
library(org.Mm.eg.db)
library(topGO)
And we do:
UNI=keys(org.Mm.eg.db, keytype ='SYMBOL')
geneList <- factor(as.integer(UNI %in% names(geneList_g1)))
names(geneList) = UNI
If you have a background of other genes, you basically use UNI as your list of genes tested, and follow up with geneList:
mysampleGOdata <- new("topGOdata",
description = "my Simple session",
ontology = "BP",
allGenes = geneList,
nodeSize = 1,
annot = annFUN.org,
mapping="org.Mm.eg.db",
ID = "SYMBOL")
resultFisher <- runTest(mysampleGOdata, algorithm = "classic", statistic = "fisher")
head(GenTable(mysampleGOdata,fisher=resultFisher),1)
GO.ID Term Annotated Significant
1 GO:0006006 glucose metabolic process 194 12
Expected fisher
1 0.19 1.0e-19
来源:https://stackoverflow.com/questions/59639543/error-when-i-load-my-own-data-using-viseago-create-topgo