Allow fewer cell counts and markers in downsample#89
Merged
maxkarlsson merged 11 commits intoJun 18, 2026
Conversation
Contributor
There was a problem hiding this comment.
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 thann_cells. - Downsample non-control markers using
min(available, requested)and handle cases wherecontrol_markersexceedsn_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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
maxkarlsson
requested changes
Jun 17, 2026
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.
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
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
PR checklist: