Hey,
The error possibly relates to how you produced annFun.org
, even though no error was returned when you ran the annFUN.org()
command. Also, the mapping is usually specified, not in new()
, but, rather, in annFUN.org()
as mapping = 'org.Hs.eg.db'
.
In addition, just to be sure, geneList
should be a named numeric vector, usually of p-values, whose names relate to genes. In your case, they have to be gene symbols.
Finally, I think that ID
should be ID = 'symbol'
Here is an example:
head(genes)
ANXA2 DHCR24 GBE1 GLA PRDX1 PSMD14
0 0 0 0 0 0
tail(genes)
CTTNBP2NL METTL7B AKR1C3 SLC5A11 TIMP4 PPP2R2C
7.395843e-07 1.496372e-06 4.328879e-05 1.612348e-04 2.620590e-04 9.728924e-04
range(genes)
[1] 0.0000000000 0.0009728924
require(topGO)
require(org.Hs.eg.db)
# function that returns TRUE/FALSE for p-values<0.05
selection <- function(allScore) {
return(allScore < 0.05)
}
allGO2genes <- annFUN.org(
whichOnto = 'BP',
feasibleGenes = NULL,
mapping = 'org.Hs.eg.db',
ID = 'symbol')
GOdata <- new('topGOdata',
ontology = 'BP',
allGenes = genes,
annot = annFUN.GO2genes,
GO2genes = allGO2genes,
geneSel = selection,
nodeSize = 10)
I show this on Biostars: https://www.biostars.org/p/350710/#350712
Kevin
thanks a lot, Kevin.
I used your code but I still don't menage to run TopGO.
Here my script where the input files are the list of universe genes (with ENSEMBLE id) and the list of relevant genes. So, I don't have any pvalue, only gene names in my files
At the end I got this error:
Hey again, the problem is that the value passed to
geneSel
should be a function - you are passing to it another named vector of values.If you take a look at my code again, you'll see that I am passing the following function to
geneSel
:This function will be applied to, in your case, the
total.gene.names
variable. It is essentially used to filter your input gene list by, for example, p-value < 0.05 (my function). Here is an example:Thanks a lot for clarifying this.
I modified my code as:
I see - that may not function as expected because the
selection
function will only accept one parameter.Just to recap: the object passed to
allGenes
should be a named vector of p-values or other values, such as fold changes. In your case, therefore, yourtotal.gene.names
variable should look something like this:------
The function passed to
geneSel
will be applied tototal.gene.names
and should return a boolean vector of values.In your case, you may want to use:
Then test it to see what it produces:
What is the output? - it should return a vector of
TRUE
|FALSE
This assumes that both
total.gene.names
significant.genes
are named vectors of p-values or fold changes.If you still have problems, you could post the output of
total.gene.names
andsignificant.genes
Correct,
ENSG00000238009 ENSG00000157999 ENSG00000198157 ENSG00000227288 ENSG00000186831 ENSG00000226261
selection(all.genes) [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[13] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[25] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[37] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[49] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[61] TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE
[73] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE .....
GOdata <- new('topGOdata', ontology = 'BP', allGenes = all.genes, annot = annFUN.GO2genes, GO2genes = allGO2genes, geneSel = selection(all.genes), nodeSize = 10)
assignment of an object of class “logical” is not valid for @‘geneSelectionFun’ in an object of class “topGOdata”; is(value, "function") is not TRUE Calls: go.enrichment ... new -> initialize -> initialize -> .local -> <anonymous> Execution halted
Ah, this should now work:
I changed
geneSel = selection(all.genes)
togeneSel = selection
no :(
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 Calls: go.enrichment ... buildLevels -> getGraphRoot -> sapply -> adj -> adj Execution halted
Ah, looks like you are using Ensembl gene IDs. So, you need to use:
Apparently it cannot read my genes...
**Annotating nodes ............... ( 12920 genes annotated to the GO terms. )
Warning message: In .local(object, test.stat, ...) : No enrichment can pe performed - there are no feasible GO terms!**
I think that it was able to read the genes but could not find any enriched term that passed the basic thresholds.
You could try to reduce the value of
nodeSize
to 5. Also, does anything come up for the other ontologies:Otherwise, you may have to explore other tests other than Fisher's.
I usually run these functions like this:
If I use KS test I have the same warning message
And it's not possible as I'm testing genes well known to belong to pathways related to lipids