I met an error when running "locateVariants" function in "VariantAnnotation" package. Before running "locateVariants" function, I need to first libarary "tidyverse", but when I library "tidyverse" package before "VariantAnnotation" and run "locateVariants" function, an error happens ("Error in as.vector(x) : no method for coercing this S4 class to a vector"). But it works when library "VariantAnnotation" and run "locateVariants" function first. Could anyone please explain to me why it happens and how could I do to make it work when library "tidyverse" first? Here is the code that can reproduce the error.
The "rd_test.rds" file can be downloaded here https://drive.google.com/open?id=0BwtKdDxl2iyQaUc5ZW9rM2FPVnc, the "Homo_sapiens.GRCh38.90.sqlite" file can be downloaded here https://drive.google.com/open?id=0BwtKdDxl2iyQQTZJZlVJS2NzWjA
## Start a new R session rd_test <- readRDS("rd_test.rds") library(GenomicFeatures) txdb <- loadDb("Homo_sapiens.GRCh38.90.sqlite") library(VariantAnnotation) allvar <- locateVariants(rd_test, txdb, AllVariants()) library(tidyverse) allvar <- locateVariants(rd_test, txdb, AllVariants()) ## "locateVariants" function works when library "VariantAnnotation" and run "locateVariants" function then library "tidyverse" sessionInfo() # R version 3.4.1 (2017-06-30) # Platform: x86_64-pc-linux-gnu (64-bit) # Running under: Ubuntu 16.04.1 LTS # # Matrix products: default # BLAS: /usr/lib/atlas-base/atlas/libblas.so.3.0 # LAPACK: /usr/lib/atlas-base/atlas/liblapack.so.3.0 # # locale: # [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C 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 LC_PAPER=en_US.UTF-8 LC_NAME=C # [9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C # # attached base packages: # [1] parallel stats4 stats graphics utils datasets grDevices methods base # # other attached packages: # [1] dplyr_0.7.2 purrr_0.2.3 readr_1.1.1 tidyr_0.7.0 # [5] tibble_1.3.4 ggplot2_2.2.1 tidyverse_1.1.1 VariantAnnotation_1.20.3 # [9] Rsamtools_1.26.2 Biostrings_2.42.1 XVector_0.14.1 SummarizedExperiment_1.4.0 # [13] GenomicFeatures_1.26.4 AnnotationDbi_1.36.2 Biobase_2.34.0 GenomicRanges_1.26.4 # [17] GenomeInfoDb_1.10.3 IRanges_2.8.2 S4Vectors_0.12.2 BiocGenerics_0.20.0 # [21] setwidth_1.0-4 colorout_1.1-2 # # loaded via a namespace (and not attached): # [1] Rcpp_0.12.12 lubridate_1.6.0 lattice_0.20-35 assertthat_0.2.0 # [5] digest_0.6.12 psych_1.7.5 cellranger_1.1.0 R6_2.2.2 # [9] plyr_1.8.4 RSQLite_2.0 httr_1.3.1 zlibbioc_1.20.0 # [13] rlang_0.1.2 readxl_1.0.0 lazyeval_0.2.0 blob_1.1.0 # [17] Matrix_1.2-11 BiocParallel_1.8.2 stringr_1.2.0 foreign_0.8-69 # [21] RCurl_1.95-4.8 bit_1.1-12 biomaRt_2.30.0 munsell_0.4.3 # [25] broom_0.4.2 modelr_0.1.1 compiler_3.4.1 rtracklayer_1.34.2 # [29] pkgconfig_2.0.1 mnormt_1.5-5 XML_3.98-1.9 GenomicAlignments_1.10.1 # [33] bitops_1.0-6 grid_3.4.1 nlme_3.1-131 jsonlite_1.5 # [37] gtable_0.2.0 DBI_0.7 magrittr_1.5 scales_0.4.1 # [41] stringi_1.1.5 reshape2_1.4.2 bindrcpp_0.2 xml2_1.1.1 # [45] tools_3.4.1 forcats_0.2.0 bit64_0.9-7 BSgenome_1.42.0 # [49] glue_1.1.1 hms_0.3 yaml_2.1.14 colorspace_1.3-2 # [53] rvest_0.3.2 memoise_1.1.0 bindr_0.1 haven_1.1.0
## Start a new R session
rd_test <- readRDS("rd_test.rds")
library(GenomicFeatures)
txdb <- loadDb("Homo_sapiens.GRCh38.90.sqlite")
library(tidyverse)
library(VariantAnnotation)
allvar <- locateVariants(rd_test, txdb, AllVariants())
# 'select()' returned 1:1 mapping between keys and columns
# Error in as.vector(x) : no method for coercing this S4 class to a vector
traceback()
sessionInfo()
# R version 3.4.1 (2017-06-30)
# Platform: x86_64-pc-linux-gnu (64-bit)
# Running under: Ubuntu 16.04.1 LTS
#
# Matrix products: default
# BLAS: /usr/lib/atlas-base/atlas/libblas.so.3.0
# LAPACK: /usr/lib/atlas-base/atlas/liblapack.so.3.0
#
# locale:
# [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C 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 LC_PAPER=en_US.UTF-8 LC_NAME=C
# [9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
#
# attached base packages:
# [1] parallel stats4 stats graphics utils datasets grDevices methods base
#
# other attached packages:
# [1] VariantAnnotation_1.20.3 Rsamtools_1.26.2 Biostrings_2.42.1 XVector_0.14.1
# [5] SummarizedExperiment_1.4.0 dplyr_0.7.2 purrr_0.2.3 readr_1.1.1
# [9] tidyr_0.7.0 tibble_1.3.4 ggplot2_2.2.1 tidyverse_1.1.1
# [13] GenomicFeatures_1.26.4 AnnotationDbi_1.36.2 Biobase_2.34.0 GenomicRanges_1.26.4
# [17] GenomeInfoDb_1.10.3 IRanges_2.8.2 S4Vectors_0.12.2 BiocGenerics_0.20.0
# [21] setwidth_1.0-4 colorout_1.1-2
#
# loaded via a namespace (and not attached):
# [1] Rcpp_0.12.12 lubridate_1.6.0 lattice_0.20-35 assertthat_0.2.0
# [5] digest_0.6.12 psych_1.7.5 cellranger_1.1.0 R6_2.2.2
# [9] plyr_1.8.4 RSQLite_2.0 httr_1.3.1 zlibbioc_1.20.0
# [13] rlang_0.1.2 readxl_1.0.0 lazyeval_0.2.0 blob_1.1.0
# [17] Matrix_1.2-11 BiocParallel_1.8.2 stringr_1.2.0 foreign_0.8-69
# [21] RCurl_1.95-4.8 bit_1.1-12 biomaRt_2.30.0 munsell_0.4.3
# [25] broom_0.4.2 compiler_3.4.1 modelr_0.1.1 rtracklayer_1.34.2
# [29] pkgconfig_2.0.1 mnormt_1.5-5 XML_3.98-1.9 GenomicAlignments_1.10.1
# [33] bitops_1.0-6 grid_3.4.1 nlme_3.1-131 jsonlite_1.5
# [37] gtable_0.2.0 DBI_0.7 magrittr_1.5 scales_0.4.1
# [41] stringi_1.1.5 reshape2_1.4.2 bindrcpp_0.2 xml2_1.1.1
# [45] tools_3.4.1 forcats_0.2.0 bit64_0.9-7 BSgenome_1.42.0
# [49] glue_1.1.1 hms_0.3 yaml_2.1.14 colorspace_1.3-2
# [53] rvest_0.3.2 memoise_1.1.0 bindr_0.1 haven_1.1.0
## "locateVariants" function doesn't work when library "tidyverse" first and then library "VariantAnnotation" and run "locateVariants" function
I need to library "tidyverse" before running "locateVariants" function, I am looking forward to some one can help me with it. Thanks!
Yuzhu
Hi Herve,
Thanks for your solution! I am looking forward to using your new release of S4Vectors package!
Cheers,
Yuzhu