This is a test version of Biostars. For the public version, visit https://www.biostars.org.
TopGO based on gene expression

Hello, I want to run gene set enrichment analysis based on gene expression values in TopGO but I cannot find an example in the TopGO tutorial nor in the manual. It does not say how the expression matrix should look like. I tried to create a TopGOdata object like this:

geneList = dat$TPM
names(geneList) = dat$gene
topDiffGenes = function(allScore) {return(allScore > 1)}
matrix = as.matrix(column_to_rownames(dat, "gene")) # convert the dataframe to matrix

GOdata = new("topGOdata", ontology = "BP", allGenes = geneList,
geneSel = topDiffGenes,  annot = annFUN.gene2GO, gene2GO = bpGO, nodeSize = 5, 
expressionMatrix = matrix)

And then I run the test:

runTest(GOdata, algorithm = "elim", statistic = "globaltest")

But I get the error:

Error in getSigGroups(object, test.stat) : No expression data found

How can I correctly load the expression matrix in the TopGOdata object?

Here the sessionInfo:

sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats4    parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] tibble_3.0.0         topGO_2.38.1         SparseM_1.78         GO.db_3.10.0         AnnotationDbi_1.48.0 IRanges_2.20.2      
 [7] S4Vectors_0.24.3     Biobase_2.46.0       graph_1.64.0         BiocGenerics_0.32.0 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4         rstudioapi_0.11    magrittr_1.5       bit_1.1-15.2       lattice_0.20-41    rlang_0.4.5        fansi_0.4.1       
 [8] blob_1.2.1         tools_3.6.2        grid_3.6.2         cli_2.0.2          DBI_1.1.0          ellipsis_0.3.0     matrixStats_0.56.0
[15] assertthat_0.2.1   yaml_2.2.1         bit64_0.9-7        digest_0.6.25      lifecycle_0.2.0    crayon_1.3.4       vctrs_0.2.4       
[22] glue_1.4.0         memoise_1.1.0      RSQLite_2.2.0      pillar_1.4.3       compiler_3.6.2     pkgconfig_2.0.3

Thank you!

Giulia

rna-seq

1 answer

Hi, the error is cryptic and may be misleading. I think that you just need to set the value of testStatistic when running new(). So, per esempio:

GOdata = new('topGOdata',
  ontology = 'BP',
  allGenes = geneList,
  geneSel = topDiffGenes,
  annot = annFUN.gene2GO,
  gene2GO = bpGO,
  nodeSize = 5,
  expressionMatrix = matrix,
  testStatistic = GOglobalTest)

runTest(GOdata, algorithm = "elim", statistic = "globaltest")

Possible values for `testStatistic are:

.testNames <- c("GOFisherTest" , "GOKSTest", "GOtTest", "GOglobalTest", "GOSumTest", "GOKSTiesTest")

Kevin

Log in to answer this question.