Command Reference#
Global Options#
cftk [--version] [--config PATH] <command> ...
--versionPrint the installed CFTK package version and exit.
--config PATHPath to
cftk_init.json. Defaults to./cftk_init.json.
Commands#
initCreate a missing schema-v2 project interactively, or validate an existing schema-v2/legacy config and prepare bwa-meth, samtools, and Picard reference companions.
cftk initFor managed batch setup, pass
--non-interactiveand--sample-sheet PATH. The default profile installs underCFTK_REFERENCE_ROOTor~/.cache/cftk/references. Local mode also requires--reference-mode local --reference-root PATH.--profileand--profile-versionselect a non-default or ambiguous version. The expertCFTK_REFERENCE_REGISTRYoverride remains available. Pass--skip-reference-prepfor validation only.doctorCheck whether selected core processing and optional downstream-analysis stages can start. The default checks steps 1 through 4. Diagnostics continue after failures and do not download, index, repair, or process data.
cftk --config cftk_init.json doctor cftk --config cftk_init.json doctor --step 4 --json cftk --config cftk_init.json doctor --analysis-preset comparative
--step {1,2,3,4}accepts one or more space-separated values.--target-bed PATHvalidates an expert Picard covered-target override;--skip-picard-metricsremoves Picard metrics from the required step-3 tool checks.--parallel Nvalidates a parallel-sample override against the configured total CPU budget and detected scheduler allocation.--jsonwrites only machine-readable JSON to stdout.--analysis-presetor--analysis-stageadds read-only checks for the downstream stage dependencies, inputs, references, roles, and CPU plan.--fragmentomics-scopeapplies the same assay-aware scope resolution to selected WPS, occupancy, and DELFI checks.Human checks use
PASS,WARN, andFAIL. No required failures returns exit status 0; one or more failures returns 1; invalid arguments return 2.runRun the beginner-safe schema-v2 core workflow. The default order is process steps 1-4, then QC steps 2, 0, and 1. FASTQ projects run every stage; BAM projects record process steps 1-2 as skipped. Mixed inputs, legacy configs, missing locks, alternative processing tools, and failed doctor checks stop before computation.
cftk run cftk run --dry-run cftk run --parallel 2 --qc-dinucleotide cftk run --downstream auto cftk run --downstream differential --modality cpg
By default,
runstops after core processing and QC.--downstreamexplicitly continues into a role-aware downstream preset, reusing valid artifacts and linking the downstream manifest and HTML summary from the core run summary.--downstream allis an advanced option; per-sample job plans and Slurm helpers remain separate advanced commands and are never submitted automatically.--adopt-existingis required to validate complete outputs that predate a run manifest. Partial untrusted outputs are preserved in a timestamped quarantine before retry. Automatic resume requires a matching config, lock, options hash, exact CFTK software identity, trusted prior stage state, and currently valid artifacts. A code or installed-build change therefore reruns affected stages instead of silently reusing old results.--target-bed PATHis an expert one-run Picard target override.--parallel Nsets concurrent samples. CFTK divides the configured totalprocess.coresbudget across those sample commands and records the result inresource-plan.json.--fragmentomics-scopeis an advanced downstream-only override and must be used together with--downstream; it applies the same panel/genome scope contract ascftk analyze.--modality NAME [NAME ...]selects differential matrices for this run without rewriting the config and requires a downstream preset containing differential analysis.Every attempt writes
run.json, event and command JSONL files, doctor and tool-version JSON, output/figure TSVs, andrun-summary.htmlunderresults/provenance/runs/<run-id>/. It also generates anevidence/directory containing stage/artifact/command tables and sanitized figure previews. If analysis completes but evidence reporting fails, the manifest status iscomplete_with_reporting_errorand the command returns a distinct nonzero status; a subsequent run can rebuild evidence without rerunning valid stages. See Beginner Workflow for the full contract.planResolve a role-aware downstream preset and record its dependencies, resources, expected outputs, and read-only doctor result without launching a stage.
cftk plan cftk plan --preset all cftk plan --preset differential --modality cpg occupancy wps cftk plan --stage diff report --json cftk plan --stage delfi --execution per-sample --slurm
autoplans occupancy, WPS, and reporting for one group; it additionally plans differential analysis for an explicit two-group control/case project.comparativeandallrequire roles, not group-name inference. Plans are recorded underresults/provenance/analysis-plans/. Use--fragmentomics-scope panel|genomeonly when overriding the assay-aware default. If configured differential or MESA modalities require occupancy or WPS matrices, their producer stages are added ahead of the dependent stage. A differential modality override is recorded in the plan and cannot be combined with--execution per-samplebecause the comparison is a cohort-level stage.--execution localis the default read-only plan and the recommended beginner path. Normal execution usescftk run --parallel N(or one ordinary institutional batch job containing that command). For expensive fragmentomics or core stages, the advanced--execution per-samplewrites one independent sample task plus a dependent cohort finalizer. CFTK never submits jobs or requires a scheduler. Fragmentomics sample tasks run the establishedcftk fragimplementation with--parallel 1 --no-finalize; core and QC tasks use their correspondingcftk process/cftk qcboundaries. The finalizer verifies all per-sample outputs, creates cohort matrices/figures where applicable, and records successful completion.--slurmadditionally writes an optional Slurm-array helper and success-gated finalizer helper underresults/provenance/job-plans/.Core processing and fragment-length QC can use the same one-sample boundary when a scheduler should own the sample jobs:
cftk plan --workflow core --execution per-sample --slurm cftk plan --workflow process --stage 3 --execution per-sample --slurm cftk plan --workflow qc --stage 2 --execution per-sample --slurm
coreincludes process steps 1-4 and QC step 2. BAM-only projects mark FASTQ-only process steps 1-2 as skipped. QC steps 0, 1, and 3 remain cohort-level because they assemble cohort tables or figures; run them once after the generated sample tasks finish. The generated process step-3 finalizer also requires the covered-targetCollectHsMetricsandCollectMultipleMetricsoutputs unless--skip-picard-metricswas explicitly used for the sample tasks. CFTK never submits the helper; submit it under the user’s institutional account.statusAdvanced, read-only inspection of a generated per-sample job plan. It reports observed sample artifacts and whether each finalizer is pending, ready, complete, or stale (a recorded finalizer whose artifacts no longer satisfy the plan). It does not infer scheduler queue or failure state.
cftk status cftk status --workflow core --json cftk status --plan results/provenance/job-plans/core-*/job-plan.json
analyzeRun downstream stages with fail-fast preflight, artifact contracts, provenance, evidence, and resume behavior. It requires a schema-v2 project and its matching lock file.
cftk analyze --dry-run cftk analyze --preset differential --modality cpg cftk analyze --preset fragmentomics cftk analyze --preset comparative cftk analyze --preset all
Explicit presets are
descriptive,differential,dmr,fragmentomics,mesa,comparative,all, andreport. Use--stagefor a precise stage or alias such asdiff,wps, orreport.--fragmentomics-scopecontrols targeted WPS, occupancy, and DELFI inputs; it defaults to panel scope for Twist. Complete stages recorded by a compatible prior analysis manifest are validated and reused automatically, even when the current preset selects additional stages. Thedifferentialanddmrpresets also refreshresults/report/report.html. DMR stage reuse additionally requires matching SHA-256 signatures for the selected CpG bedGraphs.--modality NAME [NAME ...]overrides only the selected run and is stored in the plan, manifest, and reconstructed command. Differential stage reuse additionally requires matching SHA-256 signatures for all selected input matrices; changing a matrix reruns the comparison while unchanged matrices remain reusable.--adopt-existingremains available for complete outputs produced before any trusted analysis manifest; untrusted partial outputs are quarantined before a retry. See Downstream Workflow.job-planCompatibility alias for
cftk plan --execution per-sample. New scripts should useplanso all workflow planning starts from one command.processRun raw processing steps 1 through 4. Step 3 uses the schema-v2 profile’s covered-target BED for Picard metrics, with a bundled source-checkout fallback for legacy configs.
cftk --config cftk_init.json process -s 1 2 3 4
Use
--target-bed PATHto override the covered targets, or--skip-picard-metricsfor a workflow that does not need them.qcRun QC steps 0 through 3. Step 0 assembles QC tables, step 1 plots methylation distributions, step 2 measures fragment lengths, and step 3 computes dinucleotide frequencies.
cftk --config cftk_init.json qc -s 1 2 3
powerRun the legacy CpG-level analytical power workflow. It uses the pickled
reference_data.cpg_stdtable fromcftk_init.jsonto evaluate methylation effect-size and sample-size scenarios.cftk --config cftk_init.json power -s 100 -e 0.1
This command is separate from the model-development power calculator. The latter simulates cross-validated feature selection and classification, performs matched null calibration, and is available through the Python API and Streamlit app described in Model-Development Power.
diffAdvanced compatibility command that runs PCA, differential testing, and visualizations directly. It does not provide managed preflight, matrix-sensitive resume, evidence generation, or immutable analysis-run provenance. Prefer
cftk analyze --preset differentialfor new work.cftk --config cftk_init.json diff --modality cpg cftk --config cftk_init.json diff --modality cpg occupancy wps
dmrAdvanced direct DMR compatibility command. It bypasses managed preflight, input-sensitive resume, evidence, and immutable analysis-run provenance. Prefer
cftk analyze --preset dmrfor new projects; it uses all samples in the role-defined groups unlessanalysis.dmr.samplesselects a subset, records the selection, and refreshes the final report.cftk --config cftk_init.json dmr
fragRun fragmentomics workflows. Occupancy and WPS are valid for a one-group descriptive project; comparison figures are produced only when two groups are available. The default Twist profile scopes WPS, occupancy, and DELFI to panel-overlapping reads and regions. Use
--fragmentomics-scope genomeonly for validated whole-genome inputs.cftk --config cftk_init.json frag --wps cftk --config cftk_init.json frag --delfi --fragmentomics-scope panel
--sample NAME --no-finalizeis the internal/public per-sample task boundary used byplan --execution per-sample. Use--finalizeonly after every sample task for that stage is successful; it validates the expected per-sample outputs and creates cohort matrices and figures without recalculating the sample measurements.mesaRun MESA modality performance, model construction, and LOOCV. It requires explicit control/case roles; CFTK does not infer labels from group names.
cftk --config cftk_init.json mesa --performance --mesa-model --loocv
mergeBuild feature matrices from user-specified files in the config
mergeblock.cftk --config cftk_init.json merge --modality cpg
visRegenerate visualizations from existing results.
cftk --config cftk_init.json vis --mode all
reportGenerate a self-contained HTML report.
cftk --config cftk_init.json report
run-allRun the expert compatibility pipeline. It may continue after a failed step and does not provide the validated run-state/resume contract of
cftk run.cftk --config cftk_init.json run-all --parallel 4