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 your pyproject.toml file with uv

uv add pdex

Summary

This is a python package for performing parallel differential expression using the Wilcoxon rank-sum test.

It is optimized for very large datasets and very large numbers of perturbations.

It makes use of shared memory to parallelize the computation to a high number of threads and minimizes the IPC between processes to reduce overhead.

Usage

import anndata as ad
import numpy as np
import pandas as pd

from pdex import parallel_differential_expression

PERT_COL = "perturbation"
CONTROL_VAR = "control"

N_CELLS = 1000
N_GENES = 100
N_PERTS = 10
MAX_UMI = 1e6


def build_random_anndata(
    n_cells: int = N_CELLS,
    n_genes: int = N_GENES,
    n_perts: int = N_PERTS,
    pert_col: str = PERT_COL,
    control_var: str = CONTROL_VAR,
) -> ad.AnnData:
    """Sample a random AnnData object."""
    return ad.AnnData(
        X=np.random.randint(0, MAX_UMI, size=(n_cells, n_genes)),
        obs=pd.DataFrame(
            {
                pert_col: np.random.choice(
                    [f"pert_{i}" for i in range(n_perts)] + [control_var],
                    size=n_cells,
                    replace=True,
                ),
            }
        ),
    )


def main():
    adata = build_random_anndata()
    results = parallel_differential_expression(
        adata,
        reference=CONTROL_VAR,
        groupby_key=PERT_COL,
    )
    assert results.shape[0] == N_GENES * N_PERTS

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.1.1.tar.gz (30.3 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.1.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pdex-0.1.1.tar.gz
  • Upload date:
  • Size: 30.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.3

File hashes

Hashes for pdex-0.1.1.tar.gz
Algorithm Hash digest
SHA256 70800115ea3d3e87fbdf8fe12b5b33e1ec3fd1a3a7d612bac7bb9d259e440e1d
MD5 c98c5a4ed01fdf5828d91c304d46e626
BLAKE2b-256 18c0f5c326da444035db3f369e9bb52d4edaa1974e7035637a2bcf0cc96f7b25

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pdex-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.3

File hashes

Hashes for pdex-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3a9b7e22806d772b7348ddd7ed57b9648c989dba6067c0b7f4de7db1db65b96c
MD5 323993794182441eb855bdfd68729fc2
BLAKE2b-256 e60415582d4d5606724451cec85a5ae53796ea4b8b7d5c236f3d470255711903

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