This is a test version of Biostars. For the public version, visit https://www.biostars.org.
do.call with gseGO not working

Hi!

I'm working on a highly configurable R script. I have made a function in witch there are several more functions, like gseGO from clusterProfiler.

To be configurable by the user I would like to call this function by do.call(gseGO, parameter_list). Where parameter_list is a list of all the parameters the user will provide.

My problem is, that when I try a test run for do.call, I got an error. My code looks like this:

gse <- do.call(gseGO, c(geneList=cluster_data[[1]],
              ont ="BP",
              keyType = "ENTREZID",
              nPerm = 10000,
              minGSSize = 3,
              maxGSSize = 800,
              pvalueCutoff = 1,
              verbose = TRUE,
              OrgDb = config$organism_org,
              pAdjustMethod = config$pAdjustMethod))

and the error is: argument "geneList" is missing, with no default

But when I run this same code without do.call like this:

gse_bp <- gseGO(geneList=cluster_data[[1]],
              ont ="BP",
              keyType = "ENTREZID",
              nPerm = 10000,
              minGSSize = 3,
              maxGSSize = 800,
              pvalueCutoff = 1,
              verbose = TRUE,
              OrgDb = config$organism_org,
              pAdjustMethod = config$pAdjustMethod)

It runs as it supposed to be with no problem.

And for the final code I would like something to look like this:

gse_bp <- do.call(gseGO, c(geneList=cluster_data[[1]],
              ont ="BP",
              keyType = "ENTREZID",
              OrgDb = config$organism_org,
              pAdjustMethod = config$pAdjustMethod,
              parameter_list))

What could be the problem? Any idea?

Thank you in advance!

do.call clusterprofiler r

1 answer

args should be a list of arguments to the function call :

gse <- do.call(gseGO, list(geneList=cluster_data[[1]],
              ont ="BP",
              keyType = "ENTREZID",
              nPerm = 10000,
              minGSSize = 3,
              maxGSSize = 800,
              pvalueCutoff = 1,
              verbose = TRUE,
              OrgDb = config$organism_org,
              pAdjustMethod = config$pAdjustMethod))

Thank you! And if I would like to make the parameter list how would I make it? If I have a list of parameters:

param <- list('nPerm=10000','minGSSize=10','maxGSSize=100')

And give it to the function:

gse_bp <- do.call(gseGO, list(geneList=data[[1]],
                  ont ="BP",
                  keyType = "ENTREZID",
                  pvalueCutoff = 1,
                  OrgDb = config$organism_org,
                  pAdjustMethod = config$pAdjustMethod,
                  param))

I still get an error:

Error in abs(stats)^gseaParam : non-numeric argument to binary operator

I guess its because in the list the format is not correct for a parameter, but how can I make it work?

OK! I found it out! :)

Remove the quotation marks otherwise the list will not consider the argument

param <- list(nPerm=10000,minGSSize=10,maxGSSize=100) 

At final, you need to have a single list so just concatenate your list of former arguments and the new list of arguments:

gse_bp <- do.call(gseGO, c(param,list(geneList=data[[1]],
                  ont ="BP",
                  keyType = "ENTREZID",
                  pvalueCutoff = 1,
                  OrgDb = config$organism_org,
                  pAdjustMethod = config$pAdjustMethod)))

Log in to answer this question.