vcfR documentation

by
Brian J. Knaus and Niklaus J. Grünwald

If you experience some sort of unexpected behaviour it is possible that you have discovered a bug. Ways to report a bug include contacting me directly. If you are a GitHub user it would be better if you created an issue. The success, and efficiency, of any attempt to help you will typically depend on your ability to create a minimal reproducible example. A minimal reproducible example is a small amount of code that allows me, or others, to reproduce the behaviour you are observing. Through providing a minimal reproducible example you accomplish two things. First, it provides me with a quick way to validate that the behaviour is repeatable on my system, confirming that this is not something specific to your system. Second, it provides me with an example of the reported behaviour that I can ‘poke and prod’ so that I can (hopefully) find a solution. To create a minimal reproducible example you will need some VCF data. Data for an example can be provided by using example data included in vcfR or by using your own data.

vcfR data

The R package vcfR comes with some example data. This is used in the examples and vignettes. With a little work you can modify this example data to provide a minimal reproducible example.

library(vcfR)
data(vcfR_test)
vcfR_test
## ***** Object of Class vcfR *****
## 3 samples
## 1 CHROMs
## 5 variants
## Object size: 0 Mb
## 0 percent missing data
## *****        *****         *****

Any problem is likely to occur in the ‘gt’ or ‘fix’ slots. These are matrices that can be manipulated with the square brackets ([]).

vcfR_test@gt
##      FORMAT        NA00001          NA00002          NA00003       
## [1,] "GT:GQ:DP:HQ" "0|0:48:1:51,51" "1|0:48:8:51,51" "1/1:43:5:.,."
## [2,] "GT:GQ:DP:HQ" "0|0:49:3:58,50" "0|1:3:5:65,3"   "0/0:41:3"    
## [3,] "GT:GQ:DP:HQ" "1|2:21:6:23,27" "2|1:2:0:18,2"   "2/2:35:4"    
## [4,] "GT:GQ:DP:HQ" "0|0:54:7:56,60" "0|0:48:4:51,51" "0/0:61:2"    
## [5,] "GT:GQ:DP"    "0/1:35:4"       "0/2:17:2"       "1/1:40:3"
vcfR_test@gt[1,]
##           FORMAT          NA00001          NA00002          NA00003 
##    "GT:GQ:DP:HQ" "0|0:48:1:51,51" "1|0:48:8:51,51"   "1/1:43:5:.,."
vcfR_test@gt[1,2]
##          NA00001 
## "0|0:48:1:51,51"
# Change the genotype
vcfR_test@gt[1,2] <- "3|4:48:1:51,51"
vcfR_test@gt
##      FORMAT        NA00001          NA00002          NA00003       
## [1,] "GT:GQ:DP:HQ" "3|4:48:1:51,51" "1|0:48:8:51,51" "1/1:43:5:.,."
## [2,] "GT:GQ:DP:HQ" "0|0:49:3:58,50" "0|1:3:5:65,3"   "0/0:41:3"    
## [3,] "GT:GQ:DP:HQ" "1|2:21:6:23,27" "2|1:2:0:18,2"   "2/2:35:4"    
## [4,] "GT:GQ:DP:HQ" "0|0:54:7:56,60" "0|0:48:4:51,51" "0/0:61:2"    
## [5,] "GT:GQ:DP"    "0/1:35:4"       "0/2:17:2"       "1/1:40:3"

If you can find the part of your data that reproduces the problem you should be able to engineer an example by using this example data.

Your data

Of course, it might just be simpler if you send me your data. Some of you may not be comfortable with this, particularly if your data is unpublished. But many people have been comfortable sending me their data to troubleshoot issues. Keep in mind that VCF data ‘self documents’ in that it includes information about what software created it and information about the reference file used to call variants. I think this is interesting because I get to learn a bit about all the projects people are using vcfR with. But if you’re uncomfortable with this you may either want to use the above option, or come up with a way of obfuscating any information you are uncomfortable sharing.

Reporting the issue

Once you have some data, you should provide a few lines of code that reproduces the issue. If you can forward this data, code, and any error or warning messages to me (or post it as an issue) it should help me troubleshoot this matter. Better yet, if you use RMarkdown, sharing your *.Rmd and its compiled output from your system illustrating the matter (usually *.html), that would be great.

Lastly, it never hurts to report your session information to validate this is not a version issue. Mine is as follows.

sessionInfo()
## R version 4.2.1 (2022-06-23)
## Platform: aarch64-apple-darwin20 (64-bit)
## Running under: macOS Monterey 12.4
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] RColorBrewer_1.1-3 memuse_4.2-1       poppr_2.9.3        adegenet_2.1.9    
##  [5] ade4_1.7-20        pinfsc50_1.2.0     cowplot_1.1.1      ggplot2_3.3.6     
##  [9] reshape2_1.4.4     vcfR_1.13.0        rmarkdown_2.16    
## 
## loaded via a namespace (and not attached):
##  [1] sass_0.4.2        jsonlite_1.8.0    viridisLite_0.4.1 splines_4.2.1    
##  [5] bslib_0.4.0       shiny_1.7.2       highr_0.9         yaml_2.3.5       
##  [9] pegas_1.1         cowsay_0.8.0      pillar_1.8.1      lattice_0.20-45  
## [13] glue_1.6.2        digest_0.6.29     promises_1.2.0.1  colorspace_2.0-3 
## [17] htmltools_0.5.3   httpuv_1.6.6      Matrix_1.4-1      plyr_1.8.8       
## [21] pkgconfig_2.0.3   purrr_0.3.4       xtable_1.8-4      scales_1.2.1     
## [25] later_1.3.0       tibble_3.1.8      mgcv_1.8-40       generics_0.1.3   
## [29] farver_2.1.1      ellipsis_0.3.2    cachem_1.0.6      withr_2.5.0      
## [33] fortunes_1.5-4    cli_3.4.0         magrittr_2.0.3    crayon_1.5.1     
## [37] mime_0.12         evaluate_0.16     fansi_1.0.3       nlme_3.1-157     
## [41] MASS_7.3-57       vegan_2.6-2       praise_1.0.0      tools_4.2.1      
## [45] formatR_1.14      lifecycle_1.0.1   stringr_1.4.1     munsell_0.5.0    
## [49] cluster_2.1.3     compiler_4.2.1    jquerylib_0.1.4   rlang_1.0.5      
## [53] grid_4.2.1        igraph_1.3.5      labeling_0.4.2    boot_1.3-28      
## [57] gtable_0.3.1      R6_2.5.1          knitr_1.40        dplyr_1.0.10     
## [61] fastmap_1.1.0     seqinr_4.2-23     utf8_1.2.2        permute_0.9-7    
## [65] ape_5.6-2         stringi_1.7.8     parallel_4.2.1    polysat_1.7-7    
## [69] Rcpp_1.0.9        vctrs_0.4.1       rmsfact_0.0.3     tidyselect_1.1.2 
## [73] xfun_0.32

The benefits of reporting

If you have identified an issue with the vcfR code, then reporting this issue will have at least two positive outcomes. First, I’ll (hopefully) resolve this matter and you can continue with your research. Second, I will probably use your example to engineer a unit test. A unit test is a bit of code that is executed every time vcfR is built and tests that vcfR is operating correctly. My unit tests can be seen as a collection of code that has created issues in the past. By testing these during builds it ensures that these problems are fixed and haven’t inadvertantly been unfixed while trying to address a different issue. So by reporting issues, you can actually help make vcfR a better software. Thank you!


Copyright © 2017, 2018 Brian J. Knaus. All rights reserved.

USDA Agricultural Research Service, Horticultural Crops Research Lab.