Skip to content

K-Dense-AI/scientific-agent-skills / skills/pyopenms

pyopenms

Verified

Processes mass spectrometry data with pyOpenMS. Supports proteomics and metabolomics workflows—feature detection, peptide/protein identification, label-free quantification, adduct/accurate-mass annotation, and complex LC-MS/MS pipelines. Supports extensive file formats and algorithms. For simple spectral comparison and small-molecule library matching use matchms.

scripts/consensus_to_matrix.py

View on GitHub
#!/usr/bin/env python3
"""
Consensus Map to Quantification Matrix

Convert a consensusXML into analysis-ready tables: a wide intensity matrix
(consensus features x samples) joined with feature metadata (RT, m/z, charge,
quality), plus an optional long/tidy format. Optionally normalize intensities
across samples (median or quantile).

Usage:
    python consensus_to_matrix.py study.consensusXML --out quant.csv
    python consensus_to_matrix.py study.consensusXML --out quant.csv --normalize median
    python consensus_to_matrix.py study.consensusXML --out quant.csv --long long.csv
"""

import argparse
import os
import sys

try:
    import pyopenms as ms
except ImportError:
    print("Error: pyopenms not installed. Install with: uv pip install pyopenms")
    sys.exit(1)


def main():
    parser = argparse.ArgumentParser(description="Export a consensusXML to a quant matrix CSV.")
    parser.add_argument("input", help="Input consensusXML")
    parser.add_argument("--out", required=True, help="Output wide-matrix CSV")
    parser.add_argument("--long", help="Also write a tidy/long-format CSV")
    parser.add_argument("--normalize", choices=["median", "quantile", "none"], default="none",
                        help="Cross-sample intensity normalization (default none)")
    args = parser.parse_args()

    if not os.path.exists(args.input):
        print(f"Error: file not found: {args.input}")
        sys.exit(1)

    cm = ms.ConsensusMap()
    ms.ConsensusXMLFile().load(args.input, cm)
    print(f"Loaded {cm.size()} consensus features, {len(cm.getColumnHeaders())} samples")

    if args.normalize == "median":
        ms.ConsensusMapNormalizerAlgorithmMedian().normalizeMaps(
            cm, ms.NormalizationMethod.NM_SCALE, "", "")
        print("Applied median normalization")
    elif args.normalize == "quantile":
        ms.ConsensusMapNormalizerAlgorithmQuantile().normalizeMaps(cm)
        print("Applied quantile normalization")

    import pandas as pd
    # Ensure unique row identity; consensus ids may be 0/duplicated on some maps.
    cm.setUniqueIds()
    intensity_df = cm.get_intensity_df().reset_index(drop=True)
    meta_df = cm.get_metadata_df().reset_index(drop=True)
    matrix = pd.concat([meta_df, intensity_df], axis=1)
    matrix.to_csv(args.out, index_label="consensus_id")
    print(f"Wrote {args.out} ({matrix.shape[0]} features x {intensity_df.shape[1]} samples)")

    if args.long:
        long_df = intensity_df.copy()
        long_df.insert(0, "consensus_id", range(len(long_df)))
        long_df = long_df.melt(id_vars="consensus_id", var_name="sample", value_name="intensity")
        long_df.to_csv(args.long, index=False)
        print(f"Wrote {args.long} ({len(long_df)} rows)")


if __name__ == "__main__":
    main()
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall