Skip to content

Allow fewer cell counts and markers in downsample#89

Merged
maxkarlsson merged 11 commits into
mainfrom
fix/allow-fewer-cell-counts-and-markers-in-downsample
Jun 18, 2026
Merged

Allow fewer cell counts and markers in downsample#89
maxkarlsson merged 11 commits into
mainfrom
fix/allow-fewer-cell-counts-and-markers-in-downsample

Conversation

@ptajvar

@ptajvar ptajvar commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Downsample fails when there are fewer markers or cells in the data from the corresponding requested numbers. This is usually not an issue but in pipeline tests the cells can be too-small or too-few for this functions.

Description

Now the downsample takes the minimum value of the requested and the available number of markers and cells. In addition, if downsampling markers results in any component having zero total counts, downsampling of markers will be disabled and all markers are kept.

Fixes: PNA-3050

Type of change

  • Bug fix

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates downsample_data() to be more robust when the requested n_cells/n_markers exceed what’s available in the input Seurat object, avoiding failures in small pipeline test datasets.

Changes:

  • Downsample cells per-sample using min(available, requested) with a warning when samples have fewer than n_cells.
  • Downsample non-control markers using min(available, requested) and handle cases where control_markers exceeds n_markers.
  • Disable marker downsampling (keep all markers) when the selected marker set would create zero-total-count columns.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 5 comments.

File Description
R/read_data.R Adds safer cell/marker downsampling logic and warning paths; introduces a marker-downsampling fallback.
man/downsample_data.Rd Updates generated documentation to describe the new edge-case behaviors.
Files not reviewed (1)
  • man/downsample_data.Rd: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/read_data.R
Comment thread R/read_data.R Outdated
Comment thread R/read_data.R Outdated
Comment thread man/downsample_data.Rd Outdated
Comment thread R/read_data.R
ptajvar and others added 4 commits June 17, 2026 16:56
Comment thread R/read_data.R Outdated
Comment thread R/read_data.R Outdated
Comment thread R/read_data.R Outdated
@maxkarlsson maxkarlsson merged commit ce31997 into main Jun 18, 2026
6 checks passed
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.

3 participants