Public Data Integration using Sfaira

Alexander Dietrich


Sfaira Integeration

This vignette will cover the integration of the public database Sfaria.


As a public database, sfaira (Fischer et al. 2020) is used, which is a dataset and model repository for single-cell RNA-sequencing data. It gives access to about multiple datasets from human and mouse with more than 3 million cells in total. You can browse them interactively here: Note that only annotated datasets will be downloaded! Also there are cases of datasets, which have private URLs and cannot be automatically downloaded; SimBu will skip these datasets.
In order to use this database, we first need to install it. This can easily be done, by running the setup_sfaira() function for the first time. In the background we use the basilisik package to establish a conda environment that has all sfaira dependencies installed. The installation will be only performed one single time, even if you close your R session and call setup_sfaira() again. The given directory serves as the storage for all future downloaded datasets from sfaira:

setup_list <- SimBu::setup_sfaira(basedir = tempdir())

Creating a dataset

We will now create a dataset of samples from human pancreas using the organisms and tissues parameter. You can provide a single word (like we do here) or for example a list of tissues you want to download: c("pancreas","lung"). An additional parameter is the assays parameter, where you subset the database further to only download datasets from certain sequencing assays (for examples Smart-seq2).
The name parameter is used later on to give each sample (cell) a unique name.

ds_pancrease <- SimBu::dataset_sfaira_multiple(
  sfaira_setup = setup_list,
  organisms = "Homo sapiens",
  tissues = "pancreas",
  name = "human_pancreas"

Currently there are three datasets in sfaira from human pancreas, which have cell-type annotation. The package will download them for you automatically and merge them together into a single expression matrix and a streamlined annotation table, which we can use for our simulation.
It can happen, that some datasets from sfaira are not (yet) ready for the automatic download, an error message will then appear in R, telling you which file to download and where to put it.

If you wish to see all datasets which are included in sfaira you can use the following command:

all_datasets <- SimBu::sfaira_overview(setup_list = setup_list)

This allows you to find the specific IDs of datasets, which you can download directly:

  sfaira_id = "homosapiens_lungparenchyma_2019_10x3v2_madissoon_001_10.1186/s13059-019-1906-x",
  sfaira_setup = setup_list,
  name = "dataset_by_id"
#> R version 4.2.2 (2022-10-31)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.5 LTS
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.16-bioc/R/lib/
#> LAPACK: /home/biocbuild/bbs-3.16-bioc/R/lib/
#> 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            
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> other attached packages:
#> [1] SimBu_1.0.2
#> loaded via a namespace (and not attached):
#>  [1] SummarizedExperiment_1.28.0 tidyselect_1.2.0           
#>  [3] xfun_0.37                   bslib_0.4.2                
#>  [5] purrr_1.0.1                 lattice_0.20-45            
#>  [7] colorspace_2.1-0            vctrs_0.5.2                
#>  [9] generics_0.1.3              htmltools_0.5.4            
#> [11] stats4_4.2.2                yaml_2.3.7                 
#> [13] utf8_1.2.3                  rlang_1.0.6                
#> [15] jquerylib_0.1.4             pillar_1.8.1               
#> [17] glue_1.6.2                  withr_2.5.0                
#> [19] BiocParallel_1.32.5         RColorBrewer_1.1-3         
#> [21] BiocGenerics_0.44.0         matrixStats_0.63.0         
#> [23] GenomeInfoDbData_1.2.9      lifecycle_1.0.3            
#> [25] zlibbioc_1.44.0             MatrixGenerics_1.10.0      
#> [27] munsell_0.5.0               gtable_0.3.1               
#> [29] proxyC_0.3.3                codetools_0.2-19           
#> [31] evaluate_0.20               labeling_0.4.2             
#> [33] Biobase_2.58.0              knitr_1.42                 
#> [35] IRanges_2.32.0              fastmap_1.1.1              
#> [37] GenomeInfoDb_1.34.9         parallel_4.2.2             
#> [39] fansi_1.0.4                 highr_0.10                 
#> [41] Rcpp_1.0.10                 scales_1.2.1               
#> [43] cachem_1.0.7                DelayedArray_0.24.0        
#> [45] S4Vectors_0.36.2            RcppParallel_5.1.7         
#> [47] jsonlite_1.8.4              XVector_0.38.0             
#> [49] farver_2.1.1                ggplot2_3.4.1              
#> [51] digest_0.6.31               dplyr_1.1.0                
#> [53] GenomicRanges_1.50.2        grid_4.2.2                 
#> [55] cli_3.6.0                   tools_4.2.2                
#> [57] bitops_1.0-7                magrittr_2.0.3             
#> [59] sass_0.4.5                  RCurl_1.98-1.10            
#> [61] tibble_3.2.0                tidyr_1.3.0                
#> [63] pkgconfig_2.0.3             Matrix_1.5-3               
#> [65] data.table_1.14.8           sparseMatrixStats_1.10.0   
#> [67] rmarkdown_2.20              R6_2.5.1                   
#> [69] compiler_4.2.2

Fischer, David S., Leander Dony, Martin König, Abdul Moeed, Luke Zappia, Sophie Tritschler, Olle Holmberg, Hananeh Aliee, and Fabian J. Theis. 2020. “Sfaira Accelerates Data and Model Reuse in Single Cell Genomics.” bioRxiv.