Contents

1 Introduction

BSgenome data packages are one of the many types of annotation packages available in Bioconductor. They contain the genomic sequences, which comprise chromosome sequences and other DNA sequences of a particular genome assembly for a given organism. For example BSgenome.Hsapiens.UCSC.hg19 is a BSgenome data package that contains the genomic sequences of the hg19 genome from UCSC. Users can easily and efficiently access the sequences, or portions of the sequences, stored in these packages, via a common API implemented in the BSgenome software package.

Bioconductor currently provides more than 100 BSgenome data packages, for more than 30 organisms. Most of them contain the genomic sequences of UCSC genomes (i.e. genomes supported by the UCSC Genome Browser) or NCBI assemblies. The packages are used in various Bioconductor workflows, as well as in man page examples and vignettes of other Bioconductor packages, typically in conjunction with tools available in the BSgenomeForge and Biostrings software packages. New BSgenome data packages get added on a regular basis, based on user demand.

The current process of forging a BSgenome data package requires one to download the sequence data files, either as a single twoBit file (e.g. musFur1.2bit) or in a collection of compressed FASTA files. The user then needs to prepare the BSgenome data package seed file, and then call forgeBSgenomeDataPkg function on the seed file to forge the package. This is quite a convoluted task that can be an inconvenience for the average user.

The BSgenomeForge package simplifies the whole process, by allowing the user to use one function to create a BSgenome data package. It is comprised of two main functions: forgeBSgenomeDataPkgfromNCBI and forgeBSgenomeDataPkgfromUCSC which allow the user to forge BSgenome data packages with sequence data files sourced from NCBI or UCSC respectively.

2 Installation

if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("BSgenomeForge")

3 Basic usage

3.1 Using forgeBSgenomeDataPkgFromNCBI()

library(BSgenomeForge)

Example 1: Information about assembly ASM972954v1 can be found at https://www.ncbi.nlm.nih.gov/assembly/GCF_009729545.1/, including the assembly accession, GCA_009729545.1 and organism name, Acidianus infernus. Assembly ASM972954v1 does not contain any circular sequences to be specified:

forgeBSgenomeDataPkgFromNCBI(assembly_accession="GCA_009729545.1",
                             pkg_maintainer="Jane Doe <janedoe@gmail.com>",
                             organism="Acidianus infernus")
## Creating package in ./BSgenome.Ainfernus.NCBI.ASM972954v1

Example 2: Information about assembly ASM836960v1 can be found at https://www.ncbi.nlm.nih.gov/assembly/GCA_008369605.1/, including the assembly accession, GCA_008369605.1 and organism name, Vibrio cholerae. Assembly ASM836960v1 contains three circular sequence, “1”, “2” and “unnamed”. See CP043554.1, CP043556.1, and CP043555.1 in the NCBI Nucleotide database at https://www.ncbi.nlm.nih.gov/nuccore/. They must be specified as shown in the example below:

forgeBSgenomeDataPkgFromNCBI(assembly_accession="GCA_008369605.1",
                             pkg_maintainer="Jane Doe <janedoe@gmail.com>",
                             organism="Vibrio cholerae",
                             circ_seqs = c("1", "2", "unnamed"))
## Creating package in ./BSgenome.Vcholerae.NCBI.ASM836960v1

Check ?forgeBSgenomeDataPkgFromNCBI for more information.

3.2 Using forgeBSgenomeDataPkgFromUCSC()

Example 3: Information about genome wuhCor1 can be found at https://genome.ucsc.edu/cgi-bin/hgGateway. This belongs to the organism Severe acute respiratory syndrome coronavirus 2. Genome wuhCor1 does not contain any circular sequences to be specified:

forgeBSgenomeDataPkgFromUCSC(
    genome="wuhCor1",
    organism="Severe acute respiratory syndrome coronavirus 2",
    pkg_maintainer="Jane Doe <janedoe@gmail.com>"
)
## Creating package in ./BSgenome.Scoronavirus2.UCSC.wuhCor1

Check ?forgeBSgenomeDataPkgFromUCSC for more information.

4 Final steps

forgeBSgenomeDataPkgfromNCBI or forgeBSgenomeDataPkgfromUCSC returns the path to the created package at the end of its execution. This can be used to find the package location, and afterwards carry out the following commands to build the package source tarball via command line (i.e. in a Linux/Unix terminal or Windows PowerShell terminal).

R CMD build <pkgdir>

where <pkgdir> is the path to the source tree of the package. Then check the package with

R CMD check <tarball>

where <tarball> is the path to the tarball produced by R CMD build. Finally install the package with

R CMD INSTALL <tarball>

These operations can also be carried out within R, instead, using the devtools package

devtools::build("./BSgenome.Ainfernus.NCBI.ASM972954v1")
## ── R CMD build ─────────────────────────────────────────────────────────────────
## * checking for file ‘/tmp/RtmpmDPaL3/Rbuild23573415d139be/BSgenomeForge/vignettes/BSgenome.Ainfernus.NCBI.ASM972954v1/DESCRIPTION’ ... OK
## * preparing ‘BSgenome.Ainfernus.NCBI.ASM972954v1’:
## * checking DESCRIPTION meta-information ... OK
## * checking for LF line-endings in source and make files and shell scripts
## * checking for empty or unneeded directories
## * building ‘BSgenome.Ainfernus.NCBI.ASM972954v1_1.0.0.tar.gz’
## [1] "/tmp/RtmpmDPaL3/Rbuild23573415d139be/BSgenomeForge/vignettes/BSgenome.Ainfernus.NCBI.ASM972954v1_1.0.0.tar.gz"
devtools::check_built("BSgenome.Ainfernus.NCBI.ASM972954v1_1.0.0.tar.gz")
devtools::install_local("BSgenome.Ainfernus.NCBI.ASM972954v1_1.0.0.tar.gz")

5 sessionInfo()

sessionInfo()
## R version 4.3.1 (2023-06-16)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.04.3 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.18-bioc/R/lib/libRblas.so 
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_GB              LC_COLLATE=C              
##  [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       
## 
## time zone: America/New_York
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] BSgenomeForge_1.2.0  BSgenome_1.70.0      rtracklayer_1.62.0  
##  [4] BiocIO_1.12.0        GenomicRanges_1.54.0 Biostrings_2.70.0   
##  [7] XVector_0.42.0       GenomeInfoDb_1.38.0  IRanges_2.36.0      
## [10] S4Vectors_0.40.0     BiocGenerics_0.48.0  BiocStyle_2.30.0    
## 
## loaded via a namespace (and not attached):
##  [1] bitops_1.0-7                fastmap_1.1.1              
##  [3] RCurl_1.98-1.12             GenomicAlignments_1.38.0   
##  [5] promises_1.2.1              XML_3.99-0.14              
##  [7] digest_0.6.33               mime_0.12                  
##  [9] lifecycle_1.0.3             ellipsis_0.3.2             
## [11] processx_3.8.2              magrittr_2.0.3             
## [13] compiler_4.3.1              rlang_1.1.1                
## [15] sass_0.4.7                  tools_4.3.1                
## [17] yaml_2.3.7                  knitr_1.44                 
## [19] prettyunits_1.2.0           S4Arrays_1.2.0             
## [21] htmlwidgets_1.6.2           pkgbuild_1.4.2             
## [23] DelayedArray_0.28.0         pkgload_1.3.3              
## [25] abind_1.4-5                 BiocParallel_1.36.0        
## [27] miniUI_0.1.1.1              purrr_1.0.2                
## [29] desc_1.4.2                  grid_4.3.1                 
## [31] urlchecker_1.0.1            profvis_0.3.8              
## [33] xtable_1.8-4                SummarizedExperiment_1.32.0
## [35] cli_3.6.1                   rmarkdown_2.25             
## [37] crayon_1.5.2                remotes_2.4.2.1            
## [39] rstudioapi_0.15.0           rjson_0.2.21               
## [41] sessioninfo_1.2.2           cachem_1.0.8               
## [43] stringr_1.5.0               zlibbioc_1.48.0            
## [45] parallel_4.3.1              BiocManager_1.30.22        
## [47] restfulr_0.0.15             matrixStats_1.0.0          
## [49] vctrs_0.6.4                 devtools_2.4.5             
## [51] Matrix_1.6-1.1              jsonlite_1.8.7             
## [53] bookdown_0.36               callr_3.7.3                
## [55] jquerylib_0.1.4             glue_1.6.2                 
## [57] codetools_0.2-19            ps_1.7.5                   
## [59] stringi_1.7.12              later_1.3.1                
## [61] htmltools_0.5.6.1           GenomeInfoDbData_1.2.11    
## [63] R6_2.5.1                    rprojroot_2.0.3            
## [65] evaluate_0.22               shiny_1.7.5.1              
## [67] lattice_0.22-5              Biobase_2.62.0             
## [69] Rsamtools_2.18.0            memoise_2.0.1              
## [71] httpuv_1.6.12               bslib_0.5.1                
## [73] Rcpp_1.0.11                 SparseArray_1.2.0          
## [75] xfun_0.40                   fs_1.6.3                   
## [77] MatrixGenerics_1.14.0       usethis_2.2.2