osp — one-sample-pipeline
Single-sample scRNA-seq QC → clustering/DEG → self-contained HTML report, with an optional Claude-agent step that proposes cell-type annotations and QC actions from the report and the cluster marker tables.
Strictly single-sample by design — one sample per run, no cross-sample batch integration. Loop over samples in an outer driver (e.g. a Slurm job array); treat integration as a separate downstream step.
Install
pip install osp-sc # PyPI name; `import osp` / `python -m osp`
# with the optional annotation agent (needs claude-agent-sdk + claude CLI credentials):
pip install "osp-sc[agent]" # + claude-agent-sdk for --annotate
Quick usage
from osp import run_one_sample_pipeline, generate_report
ad_fo = adata[adata.obs["sample"] == "FO"]
run_one_sample_pipeline(ad_fo, sample_label="FO", outdir="osp_out/FO")
generate_report("osp_out/FO")
Stepwise calls, if you want more control:
from osp import qc_one_sample, cluster_and_deg, deg_two_groups
qc_one_sample— QC only (flags cells, drops nothing)cluster_and_deg— clustering/DEG/PAGA on QC-passed datadeg_two_groups— Wilcoxon DEG between any two cell groups, for ad hoc comparisons outside the main pipeline
Command line
python -m osp data.h5ad --sample FO --outdir osp_out # full pipeline + report
python -m osp data.h5ad --sample FO --outdir osp_out --annotate --model claude-sonnet-5
python -m osp.report osp_out # rebuild the report only
See examples/run_one_sample.py for a driver that loads a large h5ad in
backed mode and pulls out one sample (for per-sample Slurm array tasks), and
examples/submit_array.sbatch for the job-array template.
Conventions
- Raw counts convention: if
adata.layers["counts"]exists,Xis swapped for it at the start of both the QC and clustering stages — this makes the pipeline robust to inputs whereXalready holds normalized values with raw counts kept in a layer (common in released h5ad files). - QC is flag-only:
qc_one_samplenever drops cells;low_qualityis a column, filtering is the caller's decision. - DecontX degeneracy guard: DecontX's own UMAP+DBSCAN init can collapse on
samples where the dominant cell lineage's transcriptome resembles the
ambient RNA pool (all contamination pinned near 1, or the init shattering
into 100+ tiny clusters). When detected,
qc_one_sampleautomatically re-runs DecontX with an explicit coarse-leiden clustering; checksummary["decontx_z_source"]("internal"vs"leiden_fallback") and the Ambient Contamination section of the report. - MAD-outlier assumption: the adaptive per-sample QC thresholds (
nmadsMADs around the median) assume a roughly regular within-sample distribution. On samples with unusually shallow depth or heavy ambient contamination this assumption can break — a naturally low-complexity but perfectly healthy population (e.g. neutrophils, dominated by a handful of granule genes) can get itspct_counts_in_top_20_genesMAD range squeezed and be flagged en masse. The QC report's "MAD keep-ranges" table exists specifically so this is visible instead of silent — a suspiciously tight range, or one metric dominating the fail counts, is a signal to check which cell types are being flagged before trusting the calls.
Sherlock / HPC notes
- Never run the pipeline on a login node — submit through Slurm or use an interactive allocation.
- For large h5ad files, load in backed mode and subset to one sample before
bringing it into memory (see
examples/run_one_sample.py). osp.annotateis intentionally not imported byosp/__init__.py— it depends on the optionalclaude-agent-sdk; import it explicitly (from osp.annotate import propose_annotation) only when you need it.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file osp_sc-0.1.0.tar.gz.
File metadata
- Download URL: osp_sc-0.1.0.tar.gz
- Upload date:
- Size: 51.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5af251bc85fb489c8f1fa8ccfad4d6ab2d284e77ed6737405b1edce1e4713339
|
|
| MD5 |
d4caf014a7ca8809df28af7f78899a0d
|
|
| BLAKE2b-256 |
7c217b1a13005411bb67571cbe0670049e88f585cf32c0ccf8929f12183e6777
|
File details
Details for the file osp_sc-0.1.0-py3-none-any.whl.
File metadata
- Download URL: osp_sc-0.1.0-py3-none-any.whl
- Upload date:
- Size: 55.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c01a2753869d573bb45dbc32ee8c54adbcf23142f5f5b2525c056435a612f6e
|
|
| MD5 |
9aea2a1d5724b653350caddfb7bf2d7c
|
|
| BLAKE2b-256 |
52c2af81b2080a317d12c05f354fc0dd742e486d6aa3bcc4d4dec48bcca135a4
|