Data checks

Inspect count percentages, variable genes and doublet scores using Scanpy’s PBMC3k data: 2,700 cells and 32,738 genes. Scanpy downloads it on first use.

Install or update with pip install --upgrade 'genome-spy-python[scanpy]'. Choose that environment as your Jupyter kernel.

Download notebook

import scanpy as sc
import genome_spy.integrations.scanpy as gsc
counts = sc.datasets.pbmc3k()

Check the most abundant genes

Each box shows a gene’s share of the counts across cells. Hover for values and cell IDs; scroll to zoom the percentage axis.

highest = gsc.pl.highest_expr_genes(
    counts,
    n_top=20,
    width=400,
    height=380,
    zoom=True,
    show=False,
)
highest

Prepare variable-gene statistics

Use Scanpy to filter rarely detected genes, normalize counts and calculate gene variation. A copy keeps the original counts available for the other plots.

hvg = counts.copy()
sc.pp.filter_genes(hvg, min_cells=3)
sc.pp.normalize_total(hvg, target_sum=10_000)
sc.pp.log1p(hvg)
sc.pp.highly_variable_genes(hvg)

Explore variable genes

Blue points exceed the preview score cutoff. Move the slider to change it; Scanpy’s saved selection stays unchanged.

variable = gsc.pl.highly_variable_genes(
    hvg,
    threshold_slider=True,
    zoom=True,
    width=250,
    height=250,
    show=False,
)
variable

Calculate doublet scores

Run Scrublet in Scanpy with a fixed seed. The example starts at a threshold of 0.25; inspect and choose a threshold for your own analysis.

doublets = counts.copy()
sc.pp.scrublet(
    doublets,
    threshold=0.25,
    random_state=0,
    use_approx_neighbors=False,
    verbose=False,
)

Explore doublet scores

Move the slider to preview a threshold. Blue bars lie wholly above it; saved doublet calls stay unchanged.

scores = gsc.pl.scrublet_score_distribution(
    doublets,
    threshold_slider=True,
    zoom=True,
    width=260,
    height=230,
    show=False,
)
scores

Data use and provenance

PBMC3k contains UMI counts from 10x Genomics, loaded by Scanpy. Credit 10x Genomics and Scanpy’s contributors. Source data: CC BY 4.0. Scanpy performs the preparation above; GenomeSpy plots those results. The web page loads prepared inputs. Running the notebook calculates them in Python.