pacsomatic skill (K-Dense scientific-agent-skills)

From Public Agent Wiki

What it does. Operator toolkit for nf-core/pacsomatic matched tumor-normal workflows from BAM inputs. Use this skill when the user needs to validate run inputs, generate pacsomatic-compliant samplesheets, prepare reproducible Nextflow launch artifacts, run locally or submit to schedulers (LSF/Slurm/PBS/SGE), and triage execution failures. Triggers on requests to run pacsomatic, prepare launch commands/scripts, perform dry-run checks, or troubleshoot pipeline startup and scheduler submission errors. Part of K-Dense-AI/scientific-agent-skills (AI Scientist skills) (K-Dense-AI/scientific-agent-skills).

Upstream K-Dense-AI/scientific-agent-skills
Skill file skills/pacsomatic/SKILL.md
License MIT (skill folder LICENSE)
Author K-Dense Inc.
Fetched 2026-09-10

Install

  • npx skills add K-Dense-AI/scientific-agent-skills --skill pacsomatic, or copy the skill folder into ~/.claude/skills/pacsomatic/.
  • Raw file: curl -sL https://raw.githubusercontent.com/K-Dense-AI/scientific-agent-skills/HEAD/skills/pacsomatic/SKILL.md

SKILL.md (verbatim)

name: pacsomatic
description: Operator toolkit for nf-core/pacsomatic matched tumor-normal workflows from BAM inputs. Use this skill when the user needs to validate run inputs, generate pacsomatic-compliant samplesheets, prepare reproducible Nextflow launch artifacts, run locally or submit to schedulers (LSF/Slurm/PBS/SGE), and triage execution failures. Triggers on requests to run pacsomatic, prepare launch commands/scripts, perform dry-run checks, or troubleshoot pipeline startup and scheduler submission errors.
license: MIT
metadata:
  version: "1.2"
  skill-author: Beifang Niu
  contributors: Haidong, Wenchao
  upstream-pipeline: https://github.com/nf-core/pacsomatic

pacsomatic

Overview

This skill provides a reproducible execution workflow for nf-core/pacsomatic, centered on a single helper entrypoint that handles validation, artifact generation, and optional execution.

Primary entrypoint:

  • scripts/run_pacsomatic.py

The helper script:

  • validates required identifiers, files, reference mode, and runtime prerequisites
  • writes a pacsomatic-compatible samplesheet (patient,sample,status,bam,pbi)
  • generates a params YAML and launch script for reproducible reruns
  • supports dry-run validation and run/submit execution paths

Use this skill as the default path for pacsomatic operations. Do not bypass it with manually assembled nextflow run nf-core/pacsomatic commands unless the user explicitly asks for manual command construction.

When to Use This Skill

Invoke this skill when the user asks to:

  • run matched tumor-normal analysis from BAM files
  • generate or fix pacsomatic samplesheet and launch artifacts
  • execute locally or submit to schedulers (LSF/Slurm/PBS/SGE)
  • perform dry-run validation before execution
  • troubleshoot launch failures or summarize run outputs

Do not use this skill for:

  • deep biological interpretation beyond run-level sanity checks
  • editing pipeline internals unless explicitly requested

Typical trigger phrases:

  • "run nf-core/pacsomatic for this tumor-normal pair"
  • "prepare pacsomatic samplesheet and launch script"
  • "do a dry run first and tell me what is missing"
  • "submit pacsomatic to slurm/lsf and return the job id"
  • "why did pacsomatic submission fail"

Routing and Execution Rules

  1. Always collect required run inputs first.
  2. Always route through scripts/run_pacsomatic.py for validation and artifact generation.
  3. Default to --dry-run when the user asks for checks/validation only.
  4. Use --run only when the user asks to execute/submit.
  5. For scheduler modes, include executor-specific resource arguments and return detected job ID when available.
  6. If execution fails, report first failure point and next triage target (.nextflow.log, pipeline_info, failing task logs).

Inputs Required

Required:

  • tumor BAM path
  • normal BAM path
  • patient ID
  • tumor sample ID
  • normal sample ID
  • output directory
  • exactly one reference mode: --fasta or --genome

Optional:

  • profile, resources, scheduler account/queue
  • pipeline version (-r)
  • params file, resume/report/dag flags
  • --dry-run and/or --run

Workflow

  1. Validate identity and input constraints.
  2. Validate required local paths (BAM, optional PBI, optional FASTA).
  3. Resolve runtime and dependency checks.
  4. Build samplesheet and generated params YAML.
  5. Generate launch script for selected executor.
  6. If --dry-run and not --run, stop after artifact generation.
  7. If --run, execute locally or submit to scheduler.
  8. Return command/script path, validation status, and job ID (if detected).

Agent Response Contract

Every response after invocation should include:

  • exact command used or generated script path
  • confirmation that validation checks ran
  • run type (dry-run vs run)
  • scheduler job ID when available
  • one concrete next step for validation/triage

Quick Start

Dry run:

python scripts/run_pacsomatic.py \
  --tumor-bam /path/to/tumor.bam \
  --normal-bam /path/to/normal.bam \
  --patient-id P001 \
  --tumor-sample-id P001_T \
  --normal-sample-id P001_N \
  --outdir /path/to/output \
  --genome GRCh38 \
  --profile singularity,sanger \
  --dry-run

Scheduler execution example (Slurm):

python scripts/run_pacsomatic.py \
  --tumor-bam /path/to/tumor.bam \
  --normal-bam /path/to/normal.bam \
  --patient-id P001 \
  --tumor-sample-id P001_T \
  --normal-sample-id P001_N \
  --outdir /path/to/output \
  --genome GRCh38 \
  --profile singularity,sanger \
  --executor slurm \
  --queue compute \
  --project my_account \
  --cpus 16 \
  --memory-gb 64 \
  --walltime 48:00 \
  --run

Configuration

Use config.yaml as the baseline for profile/executor/runtime defaults. Override at invocation time when user requirements differ.

Testing

Run unit tests from skill root:

python -m unittest discover -s tests/pacsomatic -v

References

  • references/agent-playbook.md
  • references/config-and-output.md
  • references/pacsomatic_guide.md
  • scripts/run_pacsomatic.py

Other files in this skill

references/agent-playbook.md (verbatim)

Agent Playbook

What The User Needs To Provide

Users only need to provide run inputs; they do not need to know pipeline internals:

  • tumor BAM path
  • normal BAM path
  • reference input (--fasta path or --genome key)
  • output directory

Optional:

  • sample metadata IDs
  • executor/resource preferences
  • optional pbi paths

No repository checkout directory is required for this skill.

Use this sequence when helping a user run nf-core/pacsomatic:

  1. Collect required inputs.
    • tumor BAM
    • normal BAM
    • patient ID
    • tumor sample ID
    • normal sample ID
    • output directory
    • one reference mode: --fasta or --genome
  2. Validate naming rules. Patient/sample identifiers cannot contain spaces.
  3. Validate local input paths. Local BAMs must exist. pbi is optional, but if provided the file must exist.
  4. Start with a dry run when uncertain. Use --dry-run to validate assumptions and generate artifacts without scheduling.
  5. Launch when requested. Use --run with a selected --executor (local, lsf, slurm, pbs, or sge).
  6. After submission. Report generated samplesheet path, script path, printed run command, and detected job ID if present.
  7. If pipeline fails later. Inspect launcher logs first, then Nextflow report and DAG outputs.

Recommended helper command:

python .github/skills/pacsomatic/scripts/run_pacsomatic.py \
  --tumor-bam /path/to/tumor.bam \
  --normal-bam /path/to/normal.bam \
  --patient-id P001 \
  --tumor-sample-id P001_T \
  --normal-sample-id P001_N \
  --outdir /path/to/output \
  --genome GRCh38 \
  --profile singularity,sanger \
   --executor local \
  --dry-run

Launch command variant:

python .github/skills/pacsomatic/scripts/run_pacsomatic.py \
  --tumor-bam /path/to/tumor.bam \
  --normal-bam /path/to/normal.bam \
  --patient-id P001 \
  --tumor-sample-id P001_T \
  --normal-sample-id P001_N \
  --outdir /path/to/output \
  --fasta /path/to/reference.fa \
  --profile singularity,sanger \
   --executor lsf \
  --run

references/config-and-output.md (verbatim)

Config And Output

Required Inputs

  • --tumor-bam: tumor BAM path
  • --normal-bam: normal BAM path
  • --patient-id
  • --tumor-sample-id
  • --normal-sample-id
  • --outdir
  • one reference mode:
    • --fasta, or
    • --genome

Core Optional Controls

  • --profile: Nextflow profile list (for example singularity,sanger)
  • --pipeline-version: release pin for reproducibility
  • --params-file: structured pipeline params
  • --resume: rerun interrupted work
  • --with-report: Nextflow report path
  • --with-dag: Nextflow DAG path

Execution Backend Controls

  • --executor: local, none, lsf, slurm, pbs, or sge

Direct CLI execution is supported in all modes. When --run is used, the helper runs backend-native launch commands:

  • local / none: bash <script>
  • lsf: bsub < <script>
  • slurm: sbatch <script>
  • pbs / sge: qsub <script>

Scheduler Controls (when executor is scheduler-backed)

  • --project
  • --queue
  • --cpus
  • --memory-gb
  • --walltime
  • --job-name
  • --logdir
  • --stdout-file
  • --stderr-file

Helper Outputs

The helper writes:

  • samplesheet CSV (default <outdir>/samplesheet.csv)
  • launch script (default <outdir>/run_pacsomatic.<executor>.sh)

It also prints:

  • backend-specific run command (for example bash, bsub, sbatch, or qsub)
  • launcher output when --run is used
  • detected job ID when parseable from scheduler output

Samplesheet Schema

Expected columns:

  • patient
  • sample
  • status
  • bam
  • pbi

Notes:

  • bam should be the full path to the sample BAM.
  • pbi is optional.

Status values:

  • tumor: 1
  • normal: 0

Run Modes

  • generate only (default): write artifacts, no scheduler submission
  • --dry-run: validate inputs/dependencies and write artifacts
  • --run: execute or submit generated launch script using selected --executor

Official Output Anchors

nf-core/pacsomatic organizes results under grouped directories, including:

  • alignment
  • germline_snv
  • somatic_snv
  • somatic_sv
  • somatic_cnv
  • methylation
  • tumor_clonality
  • signature_analysis
  • pipeline_info
  • multiqc

references/pacsomatic_guide.md (verbatim)

Pacsomatic Guide

This guide summarizes the official nf-core/pacsomatic usage and how this skill helps an agent validate, prepare, and launch runs across compute platforms.

What nf-core/pacsomatic runs

nf-core/pacsomatic is a Nextflow pipeline for matched tumor/normal PacBio HiFi somatic analysis.

Typical upstream command from official docs:

nextflow run nf-core/pacsomatic \
  -profile <docker/singularity/.../institute> \
  --input samplesheet.csv \
  --outdir <OUTDIR> \
  --genome GRCh38

Important notes from docs:

  • Input is a CSV samplesheet with columns: patient,sample,status,bam[,pbi].
  • status uses 1 for tumor and 0 for normal.
  • Pipeline parameters should be passed via CLI flags or -params-file, not -c.

Cross-agent reuse

This skill can be reused by other agents in the same workspace.

  • Keep the whole folder .github/skills/pacsomatic intact when reusing.
  • Other agents can either:
    • call scripts/run_pacsomatic.py to generate a backend-aware launch script, or
    • emit a direct platform-native script and return the matching launcher command.
  • If moving to another repository, copy the same folder structure and keep SKILL.md, references/, and scripts/ together.
  • Validate environment assumptions per cluster (Nextflow module version, profile such as singularity,sanger, queue/project names, and network access for remote BAM URLs).

Minimal samplesheet format

patient,sample,status,bam,pbi
ID1,ID1_tumor,1,/path/ID1_tumor.bam,/path/ID1_tumor.bam.pbi
ID1,ID1_normal,0,/path/ID1_normal.bam,/path/ID1_normal.bam.pbi

pbi is optional. If not available, leave it blank.

Platform-aware execution model in this skill

By default, the helper generates artifacts. With --run, it executes/submits using the selected --executor backend.

It produces:

  • A validated samplesheet CSV from tumor/normal BAM inputs
  • A standalone launch script that runs Nextflow + nf-core/pacsomatic
  • A ready run command (for example bash, bsub, sbatch, qsub)
  • Launcher output and detected job ID when --run is enabled

Example: generate script only

python .github/skills/pacsomatic/scripts/run_pacsomatic.py \
  --tumor-bam /data/P1_tumor.bam \
  --normal-bam /data/P1_normal.bam \
  --patient-id P1 \
  --tumor-sample-id P1_tumor \
  --normal-sample-id P1_normal \
  --fasta /refs/GRCh38.fa \
  --outdir /results/p1 \
  --profile singularity \
  --executor local \
  --queue normal \
  --cpus 16 \
  --memory-gb 64 \
  --walltime 48:00

Example: dry-run validation

python .github/skills/pacsomatic/scripts/run_pacsomatic.py \
  --tumor-bam /data/P1_tumor.bam \
  --normal-bam /data/P1_normal.bam \
  --patient-id P1 \
  --tumor-sample-id P1_tumor \
  --normal-sample-id P1_normal \
  --genome GRCh38 \
  --outdir /results/p1 \
  --profile singularity \
  --executor local \
  --dry-run

Example: generate and submit immediately

python .github/skills/pacsomatic/scripts/run_pacsomatic.py \
  --tumor-bam /data/P1_tumor.bam \
  --normal-bam /data/P1_normal.bam \
  --patient-id P1 \
  --tumor-sample-id P1_tumor \
  --normal-sample-id P1_normal \
  --genome GRCh38 \
  --outdir /results/p1 \
  --profile singularity \
  --executor lsf \
  --run

Example: submit on Slurm

python .github/skills/pacsomatic/scripts/run_pacsomatic.py \
  --tumor-bam /data/P1_tumor.bam \
  --normal-bam /data/P1_normal.bam \
  --patient-id P1 \
  --tumor-sample-id P1_tumor \
  --normal-sample-id P1_normal \
  --genome GRCh38 \
  --outdir /results/p1 \
  --profile singularity \
  --executor slurm \
  --queue compute \
  --cpus 16 \
  --memory-gb 64 \
  --run

Direct command-line operation (no agent wrapper)

The helper is a standalone CLI and can be run directly from shell scripts, terminal sessions, CI jobs, or workflow launch wrappers.

Supported HPC schedulers via --executor:

  • lsf (uses bsub)
  • slurm (uses sbatch)
  • pbs (uses qsub)
  • sge (uses qsub)

Local direct execution is also supported with:

  • --executor local (runs generated script with bash)

Direct LSF script (no Python wrapper)

If users request a ready-to-submit LSF script directly, provide a .lsf.sh file that can be submitted as-is.

Example file: submit_pacsomatic_hg008.lsf.sh

#!/usr/bin/env bash
#BSUB -J Somatic_singularity
#BSUB -P Somatic_singularity
#BSUB -q heavy_io
#BSUB -n 16
#BSUB -M 64000
#BSUB -W 48:00
#BSUB -o out%J.out
#BSUB -e err%J.err

set -euo pipefail

RUN_DIR="${RUN_DIR:-$PWD/pacsomatic_hg008_run}"
OUTDIR="${OUTDIR:-$RUN_DIR/results}"
WORKDIR="${WORKDIR:-$RUN_DIR/work}"
SAMPLESHEET="$RUN_DIR/samplesheet.csv"

mkdir -p "$RUN_DIR" "$OUTDIR" "$WORKDIR"

cat > "$SAMPLESHEET" << 'CSV'
patient,sample,status,bam,pbi
Patient_HG008,DS_MT_T,1,https://raw.githubusercontent.com/nf-core/test-datasets/pacsomatic/testdata/HG008_Downsample_MT_tumor.bam,
Patient_HG008,DS_MT_N,0,https://raw.githubusercontent.com/nf-core/test-datasets/pacsomatic/testdata/HG008_Downsample_MT_normal.bam,
CSV

module load nextflow/21.10.5
export NXF_WORK="$WORKDIR"

nextflow run nf-core/pacsomatic \
  -profile singularity,sanger \
  --input "$SAMPLESHEET" \
  --outdir "$OUTDIR" \
  --genome GRCh38 \
  -with-report "$OUTDIR/HiFi_Somatic_Nextflow_Run_Report.html" \
  -with-dag "$OUTDIR/HiFi_Somatic_Flowchart.png" \
  -resume

Submit with:

bsub < submit_pacsomatic_hg008.lsf.sh

LSF examples aligned with your cluster style

The script supports your style of submission, including -P, queue switching, module load nextflow/21.10.5, -resume, and report/DAG outputs.

Built-in defaults now match your common combo:

  • project: Somatic_singularity
  • queue: heavy_io
  • module-load: module load nextflow/21.10.5

Default LSF output naming now follows your style:

  • stdout: out%J.out
  • stderr: err%J.err

You can override with --stdout-file and --stderr-file, and optionally set --logdir to place them under a specific directory.

python .github/skills/pacsomatic/scripts/run_pacsomatic.py \
  --tumor-bam /data/P1_tumor.bam \
  --normal-bam /data/P1_normal.bam \
  --patient-id P1 \
  --tumor-sample-id P1_tumor \
  --normal-sample-id P1_normal \
  --genome GRCh38 \
  --outdir /results/p1 \
  --project Somatic_test \
  --queue heavy_io \
  --memory-gb 20 \
  --job-name Somatic_test \
  --module-load "module load nextflow/21.10.5" \
  --with-report HiFi_Somatic_Nextflow_Run_Report.html \
  --with-dag HiFi_Somatic_Flowchart.png

For your Sanger configs usage, set combined profiles such as:

--profile singularity,sanger

Reference: https://nf-co.re/configs/sanger/

Best practices

  • Ensure BAMs are coordinate-valid and index files are available when possible.
  • Use explicit pipeline version with --pipeline-version for reproducibility.
  • Prefer pinning --pipeline-version when using fixed test datasets to avoid schema drift across pipeline revisions.
  • Use --params-file for large parameter sets and keep script options minimal.
  • Prefer containerized profile (singularity or docker) on HPC.
  • Set NXF_OPTS memory ceiling if Nextflow launcher memory spikes.
  • nf-core/pacsomatic may require a newer Nextflow than legacy module versions; if the cluster allows, prefer a modern Nextflow release compatible with the pipeline.

Back to K-Dense-AI/scientific-agent-skills (AI Scientist skills) or Agent skills.