feat(cell_metrics): source per-category junction violins from the cell summary - #40
Merged
Merged
Conversation
…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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
on-the-fly junctions×classification explosion and into real cell-summary
columns, computed once during metrics.
{tag}_{jtype}_junctions— 9 structuralcategories × 4 junction types (known/novel × canonical/non-canonical) — in
both modes.
junc_summ_htmlblock and its duplicated PDFjunc_summblock), continuingthe B-pass effort to make
SQANTI-sc_report.Rread precomputed columnsinstead of re-deriving per-cell metrics.
Details
cell_metrics.py— emits the 36 columns in both modes. Isoforms mode isFL-weighted through the existing
wsum/m_cat/per-transcript machinery (nonew junctions×cells cartesian). Reads mode joins each junction to its
transcript's
structural_categoryandCBby isoform key.SQANTI-sc_report.R— newbuild_junc_cat_long()derives the fourper-category percentages from the columns (
total = sum of the four counts;percentage is
NAwhen a cell has no junctions of a category, so it drops outof the violin rather than reading as 0%). Both the HTML and PDF blocks now call
it, deleting the two
junc_aug/junc_summexplosions.