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/RtmpbHE2a8/Rbuild32edac4b7b5d75/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/RtmpbHE2a8/Rbuild32edac4b7b5d75/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.3 (2024-02-29)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.04.4 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.3  BSgenome_1.70.2      rtracklayer_1.62.0  
##  [4] BiocIO_1.12.0        GenomicRanges_1.54.1 Biostrings_2.70.3   
##  [7] XVector_0.42.0       GenomeInfoDb_1.38.8  IRanges_2.36.0      
## [10] S4Vectors_0.40.2     BiocGenerics_0.48.1  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.14             GenomicAlignments_1.38.2   
##  [5] promises_1.2.1              XML_3.99-0.16.1            
##  [7] digest_0.6.35               mime_0.12                  
##  [9] lifecycle_1.0.4             ellipsis_0.3.2             
## [11] processx_3.8.4              magrittr_2.0.3             
## [13] compiler_4.3.3              rlang_1.1.3                
## [15] sass_0.4.9                  tools_4.3.3                
## [17] yaml_2.3.8                  knitr_1.45                 
## [19] S4Arrays_1.2.1              htmlwidgets_1.6.4          
## [21] pkgbuild_1.4.4              DelayedArray_0.28.0        
## [23] pkgload_1.3.4               abind_1.4-5                
## [25] BiocParallel_1.36.0         miniUI_0.1.1.1             
## [27] purrr_1.0.2                 desc_1.4.3                 
## [29] grid_4.3.3                  urlchecker_1.0.1           
## [31] profvis_0.3.8               xtable_1.8-4               
## [33] SummarizedExperiment_1.32.0 cli_3.6.2                  
## [35] rmarkdown_2.26              crayon_1.5.2               
## [37] remotes_2.5.0               rstudioapi_0.16.0          
## [39] rjson_0.2.21                sessioninfo_1.2.2          
## [41] cachem_1.0.8                stringr_1.5.1              
## [43] zlibbioc_1.48.2             parallel_4.3.3             
## [45] BiocManager_1.30.22         restfulr_0.0.15            
## [47] matrixStats_1.2.0           vctrs_0.6.5                
## [49] devtools_2.4.5              Matrix_1.6-5               
## [51] jsonlite_1.8.8              bookdown_0.38              
## [53] callr_3.7.6                 jquerylib_0.1.4            
## [55] glue_1.7.0                  codetools_0.2-19           
## [57] ps_1.7.6                    stringi_1.8.3              
## [59] later_1.3.2                 htmltools_0.5.7            
## [61] GenomeInfoDbData_1.2.11     R6_2.5.1                   
## [63] evaluate_0.23               shiny_1.8.0                
## [65] lattice_0.22-6              Biobase_2.62.0             
## [67] Rsamtools_2.18.0            memoise_2.0.1              
## [69] httpuv_1.6.14               bslib_0.6.2                
## [71] Rcpp_1.0.12                 SparseArray_1.2.4          
## [73] xfun_0.43                   fs_1.6.3                   
## [75] MatrixGenerics_1.14.0       usethis_2.2.3