Skip to main content

A python command-line utility for the generation of comprehensive reports on the quality of ribosome profiling (Ribo-Seq) datasets

Project description

PyPI version Documentation Status Build Status Python Version License

A python command-line utility for the generation of comprehensive reports on the quality of ribosome profiling (Ribo-Seq) datasets

Installation

To install RiboMetric:

$ pip install RiboMetric

For PDF export support (adds ~30 dependencies):

$ pip install RiboMetric[pdf]

Usage

Create annotation files from gff files:

$ RiboMetric prepare -g gff_file.gff

Use the annotation file to run RiboMetric on a bam file:

$ RiboMetric run -b bam_file.bam -a annotation_RiboMetric.tsv

View results interactively in your terminal:

$ RiboMetric view output_RiboMetric_data.json

By default, RiboMetric calculates standard Ribo-Seq QC metrics. To enable optional (theoretical) metrics:

$ RiboMetric run -b bam_file.bam -a annotation_RiboMetric.tsv --enable-optional-metrics

Or enable specific metrics:

$ RiboMetric run -b bam_file.bam -a annotation_RiboMetric.tsv --enable-metric periodicity_fourier

For more information on how to use RiboMetric, see the documentation or use --help

Improved outputs for pipelines and review:

# One-line summary, QC status, comparison, and detailed metrics
$ RiboMetric run -b bam.bam -a annotation.tsv --improved-outputs

Or pick specific ones:

$ RiboMetric run -b bam.bam -a annotation.tsv \
    --summary-tsv --qc-status --comparison-csv --metrics-table

Gate a pipeline on QC thresholds (exits 0/1/2 for PASS/WARN/FAIL):

$ RiboMetric evaluate -i sample_RiboMetric_data.json -e thresholds.yml

The thresholds YAML lists per-metric pass and warn values:

thresholds:
  periodicity_dominance: {pass: 0.7, warn: 0.5}
  prop_reads_CDS:        {pass: 0.7, warn: 0.5}

If -e is omitted, built-in defaults are used. Use -o to save the evaluation as JSON. Accepts either a RiboMetric JSON or a metrics-table CSV.

Most RiboMetric metrics are normalised so that higher is better (e.g. periodicity_dominance, uniformity_entropy, prop_reads_CDS). A few are lower is betterduplicate_rate, multimapper_rate, soft_clip_rate_5prime, disome_proportion, stop_codon_readthrough_ratio and the raw terminal-bias divergences. evaluate knows these directions, so a high duplicate rate fails rather than passes. To force a direction for a custom metric, add direction: lower (or higher) alongside its pass/warn values in the thresholds YAML:

thresholds:
  duplicate_rate: {pass: 0.3, warn: 0.5, direction: lower}

Enable the RUST metric (requires a transcriptome FASTA, gzip supported):

$ RiboMetric run -b sample.bam -a annotation.tsv \
    -f transcriptome.fa.gz \
    --enable-metric rust_mean_kl_divergence

For BAMs with no stored sequences, skip sequence-based metrics to avoid errors:

$ RiboMetric run -b no_seq.bam -a annotation.tsv --skip-sequence-metrics

Control multimapper handling for STAR transcriptome alignments:

# Default: frame calculations use only uniquely-mapped reads (MAPQ=255)
$ RiboMetric run -b star.bam -a annotation.tsv --multimap-filter unique_only
# Pre-1.1 behaviour: use all primary reads
$ RiboMetric run -b star.bam -a annotation.tsv --multimap-filter none

Features

RiboMetric calculates comprehensive quality metrics for Ribo-Seq data:

Default Metrics (Standard Ribo-Seq QC):
  • Read length distribution (IQR, CV, max proportion, bimodality)

  • Terminal nucleotide bias (5′ and 3′ ligation bias detection)

  • 3-nt periodicity (frame dominance and information content)

  • Metagene uniformity (entropy-based)

  • CDS coverage and regional distribution (5′UTR, CDS, 3′UTR)

  • Alignment quality — duplicate rate, multimapper rate, 5′ soft-clip rate

  • Di-some detection — bimodality coefficient + disome proportion (50–70 nt reads)

  • Codon-level translation — stop-codon readthrough ratio, start-codon enrichment ratio

  • Recommended read lengths — which lengths carry clean 3-nt periodicity (and their P-site offsets) for downstream ORF/P-site analysis; tune with --min-periodicity

  • Gene-body coverage ramp — 5′→3′ A-site density across relative CDS position (translation ramp / 3′ drop-off)

  • Library complexity — analytic saturation curve (“was this sequenced deeply enough?”)

  • Library-type classification — elongation / initiation / low-quality call with supporting evidence

  • FLOSS read-length heterogeneity — fraction of transcripts with aberrant footprint-length profiles (library homogeneity QC)

FASTA-dependent (computed automatically when ``–fasta`` is supplied):
  • A-site codon dwell-times / pause sites — per-codon occupancy and pausing summary (proline, CGA)

Optional Metrics (require explicit ``–enable-metric``):
  • RUST mean KL divergence — codon-specific A-site accumulation (requires --fasta)

  • Alternative periodicity methods (autocorrelation, Fourier transform, Trips-Viz)

  • Alternative uniformity methods (autocorrelation, Theil index, Gini index)

  • Additional read length metrics (normality test)

Use --enable-optional-metrics to calculate all optional metrics, or --enable-metric <name> for specific ones.

Output Formats

RiboMetric provides multiple output formats for different use cases:

For Pipeline Integration:
  • Summary TSV - One-line summary per sample for quick QC decisions

  • QC Status JSON - Machine-readable pass/warn/fail with thresholds

  • Comparison CSV - Wide format for multi-sample comparison

For Sample Review:
  • Interactive TUI - Terminal-based viewer for exploring metrics (RiboMetric view)

  • Interactive HTML - Professional reports with executive summary and searchable metrics

  • PDF - Archivable reports for documentation

  • Metrics Table CSV - Detailed metrics with read-length breakdowns

See REPORTING_GUIDE.md for complete documentation and examples.

Deprecated metric keys

RiboMetric now publishes both consolidated and legacy metric names to ease upgrades:

  • Consolidated: terminal_bias_kl_5prime, terminal_bias_kl_3prime, terminal_bias_maxabs_5prime, terminal_bias_maxabs_3prime, cds_coverage

  • Legacy: terminal_nucleotide_bias_distribution_5_prime_metric, terminal_nucleotide_bias_distribution_3_prime_metric, terminal_nucleotide_bias_max_absolute_metric_5_prime_metric, terminal_nucleotide_bias_max_absolute_metric_3_prime_metric, CDS_coverage_metric

Plots and summary normalization accept both. We recommend migrating dashboards and downstream code to the consolidated names.

Requirements

  • Transcriptomic alignments in coordinate-sorted BAM format

  • GFF3/GTF annotations (Ensembl recommended)

  • samtools >= 1.10 available on PATH (used for idxstats and indexing)

Testing

RiboMetric has a comprehensive test suite. The quickest way to run it is via pixi (all dependencies, including test extras, are resolved automatically):

$ pixi run test

Or with a standard virtual environment:

$ pip install -e ".[dev]"
$ pytest

Credits

This project was worked on by Lukas Wierdsma during his Internship at the UCC for Bioinformatics, Howest in 2023.

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

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

ribometric-1.2.0.tar.gz (34.0 MB view details)

Uploaded Source

Built Distribution

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

ribometric-1.2.0-py3-none-any.whl (101.8 kB view details)

Uploaded Python 3

File details

Details for the file ribometric-1.2.0.tar.gz.

File metadata

  • Download URL: ribometric-1.2.0.tar.gz
  • Upload date:
  • Size: 34.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ribometric-1.2.0.tar.gz
Algorithm Hash digest
SHA256 b0e88c9b7a971820272d5144a4644ecf4c13fabbe9d1c9e5dad56c0aa2a5633d
MD5 25e7029b2a395a0596fc439facb6d86c
BLAKE2b-256 45f9fd376ebeecaed2a82910c8e06e5142f83873230c9f4217c371f0aaba38d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for ribometric-1.2.0.tar.gz:

Publisher: release.yml on JackCurragh/RiboMetric

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

File details

Details for the file ribometric-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: ribometric-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 101.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ribometric-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bfe5d0e7b70cfdfe6920ef6285631b041ef6c465000a0d468e32acc4caf071a3
MD5 ba035582a2f1e1376c2b9f5ad4714a8a
BLAKE2b-256 9ae104a348410fbedb5e7822af18f32b1a51adf946e83b1e0090f94e076b0afd

See more details on using hashes here.

Provenance

The following attestation bundles were made for ribometric-1.2.0-py3-none-any.whl:

Publisher: release.yml on JackCurragh/RiboMetric

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