do.call with gseGO not working
1
0
Entering edit mode
2.0 years ago
Pahi ▴ 30

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 • 967 views
ADD COMMENT
2
Entering edit mode
2.0 years ago
Basti ★ 2.0k

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))
ADD COMMENT
0
Entering edit mode

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?

ADD REPLY
1
Entering edit mode

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)))
ADD REPLY
0
Entering edit mode

OK! I found it out! :)

ADD REPLY

Login before adding your answer.

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