Repository navigation
CellSpectra 0.2.0 builds on kloetzerka/CellSpectra 0.1.1. The method and tutorials are by the original authors; please cite Klötzer et al., Nature Genetics 2025 (doi:10.1038/s41588-025-02285-0).
Highlights
- Seurat v5: counts are read with
SeuratObject::LayerData(), so v5 (Assay5) and v4 (Assay) objects both work without conversion. Split v5 layers are joined automatically. - Parallel runs with a progress bar:
run_spectra()andcreate_references()take a BiocParallel backend throughBPPARAM, for exampleMulticoreParam(workers = 8, progressbar = TRUE). Results do not depend on the backend or the number of workers. - Reproducible, independent sampling: each (cell type, query, reference sample) gets its own L'Ecuyer-CMRG stream derived from
seed. The caller's random number state is left unchanged. - Faster: a closed-form regression replaces
lm(), and pseudobulking and normalization are vectorized.
| Step | Data | 0.1.1 | 0.2.0 (1 core) |
|---|---|---|---|
run_spectra |
ifnb tutorial, 3 cell types × 2659 GO sets | 66.4 s | 7.2 s (4.2 s with 8 workers) |
create_references |
ifnb tutorial, 10 replicates | 25.1 s | 0.34 s |
Parallel backends help when there are many query samples. With one query sample per cell type, as in the tutorials, serial is fastest.
Results
-
For the same
datH/datD,run_spectra()agrees with 0.1.1 within 1e-10 for R² and 1e-8 for log10 p-values. The deterministic parts ofcreate_references()(sample selection, query pseudobulk, normalization) are bit-identical on the same platform. This is checked by about 1400 tests against a verbatim copy of 0.1.1 and against the tutorial outputs. -
Changed on purpose:
- Reference pseudobulks (
datH) are now sampled independently for each reference sample. 0.1.1 reused one random index sequence for all of them. So re-running a tutorial gives somewhat different R² and p-values than the committed outputs, by about as much as changing the seed did in 0.1.1. - Gene sets whose reference is fitted exactly get an NA p-value and a warning; 0.1.1 returned NaN or round-off noise.
samples_of_interest.rdsis now saved per cell type.loo_coordination_from_matrix()keeps sample names aligned.- Single surviving gene sets are no longer collapsed to a vector.
- New option:
chisq_df_offset.
See "What's new in 0.2.0" in the README for the full list.
- Reference pseudobulks (
Install
# from the attached source package
install.packages("CellSpectra_0.2.0.tar.gz", repos = NULL, type = "source")
# or
remotes::install_github("jarxunlai/CellSpectra@v0.2.0")Requires R ≥ 4.1, SeuratObject ≥ 5.0 and BiocParallel (Bioconductor). The attached source package does not contain the tutorial data; the tutorials are in the repository under tutorials/.
SHA-256 of CellSpectra_0.2.0.tar.gz: 300b537bd2d222014537121660f989c01ea9f6835528cdfb9cf32789fae9df62