Skip to main content

pyNebulosa

PyPI Documentation License: MIT

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

Standard vs Density

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 vs Python comparison

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)

Multi-marker density

Joint density

Find co-expressing cell populations by computing the product of individual gene densities:

nb.plot_density(adata, ["NKG7", "GNLY"], joint=True)

Joint density

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

Contributing

We welcome contributions of all kinds! If you'd like to contribute to pyNebulosa, please:

  1. Fork the repository and create a feature branch.
  2. Make your changes and add tests where appropriate.
  3. Ensure all tests pass with pytest tests/ -v.
  4. Submit a pull request describing your changes.

Please report bugs and feature requests on the issue tracker.

License

pyNebulosa is licensed under the MIT License.

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

Metadata

Release files for pynebulosa 0.1.1

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

Source distribution (sdist)

Source distribution for pynebulosa 0.1.1
File Size Uploaded Provenance Actions
pynebulosa-0.1.1.tar.gz 3.7 MB With provenance Details for pynebulosa-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pynebulosa 0.1.1
File Interpreter ABI Platform Actions
pynebulosa-0.1.1-py3-none-any.whl Python 3 none any Details for pynebulosa-0.1.1-py3-none-any.whl

Total release size: 3.7 MB

Release files / pynebulosa-0.1.1.tar.gz

Download URL pynebulosa-0.1.1.tar.gz
Size 3.7 MB
Tags Source
SHA-256 checksum
How to use checksums
7bc86ab5cea69e9af724676423ed136d5cd425264f8e340fa0cdbc0887a5e61a
BLAKE2b-256 checksum
How to use checksums
33cb56ff1e4d510e1ecd77a3f906001498ebc774bd21170611318ccf73f2d671
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 7, 2026.

Transparency log

Release files / pynebulosa-0.1.1-py3-none-any.whl

Download URL pynebulosa-0.1.1-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf4ffba215a3531ba70ff3952fd26684cf67fc4fd7e3d354fa23e4640dd0454c
BLAKE2b-256 checksum
How to use checksums
a23a9647f447137a168e2759c82cb83852f080ae8bff37088c4ba7e9e312007b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 7, 2026.

Transparency log

Security for pynebulosa 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pynebulosa-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

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