Skip to content

Add replace option to subsample and rename function to sample - #943

Merged
flying-sheep merged 41 commits into
mainfrom
withreplacement
Dec 19, 2024
Merged

Add replace option to subsample and rename function to sample#943
flying-sheep merged 41 commits into
mainfrom
withreplacement

Conversation

@gokceneraslan

@gokceneraslan gokceneraslan commented Dec 2, 2019

Copy link
Copy Markdown
Contributor

so that we can do sampling with replacement. It can be useful for bootstrap samples i.e. sc.pp.subsample(adata, n_obs=adata.n_obs, replace=True). We can also sample fractions > 1, but then it's not really subsampling.

@gokceneraslan

Copy link
Copy Markdown
Contributor Author

Maybe we should make a new function called sc.pp.sample?

@ivirshup

Copy link
Copy Markdown
Member

I'd like to merge this.

I think we could just rename the function, and deprecate subsample. I'd like the name sample more for this function if we could add a dim argument so users can subsample on the variable as well.

@gokceneraslan
gokceneraslan requested a review from ivirshup April 20, 2020 20:47
@gokceneraslan gokceneraslan changed the title Add replace option to subsample. Add replace option to subsample and rename function to sample Apr 20, 2020

@ivirshup ivirshup left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good! Just a few minor comments.

Comment thread scanpy/preprocessing/_simple.py Outdated
Comment thread scanpy/tests/test_preprocessing.py Outdated
Comment thread scanpy/tests/test_preprocessing.py Outdated
Comment thread scanpy/preprocessing/_simple.py Outdated
@flying-sheep flying-sheep self-assigned this Nov 14, 2024
@flying-sheep flying-sheep added this to the 1.11.0 milestone Nov 14, 2024
@codecov

codecov Bot commented Nov 14, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 96.42857% with 3 lines in your changes missing coverage. Please review.

Project coverage is 74.12%. Comparing base (7e3dd15) to head (ce02426).
Report is 49 commits behind head on main.

Files with missing lines Patch % Lines
src/scanpy/_compat.py 91.66% 2 Missing ⚠️
src/scanpy/preprocessing/_simple.py 98.03% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #943      +/-   ##
==========================================
- Coverage   76.53%   74.12%   -2.42%     
==========================================
  Files         111      112       +1     
  Lines       12881    12937      +56     
==========================================
- Hits         9859     9589     -270     
- Misses       3022     3348     +326     
Files with missing lines Coverage Δ
src/scanpy/preprocessing/__init__.py 100.00% <100.00%> (ø)
src/scanpy/preprocessing/_deprecated/sampling.py 100.00% <100.00%> (ø)
src/scanpy/preprocessing/_simple.py 88.48% <98.03%> (-1.47%) ⬇️
src/scanpy/_compat.py 70.00% <91.66%> (-9.44%) ⬇️

... and 21 files with indirect coverage changes

Comment thread src/scanpy/preprocessing/_simple.py Outdated
Comment thread tests/test_preprocessing.py
@flying-sheep
flying-sheep changed the base branch from main to pa/deprecated November 21, 2024 13:47
Base automatically changed from pa/deprecated to main November 22, 2024 14:11
An error occurred while trying to automatically change base from pa/deprecated to main November 22, 2024 14:11
@flying-sheep
flying-sheep requested a review from Intron7 December 12, 2024 14:22
@flying-sheep flying-sheep linked an issue Dec 13, 2024 that may be closed by this pull request
Comment thread src/scanpy/preprocessing/_simple.py Outdated
Comment thread src/scanpy/preprocessing/_simple.py
@flying-sheep
flying-sheep requested a review from Intron7 December 19, 2024 09:36
@flying-sheep
flying-sheep enabled auto-merge (squash) December 19, 2024 09:47
@flying-sheep
flying-sheep merged commit 86d656d into main Dec 19, 2024
@flying-sheep
flying-sheep deleted the withreplacement branch December 19, 2024 16:48
kaushalprasadhial pushed a commit to sanchit-misra/scanpy that referenced this pull request Feb 4, 2025
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.

sc.pp.subsample, allow for sampling with replacement

6 participants