Skip to main content

Python native implementation of selected PhosR style workflows for phosphoproteomics.

Project description

PhosPy

PhosPy is a focused Python library for selected phosphoproteomics workflows inspired by PhosR.

It is designed for users who want to:

  • preprocess total and phospho tables
  • analyse kinase activity from an existing predMat
  • run the native Python kinase workflow

PhosPy is intentionally narrow. It is not a full PhosR replacement.

Install

PhosPy supports Python 3.10 and newer.

pip install phospy

For parquet output:

pip install "phospy[parquet]"

The examples below use repository paths such as examples/data/.... If you installed from PyPI, use your own local file paths.

Choose the Right Entry Point

PhosphoDataset

Use PhosphoDataset when you want validated total and phospho inputs plus the standard preprocessing flow.

from phospy import PhosphoDataset
from phospy.writers import CoreOutputWriter

dataset = PhosphoDataset.from_files(
    "examples/data/total.tsv",
    "examples/data/phospho.tsv",
    phospho_encoding="utf-16le",
)
core = dataset.preprocessing.run(max_unmatched_fraction=0.1)

CoreOutputWriter().write(core, outdir="examples/output", format="csv")

site_matrix = core.site_matrix.matrix
corrected = core.phospho_corrected

KinaseActivityAnalyzer

Use KinaseActivityAnalyzer when you already have a phosphosite matrix and a predMat.

from phospy import KinaseActivityAnalyzer, PhosphoDataset

dataset = PhosphoDataset.from_files(
    "examples/data/total.tsv",
    "examples/data/phospho.tsv",
    phospho_encoding="utf-16le",
)
core = dataset.preprocessing.run(max_unmatched_fraction=0.1)

analyzer = KinaseActivityAnalyzer()
result = analyzer.run(
    pred_mat=analyzer.load_pred_mat("examples/data/predMat.csv"),
    phospho_matrix=core.site_matrix.matrix,
    threshold=0.6,
    min_substrates=1,
    top_n_substrates=1,
)

ksea_scores = result.ksea_scores

The bundled example data is tiny, so it uses min_substrates=1 and top_n_substrates=1.

PhosRPipeline

Use PhosRPipeline when you want file loading, preprocessing, optional kinase analysis, and output publishing in one call.

from phospy import PhosRPipeline

pipeline = PhosRPipeline.from_files(
    total_path="examples/data/total.tsv",
    phospho_path="examples/data/phospho.tsv",
    pred_mat_path="examples/data/predMat.csv",
    phospho_encoding="utf-16le",
    max_unmatched_fraction=0.1,
    kinase_activity_threshold=0.6,
    kinase_activity_min_substrates=1,
    kinase_activity_top_n_substrates=1,
)
outputs = pipeline.run(outdir="examples/output")

When outdir is set, the pipeline writes the core outputs, any kinase-analysis outputs, and run_manifest.json.

KinaseWorkflow

Use KinaseWorkflow for the native Python end-to-end scoring and prediction workflow.

A runnable example lives in examples/native_workflow_demo.py.

From a repository checkout:

make native-workflow-demo

File Inputs

PhosPy works with:

  • total input as TSV
  • phospho input as TSV
  • predMat as CSV, with the first column used as the phosphosite index

For the default table schema and method-level validation rules, see docs/api.md.

CLI

PhosPy also ships with a small CLI for the file-based preprocessing path and optional predMat analysis.

phospy \
  --total examples/data/total.tsv \
  --phospho examples/data/phospho.tsv \
  --pred-mat examples/data/predMat.csv \
  --phospho-encoding utf-16le \
  --max-unmatched-fraction 0.1 \
  --outdir examples/output

Read Next

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

phospy-1.2.2.tar.gz (124.1 kB view details)

Uploaded Source

Built Distribution

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

phospy-1.2.2-py3-none-any.whl (99.2 kB view details)

Uploaded Python 3

File details

Details for the file phospy-1.2.2.tar.gz.

File metadata

  • Download URL: phospy-1.2.2.tar.gz
  • Upload date:
  • Size: 124.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for phospy-1.2.2.tar.gz
Algorithm Hash digest
SHA256 a3765957feee4fa9ca0434182323abe63a9cde4acd331a29c230e6dc5d8cc8c3
MD5 47a0f284e7df793e16afabc366bf453e
BLAKE2b-256 a909f77f8a126a6081a4d4302d17b16e0d087769ff97b8182e7b251561f64877

See more details on using hashes here.

Provenance

The following attestation bundles were made for phospy-1.2.2.tar.gz:

Publisher: publish.yml on falconsmilie/phospy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phospy-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: phospy-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 99.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for phospy-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fa32f082d2005dbd6c48b828c6f220b4094ec857b5917499248eec480d4763b0
MD5 1694f1067aa86b2fb620201de2626e11
BLAKE2b-256 7611698f35f4d1e922889b1abdacf475f5c8aed640e529bfa997d42665d3f513

See more details on using hashes here.

Provenance

The following attestation bundles were made for phospy-1.2.2-py3-none-any.whl:

Publisher: publish.yml on falconsmilie/phospy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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