Skip to main content

Estimate and correct row/column multiplicative stripe artifacts in high-resolution spatial transcriptomics count data.

Project description

Destriper

Destriper corrects striping artefacts in VisiumHD spatial transcriptomics count data.

Under the hood, the method fits a negative binomial model to each nucleic bin $ij$ total counts $k_{ij}$: $k_{ij} \sim NB(\text{mean} = c_p h_i w_j, \text{dispersion} = \theta)$, where $h_i$, $w_j$ are row/column stripe factors, and $c_p$ a per-nucleus concentration [counts/bin]. The fitted stripe factors are then applied to all bins to produce destriped counts.

Method overview

  • The underlying mean-variance relationship reads $\text{var} = \mu + \theta\mu^2$.
  • Fitted stripe factors $h_i$ and $w_j$ equal 1 on average.

Cite

To learn more about the method, or to cite, use:

Paola Malsot, Malte Londschien, Valentina Boeva, Gunnar Rätsch, Striping artifact removal in VisiumHD data through nuclear counts modeling, Bioinformatics, Volume 42, Issue Supplement_1, July 2026, btag306, https://doi.org/10.1093/bioinformatics/btag306

Install

pip install destriper            # low-level interface
pip install "destriper[anndata]" # + AnnData interface

Tutorial

See the tutorial notebook for an example on Visium HD mouse brain data.

Usage

Low-level interface

import destriper as ds

# nucleus bins only; counts are per-bin TOTAL counts
result = ds.fit(
    counts,          # 1-D int array
    row_indices,     # 1-D int array (array-grid row)
    column_indices,  # 1-D int array (array-grid col)
    nucl_labels,     # 1-D array of nucleus ids (non-null)
    cv="spatial",    # "spatial" | "default" | int (KFold) | per-bin group array
    max_iter_theta=5,
    max_iter=100_000,
)

result.row_factors        # pandas Series h_i
result.col_factors        # pandas Series w_j
result.nucl_concentration # pandas Series c_p
result.dispersion         # fitted NB theta

# apply to ALL bins (nucleus bins -> quantile matching, others -> division)
corrected_totals = ds.destripe_tot_counts(
    tot_counts, row_indices, column_indices, nucl_labels, result
)

# rescale the sparse count matrix to the corrected totals
corrected_matrix, achieved_totals = ds.rescale(count_matrix, corrected_totals)

achieved_totals can differ from corrected_totals on originally-empty bins: a zero row cannot be rescaled to a positive target, so it stays zero. Both are returned so the discrepancy is explicit.

Anndata interface

import destriper as ds

result = ds.fit_adata(
    adata,
    nucl_key="nucleus_id",
    count_key="total_counts",   # None -> compute from adata.X
    row_key="array_row",
    col_key="array_col",
)

ds.destripe_adata(adata, result, source_layer=None, target_layer="destriped")
# writes adata.layers["destriped"], adata.obs["ds_destripe_factor"], adata.obs["ds_corrected_counts"]
# and adata.uns["destriper"]["result"]

Fitting uses only bins with a non-null nucl_key; unlabelled (cytoplasm) bins are ignored during fitting and corrected by division at destriping time.

Notes

  • glum==3.1.2 and tabmat==4.2.1 are pinned exactly — the coordinate-descent solver relies on private internals of those versions.
  • This package is derived from the destriping-GLM repo.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

destriper-0.1.1.tar.gz (4.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

destriper-0.1.1-py3-none-any.whl (50.0 kB view details)

Uploaded Python 3

File details

Details for the file destriper-0.1.1.tar.gz.

File metadata

  • Download URL: destriper-0.1.1.tar.gz
  • Upload date:
  • Size: 4.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for destriper-0.1.1.tar.gz
Algorithm Hash digest
SHA256 dac54b38e93fcf9a80d90559f09a15a1003c53e84e7d0c28f87d1ddefbf2104d
MD5 c92f1c6d1e4b2e4446fbb2448ca0c40f
BLAKE2b-256 1c62109a3134b20f726a6c7552efa4e7da2754648c7b5cf8828a4790aeb17d2b

See more details on using hashes here.

File details

Details for the file destriper-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: destriper-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 50.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for destriper-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1a3bf7ca669f3de6cb00820ccb4c32929455cf9376fbe23b4f781c3c6f81296c
MD5 e93bdf2abc41fd0c339c72a1623d5287
BLAKE2b-256 79eb61e07e7889d03ecf7d763ba39c698b4a5fcb4bc927d9e5e37242e93b8742

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page