Skip to main content

PyPI version Python 3.8+ Downloads Github action

DECONVersation leverages embedding representations from large-scale, LLM-based foundation models to perform deconvolution of bulk RNA-seq data. This takes advantage of the strengths of scFMs in faithfullly representing transcriptomes, learning meaningful biological networks, and minimizing batch effect and noise. Currently, cell embeddings from Geneformer, Cell2Sentence, CellHermes, and scGPT are supported (+PCA and scVI for comparison).

DECONVersation enables end-to-end deconvolution through a set of easy-to-use functions. Embeddings can be extracted from both bulk and single-cell datasets, with single-cell embeddings used to construct robust signature matrices from .h5ad references. Cell type proportions are then estimated via NNLS directly in embedding space. Built-in benchmarking tools evaluate predictions against ground truth using RMSE and Pearson correlation, complemented by visualization utilities for assessing method performance. DECONVersation also supports testing and validation with in-built pseudobulk functions.

---
config:
  theme: 'neutral'
---
flowchart
    subgraph ide1 [standard deconv]
    direction TB 
    A[scRNA: gene x cell] --> B(full profile: gene x type)
    A[scRNA: gene x cell] --> C(markers)
    D[bulkRNA: gene x sample]
    B --> F(signature: marker x type)
    C --> F
    F bb@==> E
    D db@==> E{{deconv res:
    sample x type%}}
    end
    subgraph ide2 [foundation model deconv]
    direction TB
    A1[scRNA: gene x cell] --> B1(full profile: gene x type)
    C2([fa:fa-robot zero-shot model]) --> F1(embeddings x type)
    C2 --> G1
    B1 --> F1(embeddings x type)
    D1[bulkRNA: gene x sample] --> G1(embeddings x sample)
    F1 f1b@==> E1{{deconv res:
    sample x type%}}
    G1 g1b@==> E1
    end
    subgraph ide2 [foundation model deconv]
    direction TB
    A3[scRNA: gene x cell] --> B3(full profile: gene x type)
    A3[scRNA: gene x cell] --> C3([fa:fa-robot fine-tuned model])
    B3 --> F3(embeddings x type)
    C3 --> F3
    D3[bulkRNA: gene x sample] --> G3(embeddings x sample)
    C3 --> G3
    F3 f1b@==> E3{{deconv res:
    sample x type%}}
    G3 g1b@==> E3
    end

bb@{ curve: linear }
db@{ curve: linear }
f1b@{ curve: linear }
g1b@{ curve: linear }
style A fill:green,color:#fff
style A1 fill:green,color:#fff
style A3 fill:green,color:#fff
style D fill:blue,color:#fff
style D1 fill:blue,color:#fff
style D3 fill:blue,color:#fff
style C2 fill:red,color:#fff
style C3 fill:red,color:#fff
style E stroke-width:4px
style E1 stroke-width:4px
style E3 stroke-width:4px

Benchmarking

DECONVersation was benchmarked across 6 real bulk RNA-seq datasets with ground truths, spanning diverse tissue types and experimental conditions, to evaluate deconvolution performance and generalizability.

Summary
Across 6 benchmarked datasets, we calculate overall RMSE and correlation coefficient alongside mean RMSE and correlation averaged across cell types. Fine-tuned Cell2Sentence and Geneformer-based embeddings both demonstrate consistent deconvolution performance across all 6 datasets, with fine-tuned models outperforming their zero-shot counterparts in each case. Though zero-shot performance is already comparable to some common tools in the field, this highlights the benefit of fine-tuning (training models to predict cell type annotations from a single-cell reference). Among the tested tools, only DWLS R pacakge achieves comparable performance to the fine-tuned embedding-based approaches available in DECONVersation.

# Dataset Source Ground Truth Cell Type #
1 PMBC (Hoek) PBMC FACS 5
2 PMBC (Finotello) PBMC FACS 5
3 PMBC (Morandini) PBMC FACS 5
4 Cell Line Mixture (Cobos) Cell Line Mixture Mixture Count 6
5 Pre-Frontal Cortex (Huuki-Myers) DLPFC RNAScope/IF 6
6 Retina (Guo) Retina snRNA 6

Installation

While DECONVersation itself is lightweight and easy to install with pip install DECONVersation, the various single cell foundation models themselves are not. In fact, due to dependency restrictions, they will never be compatible in the same python environment. DECONVersation works around this by detecting and only loading the available model(s). For each scFM model and package, users should consult the correpsonding official installation guides. We also provide conda env yaml files in the envs directory that are reproducibly operational on our hardware (NVIDIA L40S), each corresponding to one of the scFMs + DECONVersation. They can be installed with e.g. conda env create -f deconv_gf.yml.


Quick start

# python
import deconversation
res = deconversation.deconverse(
    bulk_df = "bulk_rna.csv",
    sig_df = "signature_matrix.csv", # or adata = "reference.h5ad", needs one or the other
    model = "path_to/Geneformer-V2-316M",
    temp_output_dir = "temp"
)

# command line
deconverse --help
deconverse --demo --model path_to_model
deconverse --bulk bulk_rna.csv --sig signature_matrix.csv --model path_to_model -o deconv_results.csv
deconverse --bulk bulk_rna.csv --adata reference.h5ad --cell_type_col celltype --model path_to_model

Tutorials


Suggested Reading

  • Geneformer Transfer learning enables predictions in network biology
  • Cell2Sentence Cell2Sentence: Teaching Large Language Models the Language of Biology
  • CellHermes Language may be all omics needs: Harmonizing multimodal data for omics understanding with CellHermes
  • scGPT scGPT: toward building a foundation model for single-cell multi-omics using generative AI

Release files for DECONVersation 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for DECONVersation 0.0.2
File Size Uploaded
deconversation-0.0.2.tar.gz 463.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for DECONVersation 0.0.2
File Interpreter ABI Platform
deconversation-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 933.3 kB

Release files / deconversation-0.0.2.tar.gz

Download URL deconversation-0.0.2.tar.gz
Size 463.0 kB
Tags Source
SHA-256 checksum
How to use checksums
91222b3fc077589c6afb8242b86660946cdc3a8a050042ee7362b38ed04b9eb7
BLAKE2b-256 checksum
How to use checksums
fbcfaf1d7fa9d77966da47fd42b42c3b69ec4bacf8ac5b894c10c65597ebfa1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.15

Release files / deconversation-0.0.2-py3-none-any.whl

Download URL deconversation-0.0.2-py3-none-any.whl
Size 470.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
83ffb2ed033f5ca073a24c014587bfd9b8c9a17e2104e2cf6a22f8c1042093e3
BLAKE2b-256 checksum
How to use checksums
1579c12405901de036be11dbb703ed5ce24308023d40de858bd4b1db6f2532c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.15

Release history Release notifications | RSS feed

0.1.0

2 release files

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page