Skip to main content

Parallel differential expression for single-cell perturbation sequencing

Project description

pdex

Parallel differential expression for single-cell perturbation sequencing.

Installation

# add to pyproject.toml
uv add pdex

# add to env
uv pip install pdex

Overview

pdex computes per-gene differential expression statistics between perturbation groups in single-cell data using Mann-Whitney U tests with FDR correction. It was originally designed for CRISPR screen and perturbation sequencing datasets with many groups and large cell counts.

It supports dense and sparse (CSR) expression matrices, and uses numba-mwu for Numba-accelerated Mann-Whitney U computation.

Modes

Mode Description
"ref" Each group vs a single reference group (default: "non-targeting")
"all" Each group vs all remaining cells (1-vs-rest)
"on_target" Each group vs the reference at its single target gene only

Usage

Reference mode (default)

import anndata as ad
from pdex import pdex

adata = ad.read_h5ad("screen.h5ad")

results = pdex(
    adata,
    groupby="guide",
    mode="ref",
    is_log1p=False,
)

1-vs-rest mode

results = pdex(
    adata,
    groupby="guide",
    mode="all",
    is_log1p=False,
)

On-target mode

Requires a column in adata.obs mapping each group to its target gene:

results = pdex(
    adata,
    groupby="guide",
    mode="on_target",
    gene_col="target_gene",
    is_log1p=False,
)

Parameters

Parameter Type Default Description
adata AnnData required Annotated data matrix (dense or sparse CSR)
groupby str required Column in adata.obs defining groups
mode str "ref" Comparison mode: "ref", "all", or "on_target"
threads int 0 Numba thread count (0 = all CPUs)
is_log1p bool | None None Whether data is log1p-transformed. Auto-detected if None
geometric_mean bool True Use geometric mean for pseudobulk (vs arithmetic)
as_pandas bool False Return a pandas DataFrame instead of Polars
reference str "non-targeting" Reference group name (modes: ref, on_target)
gene_col str Column mapping groups to target genes (mode: on_target)

Output

Returns a Polars DataFrame (or pandas if as_pandas=True) with one row per (group, gene) pair:

Column Description
target Perturbation group name
feature Gene name
target_mean Pseudobulk mean for the target group (count space)
ref_mean Pseudobulk mean for the reference (count space)
target_membership Number of cells in the target group
ref_membership Number of cells in the reference
fold_change Deprecated alias for log2_fold_change (identical values). Will be removed in pdex 0.3.0.
log2_fold_change log2(target_mean / ref_mean). Genes unexpressed in both groups (0/0) report 0.0, not NaN.
percent_change (target_mean - ref_mean) / ref_mean. Genes unexpressed in both groups (0/0) report 0.0, not NaN.
p_value Mann-Whitney U p-value
statistic Mann-Whitney U statistic
fdr FDR-corrected p-value (per-group, across genes). For on_target mode, this is applied across all groups.

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

pdex-0.2.4.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

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

pdex-0.2.4-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file pdex-0.2.4.tar.gz.

File metadata

  • Download URL: pdex-0.2.4.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pdex-0.2.4.tar.gz
Algorithm Hash digest
SHA256 e103783c3f47f02f9d7ad14a27d4ee371a5b5a0315f9a14428a401bd3f03a419
MD5 7372c875558d0a453cfb70d085677b84
BLAKE2b-256 31b07af8bfb3e78bc8d6a9af29409b048934071dc65538a1c728d9ced1875ecd

See more details on using hashes here.

File details

Details for the file pdex-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: pdex-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pdex-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bb0ab992700ed0821f5a7e33d4acde71cbf8b5eece9942bf780385d5e75128ac
MD5 06fd7c4bb4e572a9a0091d2426139319
BLAKE2b-256 c81074cc7dd8ba9420d36c264d714d8ff2a1115463062d7f3acf216a1c9daa81

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