I wrote an R function, setGt2Na()
, taking a bgzipped VCF as input, setting genotypes to missing (i.e. GT to ".") when quality is below a threshold, and writing a new bgzipped VCF. Here is an example:
library(rutilstimflutre) # my personal R pkg, see below setGt2Na(vcf.file="input.vcf.gz", genome="test", out.file="output.vcf", yieldSize=10000, min.gq=90)
But I receive the following error:
Error in unlist(Map(function(l, nm) { : error in evaluating the argument 'x' in selecting a method for function 'unlist': Error in relist(from, PartitioningByEnd(seq_along(from), names = names(from))) : error in evaluating the argument 'skeleton' in selecting a method for function 'relist': Error: could not find function "PartitioningByEnd"
Following R debugging good practices, I do the following:
traceback()
which returns:
7: unlist(Map(function(l, nm) { ifelse(l, nm, NA_character_) }, info[logicals], as(names(info)[logicals], "List"))) 6: .makeVcfInfo(info(obj), length(rd)) 5: .makeVcfMatrix(filename, obj) 4: .local(obj, filename, ...) 3: VariantAnnotation::writeVcf(obj = vcf, filename = con) 2: VariantAnnotation::writeVcf(obj = vcf, filename = con) 1: setGt2Na(vcf.file = "input.vcf.gz", genome = "test", out.file = "output.vcf", yieldSize = 10000, min.gq = 90)
The PartitioningByEnd
function belongs to thez IRanges
package, which is in the Imports
field of the DESCRIPTION
file of the VariantAnnotation
package. Moreover, my function does requireNamespace("IRanges")
at the beginning.
So do you have any idea why this error is happening?
FYI the code of the setGt2Na()
function is in my custom R pkg on GitHub. Note that, as this is my personal R pkg, it has many functions doing different stuff. To avoid having it to depend on too many packages from different fields (genomics, genetics, statistics, etc), I explicitly use requireNamespace("foo")
when I need a function from the foo
pkg in one of my function, as advised by Hadley Wickham in his book here.
Here is my sessionInfo()
:
R version 3.2.2 (2015-08-14) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS release 6.6 (Final) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rutilstimflutre_0.15.0 loaded via a namespace (and not attached): [1] AnnotationDbi_1.32.0 XVector_0.10.0 [3] GenomicAlignments_1.6.0 GenomicRanges_1.22.0 [5] BiocGenerics_0.16.0 zlibbioc_1.16.0 [7] IRanges_2.4.0 BiocParallel_1.4.0 [9] BSgenome_1.38.0 GenomeInfoDb_1.6.0 [11] tools_3.2.2 SummarizedExperiment_1.0.0 [13] parallel_3.2.2 Biobase_2.30.0 [15] data.table_1.9.6 DBI_0.3.1 [17] lambda.r_1.1.7 futile.logger_1.4.1 [19] rtracklayer_1.30.0 S4Vectors_0.8.0 [21] futile.options_1.0.0 bitops_1.0-6 [23] RCurl_1.95-4.7 biomaRt_2.26.0 [25] RSQLite_1.0.0 compiler_3.2.2 [27] GenomicFeatures_1.22.0 Rsamtools_1.22.0 [29] Biostrings_2.38.0 XML_3.98-1.3 [31] stats4_3.2.2 VariantAnnotation_1.16.0 [33] chron_2.3-47
ah yes, I see his commit, thanks