Single-cell data visualization using kernel gene-weighted density estimation
Project description
pyNebulosa
Single-cell data visualization using kernel gene-weighted density estimation.
pyNebulosa is a Python package (ported from the original R/Bioconductor package) that recovers gene expression signals lost to dropout in single-cell data by using weighted kernel density estimation on low-dimensional embeddings. It integrates natively with scanpy and AnnData.
Motivation
Standard feature plots in single-cell analysis are plagued by sparsity — many cells show zero expression even for marker genes, making it hard to see biological signal. pyNebulosa addresses this by computing a gene-weighted kernel density estimate (KDE) on the embedding space, effectively smoothing expression over neighbouring cells.
| Standard feature plot | pyNebulosa density plot |
|---|---|
| Sparse, hard to interpret | Smooth, recovers signal |
R vs Python
pyNebulosa was originally an R/Bioconductor package (Nebulosa) for Seurat and SingleCellExperiment objects. This Python port provides an equivalent API for the scanpy/AnnData ecosystem, producing identical density estimates.
| R (Seurat) | Python (scanpy) |
|---|---|
library(Nebulosa)
library(Seurat)
pbmc <- pbmc3k.SeuratData::pbmc3k.final
plot_density(pbmc, "NKG7")
plot_density(pbmc, c("NKG7", "GNLY"),
joint = TRUE)
|
import scanpy as sc
import pynebulosa as nb
adata = sc.datasets.pbmc3k_processed()
nb.plot_density(adata, "NKG7")
nb.plot_density(adata, ["NKG7", "GNLY"],
joint=True)
|
Installation
pip install pynebulosa
With scanpy (recommended):
pip install "pynebulosa[scanpy]"
Quick start
import scanpy as sc
import pynebulosa as nb
adata = sc.datasets.pbmc3k_processed()
# Single gene density plot
nb.plot_density(adata, "NKG7")
Multi-marker panels
Visualize multiple markers at once to identify cell populations:
nb.plot_density(adata, ["MS4A1", "NKG7", "CST3", "PPBP"], ncols=4)
Joint density
Find co-expressing cell populations by computing the product of individual gene densities:
nb.plot_density(adata, ["NKG7", "GNLY"], joint=True)
API
| Function | Purpose |
|---|---|
nb.plot_density(adata, features) |
Main visualization function |
nb.calculate_density(weights, coords) |
Compute density values programmatically |
nb.wkde2d(x, y, w) |
Low-level weighted 2D KDE |
Key parameters
| Parameter | Description | Default |
|---|---|---|
joint |
Compute joint density across features | False |
reduction |
Embedding key in adata.obsm |
Auto-detect (X_umap) |
method |
"wkde" (custom) or "ks" (scipy) |
"wkde" |
adjust |
Bandwidth adjustment factor | 1.0 |
cmap |
Matplotlib colormap | "viridis" |
layer |
Expression layer | adata.X |
How it differs from similar tools
| Tool | Approach | Use case |
|---|---|---|
scanpy.tl.embedding_density |
Unweighted KDE per category | Where are cells of group X? |
| pyUCell | Rank-based scoring + KNN smoothing | Gene signature scoring |
| pyNebulosa | Gene-weighted KDE on embeddings | Recovering dropout signal |
Documentation
- Full documentation (ReadTheDocs)
- Tutorial notebook (PBMC 3K walkthrough)
Citation
If you use pyNebulosa, please cite:
Alquicira-Hernandez, J., Powell, J.E. Nebulosa recovers single-cell gene expression signals by kernel density estimation. Bioinformatics, 37(16), 2485-2487, 2021. doi:10.1093/bioinformatics/btab003
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pynebulosa-0.1.0.tar.gz.
File metadata
- Download URL: pynebulosa-0.1.0.tar.gz
- Upload date:
- Size: 3.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
847745de9a7aa8edc505ee488506d753111937dc9f691541e688b6e4a39565c6
|
|
| MD5 |
331aef1ad370f532ed3984ed434767d5
|
|
| BLAKE2b-256 |
5638dd289c5d1e3c1894779df30a5aed1afde6ed9ff1924b7a2ca74142790b48
|
Provenance
The following attestation bundles were made for pynebulosa-0.1.0.tar.gz:
Publisher:
publish.yml on mdmanurung/pyNebulosa
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pynebulosa-0.1.0.tar.gz -
Subject digest:
847745de9a7aa8edc505ee488506d753111937dc9f691541e688b6e4a39565c6 - Sigstore transparency entry: 1243589395
- Sigstore integration time:
-
Permalink:
mdmanurung/pyNebulosa@9dfee8ec48ee2b0d0819e1f92c8372e0b0443910 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mdmanurung
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9dfee8ec48ee2b0d0819e1f92c8372e0b0443910 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pynebulosa-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pynebulosa-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fba2192ff0acb1f108946c4c9baffb0268e0b70347a90399e3e540a947cab5a7
|
|
| MD5 |
d340ea6fcc54276731de3b77a16b8e94
|
|
| BLAKE2b-256 |
ba29492c801d7ea67f51f06fd72685ad166805ac80c251b5b0bd6cbac6d6dc05
|
Provenance
The following attestation bundles were made for pynebulosa-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on mdmanurung/pyNebulosa
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pynebulosa-0.1.0-py3-none-any.whl -
Subject digest:
fba2192ff0acb1f108946c4c9baffb0268e0b70347a90399e3e540a947cab5a7 - Sigstore transparency entry: 1243589398
- Sigstore integration time:
-
Permalink:
mdmanurung/pyNebulosa@9dfee8ec48ee2b0d0819e1f92c8372e0b0443910 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mdmanurung
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9dfee8ec48ee2b0d0819e1f92c8372e0b0443910 -
Trigger Event:
release
-
Statement type: