Skip to main content

cellsweep

Sweep out noisy counts from single-cell RNA-seq data with CellSweep!

Documentation: https://cellsweep.readthedocs.io

alt text

Install

Basic use

pip install cellsweep

To run notebooks:

pip install cellsweep[analysis]

To remake figures from the paper:

git clone https://github.com/pachterlab/cellsweep.git
cd cellsweep
conda env create -f environment.yml
pip install cellsweep[analysis]==0.1.1

Quickstart

CellSweep has a single function denoise that takes a raw count matrix in an AnnData object and produces a denoised count matrix in another AnnData object. See a simple, fully worked example in the notebooks/intro.ipynb Jupyter Notebook.

Python API

import cellsweep
adata_cellsweep = cellsweep.denoise(adata_raw_path, adata_out=adata_cellsweep_path)  # see below for expected structure

# for help
help(cellsweep.denoise)

Command line interface

cellsweep denoise -o adata_cellsweep.h5ad adata_raw.h5ad  # see below for expected structure

# for help
cellsweep denoise --help

There are many utility functions in the cellsweep.utils module for data processing, plotting, and analysis. See examples in our Jupyter Notebooks.

Anndata object

The input Anndata object/h5ad file should have the following structure:

  • adata.X : cell count matrix (cells x genes)
  • adata.obs:
    • adata.obs[celltype_key]: a column indicating the cell type of each cell. Labels on barcodes where adata.obs[is_empty_key] is True are ignored.
    • adata.obs[is_empty_key] (optional): a boolean column indicating whether each cell is an empty droplet. If not provided, barcodes whose adata.obs[celltype_key] equals empty_label (default "Empty Droplet") are marked empty. If no barcode has that label, CellSweep will infer empty droplets using the empty_droplet_method argument.

If a column is provided in any part of adata, then it will take priority over default internal calculations. For example, if adata.obs[is_empty_key] is provided, then CellSweep will not infer empty droplets and will use the provided column instead.

Additional column inputs can be provided in advanced use cases. See the documentation for details.

CellSweep returns a denoised Anndata object (and writes it to adata_out, if provided) with an updated adata.X and the following added fields. By default the empty droplets are removed from the output so it only contains the real cells; pass keep_empties=True (CLI: --keep-empties) to keep every input barcode.

  • adata.layers["raw"] : raw count matrix
  • adata.obs:
    • adata.obs["alpha_hat"] : final optimized alpha values
    • adata.obs["contamination_fraction"] : total contamination fraction per cell, (1 - beta_hat) * alpha_hat + beta_hat
    • adata.obs["z_hat"] : final cell-type assignments
  • adata.var:
    • adata.var["ambient_hat"] : final optimized ambient distribution
    • adata.var["bulk_hat"] : global noise distribution
  • adata.uns:
    • adata.uns["p_hat"] : final optimized matrix of cell-type profiles (K x G)
    • adata.uns["beta_hat"] : final optimized beta
    • adata.uns["loglike"] : final log-likelihood (this is the relative log-likelihood, not the complete log-likelihood)

Multiple samples

CellSweep fits a single ambient profile, global contamination profile and global contamination fraction per run. Ambient contamination is specific to each sample, so run CellSweep separately on each sequencing sample (e.g. each 10x channel or plate), with that sample's own non-cellular barcodes, rather than on a matrix that combines several samples, batches or plates.

Tutorials

We have several Jupyter Notebooks demonstrating the use of CellSweep for denoising count matrices and analyzing the results. See the notebooks folder in the repository.

Metadata

Release files for cellsweep 1.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 cellsweep 1.0.2
File Size Uploaded Provenance Actions
cellsweep-1.0.2.tar.gz 80.2 kB Without provenance Details for cellsweep-1.0.2.tar.gz

Built distribution (wheel)

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

Total release size: 157.8 kB

Release files / cellsweep-1.0.2.tar.gz

Download URL cellsweep-1.0.2.tar.gz
Size 80.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7604cad392af15b533c3bb0b6ddcd4a0aaa9b838c2ce5424897fb59cdd7c6b1e
BLAKE2b-256 checksum
How to use checksums
35947225631748aca00ec36d66bba2793beb3cddd0ac06c552f6a4c2d4bc9257
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Release files / cellsweep-1.0.2-py3-none-any.whl

Download URL cellsweep-1.0.2-py3-none-any.whl
Size 77.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a5d2b85ba896eabda770bfde99bbecd93706a4f35c419905e3081c7f24fe5a3
BLAKE2b-256 checksum
How to use checksums
f0833ae7281ea2f494eef699d24dfcc591a112aa947a61e5197d321c82a6f612
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Security for cellsweep 1.0.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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