SAGAconf
SAGAconf gives a calibrated confidence score to each call in a chromatin state annotation. Segmentation and genome annotation (SAGA) methods, such as ChromHMM and Segway, label every genomic bin with a chromatin state. Many of these labels do not reproduce across replicates. SAGAconf compares a base annotation with a verification annotation and gives each bin an r-value: a score for how well its state call reproduces. You can then keep only the reproducible calls for downstream analysis. SAGAconf works with any SAGA method, because it reads only the posterior probability matrix.
- Paper: Foroozandeh Shahraki, Farahbod and Libbrecht, Robust chromatin state annotation, Genome Research 34(3):469–483, 2024.
- Blog post: Reproducibility as a measure of confidence.
Install
pip install sagaconf
SAGAconf needs Python 3.9 or later. The active-regions mode also needs
bedtools on your PATH.
Quick start
Parse the posteriors of each annotation, then compare the two parsed files:
sagaconf parse --saga chmm base_posteriors/ 200 base/
sagaconf parse --saga chmm verif_posteriors/ 200 verif/
sagaconf run base/parsed_posterior.bed verif/parsed_posterior.bed results/
results/r_values.bed holds one r-value per bin. results/confident_segments.bed holds the
reproducible subset of the base annotation.
To run the full example on ChromHMM's sample data, run example/run.sh.
Input
SAGAconf compares two annotations of the same genome:
- The base annotation is the one you want to score.
- The verification annotation comes from a replicate. It can come from different data and a different model (setting S1 in the paper), the same model trained on both replicates (S2), or the same data with a different random initialization (S3).
sagaconf run reads one parsed posterior file per annotation. The file has one row per
genomic bin and K + 3 columns: chr, start, end, and one posterior probability for
each of the K states. The file can be BED (tab-separated) or CSV. sagaconf parse writes
this file from the output of ChromHMM or Segway:
- ChromHMM: run
LearnModelwith-printposterior. Givesagaconf parsethe directory of*_posterior.txtfiles (one file per cell type and chromosome). - Segway: give
sagaconf parsethe directory ofposterior<i>.bedGraphfiles (one file per state).
Commands
sagaconf parse
sagaconf parse --saga {chmm,segway} [--out-format {bed,csv}] POSTERIORDIR RESOLUTION OUTDIR
| Argument | Meaning |
|---|---|
POSTERIORDIR |
Directory with the SAGA model's posterior files. |
RESOLUTION |
Bin size of the SAGA model, in bp. |
OUTDIR |
Directory for parsed_posterior.bed (or .csv). SAGAconf creates it if it does not exist. |
--saga |
The SAGA model that wrote the posteriors: chmm or segway. |
--out-format |
bed (default) or csv. |
sagaconf run
sagaconf run BASE VERIF OUTDIR [--mode MODE] [options]
| Option | Default | Meaning |
|---|---|---|
--mode |
full |
The analysis to run. See the table below. |
-bm, --base-mnemonics FILE |
none | State names for the base annotation. |
-vm, --verif-mnemonics FILE |
none | State names for the verification annotation. |
-s, --chr21-only |
off | Analyse chr21 only, for a quick check. |
-w, --window-size BP |
1000 | Window around each bin, in bp. |
-to, --iou-threshold |
0.75 | IoU overlap that makes two states correspond. |
-tr, --repr-threshold |
0.8 | r-value that makes a bin reproduced (α in the paper). |
-k, --merge-k K |
none | Merge the base states down to K states. |
--ccre-file FILE |
none | cCRE BED file. The active-regions mode needs it. |
--meuleman-file FILE |
none | Meuleman et al. DHS index for the active-regions mode. If you omit it, SAGAconf skips that step. |
-v, --verbose |
off | Report the analysis steps that fail. |
| Mode | What it writes |
|---|---|
full |
All analyses: r-values, confident segments, overlap, calibration, granularity and misalignment reports. |
quick |
The essential reports only. |
rvalues |
r_values.bed only. |
celltype |
The per-annotation analyses (overlap, calibration, granularity, misalignment). |
seglength |
Reproducibility as a function of position in a segment. |
merge |
The reports after merging the base states down to -k states. |
active-regions |
r-values genome-wide and in cCREs (and in Meuleman DHSs if you give the file). |
python -m sagaconf runs the same command as sagaconf.
Mnemonics file
A mnemonics file gives each state a biological name. It is a tab-separated file with the
header old and new. The old column holds the state number, in the column order of the
parsed posterior file. The numbers can start at 0 or at 1. The new column holds the name.
SAGAconf shortens each name to its first 4 characters (and to 3 characters after an
underscore), so Enhancer_low becomes Enha_low. Reports then name each state
<number>_<short name>, for example 0_Enha_low.
Rules that are easy to miss:
- SAGAconf uses the names only when you give both
-bmand-vm. - The first row decides the numbering:
oldmust start at 0 or at 1. With any other start, no state gets a name. - A name can hold at most one underscore. A state with no usable row is named
<number>_Unkn.example/example_mnemonics.txtis an example:
old new
1 Enhancer_low
2 Enhancer
3 Promoter_flanking
Running from scripts and agents
sagaconf --help, sagaconf parse --help and sagaconf run --help hold everything a script
needs: the input and mnemonics formats, the main outputs, the cost, and the exit status.
-
Input check. Both parsed posterior files must use the same bins and the same number of states.
sagaconf runjoins them onchr,startandend, and scores only the shared bins. It reads the resolution from the first row. The file format follows the extension in the name (.bedor.csv). -
Try it small first.
-sanalyses chr21 only.--mode rvalues -sgivesr_values.bedfor chr21 in a minute or two. -
Cost. Version 1.2.0, genome-wide GM12878, 16 states, 24 CPUs:
Full mode Time Peak memory ChromHMM, 200 bp bins about 3 minutes about 50 GB Segway, 100 bp bins about 10 minutes about 60 GB On Linux with 2 or more CPUs, SAGAconf runs independent analysis steps in parallel processes. It keeps them within 65% of the memory limit: the Slurm or cgroup limit, else the free memory of the machine. The output is the same as with one CPU. To use one process, run on one CPU, for example
taskset -c 0 sagaconf run .... While it runs,OUTDIRholds a copy of both input files. -
Exit status. 0 is success. 1 is an error, or, in
fullmode, one or more failed analysis steps (stderr lists them; the other steps still ran). 2 is an invalid argument.
Output
sagaconf run writes these files in OUTDIR in full mode:
| File | Content |
|---|---|
r_values.bed |
The r-value of each bin: chr, start, end, MAP (the most probable state), r_value. |
r_values_UCSC_GenomeBrowser.bed |
The r-values as a UCSC Genome Browser track. |
r_values_report.txt |
The average r-value, genome-wide and per state. |
rval_hist |
Histograms of r-values per state. |
confident_segments.bed |
The reproducible subset of the base annotation, one row per bin. |
confident_segments_dense.bed |
The same subset, with adjacent bins of one state merged into segments. |
ratio_robust.txt |
The fraction of bins that are reproduced, genome-wide and per state. |
overlap_ratio.txt |
The naive overlap per state. |
NMI.txt |
Mutual information, with and without the posteriors. |
coverages1.txt, coverages2.txt |
The genome coverage of each state in the base and verification annotations. |
heatmap, heatmap_w |
IoU overlap between the states of the two annotations, with w = 0 and with w > 0. |
binned_posterior_heatmap |
IoU overlap against the binned posteriors of the base annotation. |
granularity, barplot, AUC_mAUC.txt |
The state-merging curve and the area under it (auSMC) per state. |
len_bound, len_bound_overall |
Overlap as a function of w, per state and genome-wide. |
calib/ |
Posterior calibration curves per state. |
Dist_vs_Corresp/, Dist_vs_Corresp_3/ |
Overlap and correspondence as a function of w. |
Each plot is written as PDF and SVG. Each .txt file next to a plot holds the plotted values.
Changes from the paper version
The results match the version that the paper used, except for these fixes:
- In
fullmode,-know merges states. Before, it did nothing. - Without mnemonics,
fullmode now writes the genome-wide results (includingconfident_segments.bedand the UCSC track). Before, it skipped them. - In
mergemode, SAGAconf now writes the UCSC track for merged states. Before, it stopped with aKeyError.
Legacy interface
The original scripts still work, with the same flags and the same output:
python SAGAconf_parser.py --saga chmm POSTERIORDIR 200 OUTDIR
python SAGAconf.py [-q | --r_only | --ct_only | ...] BASE VERIF OUTDIR
sagaconf run also accepts the original flag names (--r_only, --windowsize,
--base_mnemonics, and so on). In the original scripts, the --active_regions mode reads
src/biointerpret/GRCh38-cCREs.bed and src/biointerpret/Meuleman.tsv relative to the
working directory.
The code as the paper used it is on the legacy
branch (tag v0-legacy). That branch also keeps the scripts that produced the paper's figures.
Tests
tests/golden/ checks that this version gives byte-identical output to the
legacy version. It runs both versions on the same input and compares every file they write,
and everything they print. tests/golden/gate.py describes the method.
The check passes on synthetic data and on the paper's GM12878 ChromHMM and Segway annotations.
Citation
@article{foroozandeh2024robust,
title = {Robust chromatin state annotation},
author = {Foroozandeh Shahraki, Mehdi and Farahbod, Marjan and Libbrecht, Maxwell W.},
journal = {Genome Research},
volume = {34},
number = {3},
pages = {469--483},
year = {2024},
doi = {10.1101/gr.278343.123}
}
License
SAGAconf is available under the MIT License.
Metadata
Release files for sagaconf 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sagaconf-1.2.0.tar.gz | 67.2 kB | With provenance | Details for sagaconf-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sagaconf-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for sagaconf-1.2.0-py3-none-any.whl |
Total release size: 131.5 kB
Release files / sagaconf-1.2.0.tar.gz
| Download URL | sagaconf-1.2.0.tar.gz |
|---|---|
| Size | 67.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac4bcfab848448c72b9848973a886ea792259db356436483e9743d70bc0317a3
|
|
BLAKE2b-256 checksum How to use checksums |
cc939b09826d635435cea5a49ef3a85549c085ca98834fb1a1b9386b30b7e1b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logRelease files / sagaconf-1.2.0-py3-none-any.whl
| Download URL | sagaconf-1.2.0-py3-none-any.whl |
|---|---|
| Size | 64.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7c4836719bea6b8802298ad519f0c00b44bf4234f5e98c6b9973993dd6abb012
|
|
BLAKE2b-256 checksum How to use checksums |
d3ccf74988a019d6950017a2f4b16ea97bcba37119f50c7648555399a613f0af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logSecurity for sagaconf 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for sagaconf-1.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.