Skip to main content

PerturbResidual 0.1.0

PerturbResidual converts matched control, single-perturbation, and measured double-perturbation means into auditable pair-level functional-coupling scores. Score construction does not read STRING, KEGG, dataset names, or other functional labels.

The scientific object is the higher-order residual

R_AB = d_AB - d_A - d_B

where each effect is measured relative to the same control. PerturbResidual then separates recurrent source means from gene-scale heteroscedasticity and chooses a frozen nuisance-control branch using only the measured panel's median endpoint degree.

Scientific scope

PerturbResidual:

  • ranks combinations that have already been measured;
  • tests whether higher-order residual structure carries functional coupling;
  • reports whether its selected branch contains a transductive component.

It is not a directed-edge estimator, a full-transcriptome response predictor, or a method for predicting arbitrary unmeasured combinations.

Frozen algorithm

For each measured pair, the software constructs:

  1. the original pair-specific top-10 residual score;
  2. a strict leave-one-pair-out source-mean correction;
  3. an independently estimated gene-scale correction;
  4. a sparse OPG-A score;
  5. when required, a strict-LOPO spectral score and a bounded transductive PC5 tail.

The label-blind router is:

median endpoint degree < 5   -> sparse OPG-A
median endpoint degree >= 5  -> dense spectral-tail

The strict-LOPO description applies to the spectral component. The PC5 tail is unsupervised but transductive because its basis contains the scored pair; this fact is written to every dense-run audit. Dense scoring requires at least ten genes after the frozen HVG and perturbation-identity masks; smaller spaces stop with an explicit error instead of silently changing the low-rank formula.

Install the release artifact

PerturbResidual 0.1.0 supports Python 3.12. Compatibility will be broadened only after the corresponding runtime CI gates pass.

python -m pip install perturbresidual-0.1.0-py3-none-any.whl

After an eventual PyPI publication, the intended command is:

python -m pip install perturbresidual==0.1.0

The present release bundle prepares the wheel and source distribution but does not claim that either has already been uploaded to PyPI.

Python API

from perturbresidual import PerturbResidual

model = PerturbResidual(route="auto")
result = model.fit_score(
    control=control,          # shape: (genes,)
    singles=singles,          # dict[str, array of shape (genes,)]
    doubles=double_means,     # shape: (pairs, genes)
    pairs=pairs,              # list[tuple[str, str]]
    gene_names=gene_names,
)

scores = result.scores
audit = result.audit
frame = result.to_dataframe()

route="sparse" and route="dense" are available for diagnostics. Scientific use should normally retain route="auto". Changing route, hvg_quantile, top_k, or source_ridge marks the output NONCANONICAL_VARIANT, records the exact parameter differences, and removes the frozen-paper evidence claim. Set compute_all_components=True to compute dense diagnostics without changing the selected score or canonical status.

Command line

perturbresidual score \
  --control control.csv \
  --singles singles.csv \
  --doubles doubles.csv \
  --output results

Input files use a wide format:

  • control.csv: exactly one row; every column is a gene;
  • singles.csv: first column perturbation, followed by the same gene columns;
  • doubles.csv: first columns source_a,source_b, followed by the same genes.

Perturbation names and pair endpoints must be nonempty. Duplicate single names are rejected rather than silently overwritten.

The output directory contains:

  • pair_scores.csv;
  • route_audit.json;
  • nuisance_diagnostics.csv;
  • run_config.json.

Reproducibility

Run fast tests from the source tree:

PYTHONPATH=src python -m unittest discover -s tests -v

Run the frozen Norman/Wessels regression when PerturbResidual_repo_v2 is available alongside the release:

PYTHONPATH=src python validation/run_frozen_regression.py \
  --repo-root ../PerturbResidual_repo_v2 \
  --out-dir validation/results

The regression finalizes both label-blind score vectors before evaluating the four STRING/KEGG metrics per panel.

Evidence boundary

The paper reports the strongest point estimates in the symmetrically evaluated external comparator fields across eight Norman/Wessels metrics. Both panels contributed to method development, and seven of eight source-endpoint intervals cross zero. This package therefore supports reproducibility and reuse; it does not turn the developmental result into confirmatory two-panel SOTA.

License

MIT.

Maintainer: Ziran Peng.

Download files

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

Source Distribution

perturbresidual-0.1.0.tar.gz (24.8 kB view details)

Uploaded Source

Built Distribution

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

perturbresidual-0.1.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file perturbresidual-0.1.0.tar.gz.

File metadata

  • Download URL: perturbresidual-0.1.0.tar.gz
  • Upload date:
  • Size: 24.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.2

File hashes

Hashes for perturbresidual-0.1.0.tar.gz
Algorithm Hash digest
SHA256 791f61e1c8f1d5f4b3dd0df131af1bb235ef864b801958f0d1ae8c715e877301
MD5 f4b58301002ed2d0692082a74c812649
BLAKE2b-256 24d40a43df1c3324507fefa143e40c59488321238e06fc4fa9eb0ace28dc9a10

See more details on using hashes here.

File details

Details for the file perturbresidual-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for perturbresidual-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc0a586657e4ebc850c5bb39cdda5fea88afa6ac9ebc408e5e65d67e92d5926a
MD5 18638c87bca69ab64748b775302ac22b
BLAKE2b-256 c32393ec2c52181a417ac72c8e85d5667ab8aa25251590448be94337547a3399

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 Sentry Error logging StatusPage Status page