xenLite: exploration of a class for Xenium demonstration data (original) (raw)
Contents
Introduction
Motivation
Numerous groups are working on methodology for analyzing new data resources emerging from spatial transcriptomics experiments. The “computing technology stack” necessary to work with such data is complex. The followingcomment(Aug 16 2024) from the scverse group is characteristic:
The SpatialData Zarr format, which is described in our design doc, is an extension of the OME-NGFF specification, which makes use of the OME-Zarr, the AnnData Zarr and the Parquet file formats. We need to use these combination of technologies because currently OME-NGFF does not provide all the fundamentals required for storing spatial omics dataset; nevertheless, we try to stay as close as OME-NGFF as possible, and we are contributing to ultimately make spatial omics support available in pure OME-NGFF.
In Bioconductor 3.19, we might be committed to all these technologies (which include but do not mention HDF5) plus R, reticulate, basilisk, and sf to have a widely functional solution. Attaching the Voyagerpackage leads to loading over 100 associated packages. The xenLite package is intended to explore the balance between functionality and high dependency load specifically for the analysis of outputs from 10x Xenium experiments. The XenSPEP class extendsSpatialExperiment to include references to parquet files that manage voluminous geometry data; geometry can also be handled as DataFrame for sufficiently low volume experiments.
As of 0.0.7 of xenLite, a new class, XenSPEP, is provided to address parquet representation of cell, nucleus and transcript coordinates.
Installation
To install in Bioconductor 3.20 or later:
BiocManager::install("xenLite")
Data
This package is based on publicly available datasets.
- Human dermal melanoma FFPE Human pan tissue dataset. For this dataset, we retrieved the
outs.zip
file from this site and ranXenSCE::ingestXen
on the contents, producing a XenSPEP instance which was then saved in an HDF5-backed representation. This, along with the parquet files for cell, nucleus, and transcript coordinates, are zipped together and placed in an Open Storage Network bucket for retrieval viacacheXenPdmelLite
. - Human prostate adenocarcinoma FFPE Human pan tissue dataset. For this dataset, we retrieved the
outs.zip
file from this site and ranXenSCE::ingestXen
on the contents, producing a XenSPEP instance which was then saved in an HDF5-backed representation. This, along with the parquet files for cell, nucleus, and transcript coordinates, are zipped together and placed in an Open Storage Network bucket for retrieval viacacheXenProstLite
. - Human Lung FFPE Lung cancer preview, Use
example(cacheXenLuad)
to obtain this instance of XenSPEP.
A quick look
Hybrid example
In this example, transcript counts are in memory in a sparse matrix, but geometry information is handled in parquet. The viewSegG2
function allows selection of two gene symbols, and cells are colored according to single or double occupancy.
library(xenLite)
pa <- cacheXenLuad()
luad <- restoreZipXenSPEP(pa)
rownames(luad) <- make.names(SummarizedExperiment:::rowData(luad)$Symbol, unique = TRUE)
out <- viewSegG2(luad, c(5800, 6300), c(1300, 1800), lwd = .5, gene1 = "CD4", gene2 = "EPCAM")
legend(5800, 1390, fill = c("purple", "cyan", "pink"), legend = c("CD4", "EPCAM", "both"))
## [1] 2074
Interactivity
In inst/app4
, code is provided to work with the primary dermal melanoma dataset. A map of the cell coordinates can drive focused exploration. The region of interest is shown by a whitened rectangle in the upper left corner.
Figure 1: Map based on cell centroids
Cells are colored by quintile of size. Points where FBL transcripts are found are plotted as dots.
Figure 2: Zoom to slider-specified subplot
More work is needed to identify useful exploratory visualizations.
Large disk-based example
HDF5+parquet-backed example: not ready in xenLite
We want to be able to accommodate very large numbers of cells and transcripts without heavy infrastructure commitments.
We’ll use the prostate adenocarcinoma 5K dataset to demonstrate. A 900MB zip file will be cached.
prost <- cacheXenProstLite()
prost
is the path to a zip file in a BiocFileCache instance.
Create a folder to work in, and unzip.
dir.create(xpw <- file.path(tempdir(), "prost_work"))
unzip(prost, exdir = xpw)
dir(xpw)
Restore the SpatialExperiment component.
prostx <- HDF5Array::loadHDF5SummarizedExperiment(file.path(xpw, "xen_prost"))
prostx
Session information
## R version 4.5.0 RC (2025-04-04 r88126)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.2 LTS
##
## Matrix products: default
## BLAS: /home/biocbuild/bbs-3.21-bioc/R/lib/libRblas.so
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0 LAPACK version 3.12.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] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] xenLite_1.2.1 BiocStyle_2.36.0
##
## loaded via a namespace (and not attached):
## [1] tidyselect_1.2.1 EBImage_4.50.0
## [3] dplyr_1.1.4 farver_2.1.2
## [5] blob_1.2.4 arrow_20.0.0
## [7] filelock_1.0.3 bitops_1.0-9
## [9] fastmap_1.2.0 SingleCellExperiment_1.30.1
## [11] RCurl_1.98-1.17 BiocFileCache_2.16.0
## [13] promises_1.3.2 digest_0.6.37
## [15] mime_0.13 lifecycle_1.0.4
## [17] RSQLite_2.3.11 magrittr_2.0.3
## [19] compiler_4.5.0 rlang_1.1.6
## [21] sass_0.4.10 tools_4.5.0
## [23] yaml_2.3.10 knitr_1.50
## [25] S4Arrays_1.8.0 htmlwidgets_1.6.4
## [27] bit_4.6.0 curl_6.2.2
## [29] DelayedArray_0.34.1 RColorBrewer_1.1-3
## [31] abind_1.4-8 HDF5Array_1.36.0
## [33] withr_3.0.2 purrr_1.0.4
## [35] BiocGenerics_0.54.0 grid_4.5.0
## [37] stats4_4.5.0 xtable_1.8-4
## [39] Rhdf5lib_1.30.0 ggplot2_3.5.2
## [41] scales_1.4.0 tinytex_0.57
## [43] dichromat_2.0-0.1 SummarizedExperiment_1.38.1
## [45] cli_3.6.5 rmarkdown_2.29
## [47] crayon_1.5.3 generics_0.1.4
## [49] rjson_0.2.23 httr_1.4.7
## [51] DBI_1.2.3 cachem_1.1.0
## [53] rhdf5_2.52.0 assertthat_0.2.1
## [55] BiocManager_1.30.25 XVector_0.48.0
## [57] tiff_0.1-12 matrixStats_1.5.0
## [59] vctrs_0.6.5 Matrix_1.7-3
## [61] jsonlite_2.0.0 bookdown_0.43
## [63] IRanges_2.42.0 fftwtools_0.9-11
## [65] S4Vectors_0.46.0 bit64_4.6.0-1
## [67] magick_2.8.6 jpeg_0.1-11
## [69] h5mread_1.0.0 locfit_1.5-9.12
## [71] jquerylib_0.1.4 glue_1.8.0
## [73] gtable_0.3.6 later_1.4.2
## [75] GenomeInfoDb_1.44.0 GenomicRanges_1.60.0
## [77] UCSC.utils_1.4.0 tibble_3.2.1
## [79] pillar_1.10.2 htmltools_0.5.8.1
## [81] rhdf5filters_1.20.0 GenomeInfoDbData_1.2.14
## [83] R6_2.6.1 dbplyr_2.5.0
## [85] evaluate_1.0.3 shiny_1.10.0
## [87] lattice_0.22-7 Biobase_2.68.0
## [89] png_0.1-8 SpatialExperiment_1.18.1
## [91] memoise_2.0.1 httpuv_1.6.16
## [93] bslib_0.9.0 Rcpp_1.0.14
## [95] SparseArray_1.8.0 xfun_0.52
## [97] MatrixGenerics_1.20.0 pkgconfig_2.0.3