Skip to content

feat(cell_metrics): source per-category junction violins from the cell summary - #40

Merged
CarlosBlancoGo merged 1 commit into
mainfrom
feat/junction-metrics-cell-summary
Jul 20, 2026
Merged

feat(cell_metrics): source per-category junction violins from the cell summary#40
CarlosBlancoGo merged 1 commit into
mainfrom
feat/junction-metrics-cell-summary

Conversation

@CarlosBlancoGo

Copy link
Copy Markdown
Collaborator

Summary

  • Moves the per-structural-category junction breakdown out of the report's
    on-the-fly junctions×classification explosion and into real cell-summary
    columns, computed once during metrics.
  • Adds 36 per-cell columns {tag}_{jtype}_junctions — 9 structural
    categories × 4 junction types (known/novel × canonical/non-canonical) — in
    both modes.
  • Removes both junction re-explosions from the report (the HTML
    junc_summ_html block and its duplicated PDF junc_summ block), continuing
    the B-pass effort to make SQANTI-sc_report.R read precomputed columns
    instead of re-deriving per-cell metrics.

Details

  • cell_metrics.py — emits the 36 columns in both modes. Isoforms mode is
    FL-weighted through the existing wsum/m_cat/per-transcript machinery (no
    new junctions×cells cartesian). Reads mode joins each junction to its
    transcript's structural_category and CB by isoform key.
  • SQANTI-sc_report.R — new build_junc_cat_long() derives the four
    per-category percentages from the columns (total = sum of the four counts;
    percentage is NA when a cell has no junctions of a category, so it drops out
    of the violin rather than reading as 0%). Both the HTML and PDF blocks now call
    it, deleting the two junc_aug/junc_summ explosions.
  • Tests — added guards for the new columns in both modes.

…l summary

Add 36 per-cell columns {tag}_{jtype}_junctions (9 structural categories x 4
junction types: known/novel x canonical/non-canonical) to the cell summary, in
both modes. Isoforms mode is FL-weighted via the existing wsum/m_cat/per_tx
approach; reads mode joins each junction to its transcript's structural_category
and CB by isoform key. The report's new build_junc_cat_long() derives the four
per-category percentages from these columns (total = sum of the four counts;
percentage NA when a cell has no junctions of a category, so it drops out of the
violin). Both the HTML junc_summ_html block and the duplicated PDF junc_summ block
now call it, removing both junctions-x-classification re-explosions from the report.
@CarlosBlancoGo
CarlosBlancoGo merged commit e7cc925 into main Jul 20, 2026
2 checks passed
@CarlosBlancoGo
CarlosBlancoGo deleted the feat/junction-metrics-cell-summary branch July 20, 2026 07:01
CarlosBlancoGo added a commit that referenced this pull request Jul 20, 2026
…cating rows (#42)

The per-cluster length-distribution violins re-derived their data by exploding the classification CB/FL lists to per-(transcript, cell) rows and then replicating each row FL times (rep(seq_len(n), times = FL)) so every read became a literal row. In isoforms mode the replicated frame is the number of reads -- the same per-read explosion that #35, #36, #40 and #41 removed elsewhere by moving metrics off the report's on-the-fly re-derivation.

Aggregate instead to per-(transcript, cluster) with weight = sum(FL), and drive the violin with the native geom_violin weight aesthetic, plus a weighted mean and a weighted five-number box summary computed from a small weighted-quantile helper. This reproduces the FL-replicated distribution exactly at a fraction of the rows: on the test set the weighted mean matches the replicated mean to full precision and the quantiles to within interpolation noise (invisible on the log-length axis); the rendered violins are indistinguishable in both modes.

The weighted-quantile helper also handles clusters/category subsets with fewer than two points (a single transcript collapses to a degenerate box) so sparse per-category panels no longer abort the whole length-by-cluster block via the outer tryCatch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant