Skip to content

feat: cap the UMI degree distribution axis at 40 and summarize outliers - #97

Closed
ludvigla wants to merge 1 commit into
mainfrom
cursor/cap-degree-distribution-axis-b8a8
Closed

feat: cap the UMI degree distribution axis at 40 and summarize outliers#97
ludvigla wants to merge 1 commit into
mainfrom
cursor/cap-degree-distribution-axis-b8a8

Conversation

@ludvigla

@ludvigla ludvigla commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Description

The UMI degree distribution is always strongly skewed: degree 1 is the most common value, counts decline rapidly, and everything above roughly 30 is an outlier. A single extreme outlier stretches the degree axis so far that the informative part of the distribution collapses into the left edge of the panel.

component_node_degree() now builds a degree distribution plot (degree_distribution_plot) from es_data$qc$degree_distribution where:

  • the degree axis is capped at degree_cap (40 by default) with coord_cartesian(), so out-of-range points are hidden without being dropped from the underlying data,
  • each sample panel with degrees above the cap gets a text box stating how many UMIs exceed the cap and what the maximum degree is, per UMI type,
  • the y axis gets extra headroom when a text box is drawn so the box does not cover the curve.

The plot is added alongside the existing mean node degree violin and table, so component$plot and component$table are unchanged. When no degree distribution data is available (older QC files, failed QC load) degree_distribution_plot is NULL. Pooled data (pool instead of sample_alias) is handled the same way as in component_denoising().

Note that the built-in Quarto report does not currently call component_node_degree(), so this only changes what the component returns; no report child document was modified.

Rendered with the degree distributions from the bundled QC test data (which contain degrees up to 49):

UMI degree distribution capped at 40 with outlier text box

Fixes: #(issue number)

Type of change

  • Bug fix
  • New feature
  • Breaking change

How Has This Been Tested?

  • CI is green: R CMD check passes on ubuntu, macos and windows, lint passes, and the Docker CI test job passes. The package test suite (including the new assertions) therefore runs against the real es_data fixtures for both the default and the hashing test data.
  • New tests in tests/testthat/test_components.R: component_node_degree() returns a buildable degree_distribution_plot, returns NULL for it when qc$degree_distribution is missing, the degree axis stays capped when an extreme outlier is present, the text box appears only when there are outliers and reports the right UMI count and maximum degree, degree_cap is configurable, and pooled input is accepted.
  • The plot was also rendered locally against the real umi1/umi2 degree distributions in inst/extdata/qc_jsons/collapse/ to check the layout of the text box (screenshot above).

PR checklist:

  • I have run R CMD check on the package and it passes.
  • I have made changes to the documentation.
  • I have added tests.
  • I have documented any significant changes in CHANGELOG.md

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

Add a UMI degree distribution plot to component_node_degree(). The degree
axis is capped at degree_cap (40 by default) so that extreme outliers do
not compress the distribution, and samples with degrees above the cap get
a text box stating the number of UMIs above the cap and the max degree.

Co-authored-by: ludvigla <ludvigla@users.noreply.github.com>
@ludvigla
ludvigla marked this pull request as ready for review August 17, 2026 07:40
@ludvigla ludvigla closed this Aug 17, 2026
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.

2 participants