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/RtmpQHE6D3/Rbuild156a8854816bc7/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/RtmpQHE6D3/Rbuild156a8854816bc7/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.2 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.17-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.0.1  BSgenome_1.68.0      rtracklayer_1.60.0  
##  [4] GenomicRanges_1.52.0 Biostrings_2.68.1    XVector_0.40.0      
##  [7] GenomeInfoDb_1.36.1  IRanges_2.34.0       S4Vectors_0.38.1    
## [10] BiocGenerics_0.46.0  BiocStyle_2.28.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.36.0   
##  [5] promises_1.2.0.1            XML_3.99-0.14              
##  [7] digest_0.6.31               mime_0.12                  
##  [9] lifecycle_1.0.3             ellipsis_0.3.2             
## [11] processx_3.8.1              magrittr_2.0.3             
## [13] compiler_4.3.1              rlang_1.1.1                
## [15] sass_0.4.6                  tools_4.3.1                
## [17] yaml_2.3.7                  knitr_1.43                 
## [19] prettyunits_1.1.1           S4Arrays_1.0.4             
## [21] htmlwidgets_1.6.2           pkgbuild_1.4.1             
## [23] DelayedArray_0.26.3         pkgload_1.3.2              
## [25] BiocParallel_1.34.2         miniUI_0.1.1.1             
## [27] purrr_1.0.1                 desc_1.4.2                 
## [29] grid_4.3.1                  urlchecker_1.0.1           
## [31] profvis_0.3.8               xtable_1.8-4               
## [33] SummarizedExperiment_1.30.2 cli_3.6.1                  
## [35] rmarkdown_2.22              crayon_1.5.2               
## [37] remotes_2.4.2               rstudioapi_0.14            
## [39] rjson_0.2.21                sessioninfo_1.2.2          
## [41] cachem_1.0.8                stringr_1.5.0              
## [43] zlibbioc_1.46.0             parallel_4.3.1             
## [45] BiocManager_1.30.21         restfulr_0.0.15            
## [47] matrixStats_1.0.0           vctrs_0.6.3                
## [49] devtools_2.4.5              Matrix_1.5-4.1             
## [51] jsonlite_1.8.5              bookdown_0.34              
## [53] callr_3.7.3                 jquerylib_0.1.4            
## [55] glue_1.6.2                  codetools_0.2-19           
## [57] ps_1.7.5                    stringi_1.7.12             
## [59] later_1.3.1                 BiocIO_1.10.0              
## [61] htmltools_0.5.5             GenomeInfoDbData_1.2.10    
## [63] R6_2.5.1                    rprojroot_2.0.3            
## [65] evaluate_0.21               shiny_1.7.4                
## [67] lattice_0.21-8              Biobase_2.60.0             
## [69] Rsamtools_2.16.0            memoise_2.0.1              
## [71] httpuv_1.6.11               bslib_0.5.0                
## [73] Rcpp_1.0.10                 xfun_0.39                  
## [75] fs_1.6.2                    MatrixGenerics_1.12.2      
## [77] usethis_2.2.0