Closed harrig12 closed 4 years ago
Hi, Thanks for using maftools and I am glad that you find it useful. Regarding the issue I can not think of any workarounds for it. It seems to be an issue with cascading environments and scope of variables. I will read more and see if I can find any solution.
@harrig12 Here I put a workaound, hope it helps
library(maftools)
laml.maf <- system.file("extdata", "tcga_laml.maf.gz", package = "maftools")
laml <- read.maf(maf = laml.maf)
# In global env this works fine
classes = c('Splice_Site', "Frame_Shift_Ins")
subsetMaf(maf = laml, query = "Variant_Classification %in% classes")
myFun <- function(maf, myClasses){
myClasses <- deparse(dput(myClasses))
subsetted_maf <- subsetMaf(maf, query = paste0("Variant_Classification %in% ", myClasses))
return(subsetted_maf)
}
z = myFun(laml, classes)
table(z@data$Variant_Classification)
That's a pretty neat trick!
I am closing this issue for now since @ShixiangWang answer seems to work. Please feel free to reopen if necessary.
Enjoying maftools. Excellent package, thank you!
I have an issue that I think may have more to do with the defaults in
eval
/parse
thansubsetMaf
, but it is in usingsubsetMaf
that I noticed this, and it is a bit inconvenient.Seems that there is something odd about the behavior of the environment that a custom query is evaluated in. Using subsetMaf in the global environment, there is no problem, but from within a function it can't "see" an object that should be available to it, passed through a function.
MWE
Here's the output
Session info