Skip to content

feat: add anndata.acc support to mask params - #4333

Merged
flying-sheep merged 7 commits into
mainfrom
mask-acc
Sep 11, 2026
Merged

flying-sheep merged 7 commits into
mainfrom
mask-acc

Conversation

@flying-sheep

@flying-sheep flying-sheep commented Sep 1, 2026 •

Copy link
Copy Markdown
Member

TODO:

  • probably good to unify _mask_arg with _check_mask?
  • think about if it makes sense to rename from mask_{obs,var} to mask:
    • not explicit from param name anymore which dim is masked
    • but explicit through argument (e.g. mask="obs.xy")
    • also good fit for functions that can operate on either axis (sample, aggregate) or allow to mask either or both axes (e.g. pca could be fit on a subset or scale could be called on a subset)

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@codecov

codecov Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.77419% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.92%. Comparing base (a656a33) to head (a2729d8).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/scanpy/get/get.py 94.11% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4333      +/-   ##
==========================================
- Coverage   81.98%   81.92%   -0.06%     
==========================================
  Files         134      134              
  Lines       13235    13027     -208     
==========================================
- Hits        10851    10673     -178     
+ Misses       2384     2354      -30     
Flag Coverage Δ
hatch-test.low-vers 78.80% <83.87%> (-0.27%) ⬇️
hatch-test.pre 81.79% <96.77%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/scanpy/_docs.py 100.00% <100.00%> (ø)
src/scanpy/_settings/presets.py 93.10% <ø> (-0.05%) ⬇️
src/scanpy/_utils/__init__.py 75.57% <100.00%> (ø)
src/scanpy/experimental/pp/_normalization.py 92.75% <100.00%> (-1.93%) ⬇️
src/scanpy/get/_aggregated.py 95.28% <100.00%> (+0.03%) ⬆️
src/scanpy/preprocessing/_docs.py 100.00% <100.00%> (ø)
src/scanpy/preprocessing/_highly_variable_genes.py 94.63% <ø> (ø)
src/scanpy/preprocessing/_pca/__init__.py 90.76% <100.00%> (-0.75%) ⬇️
src/scanpy/preprocessing/_scale.py 100.00% <100.00%> (+10.41%) ⬆️
src/scanpy/preprocessing/_simple.py 90.99% <100.00%> (ø)
... and 3 more

@flying-sheep flying-sheep added this to the 1.13.0 milestone Sep 1, 2026
Comment thread src/scanpy/_settings/presets.py Resolved
Comment thread src/scanpy/_utils/__init__.py Resolved
Comment thread src/scanpy/preprocessing/_scale.py Resolved
Comment thread src/scanpy/preprocessing/_scale.py Resolved
@flying-sheep
flying-sheep merged commit 5f2accb into main Sep 11, 2026
14 checks passed
@flying-sheep
flying-sheep deleted the mask-acc branch September 11, 2026 06:42
Intron7 added a commit to scverse/rapids-singlecell that referenced this pull request Nov 8, 2026
Port scverse/scanpy#4333: pp.pca takes `mask` with anndata.acc references
and deprecates `mask_var`; pca, scale and rank_genes_groups share one
`_mask_arg`, the PCA mask is stored in `.uns` as scanpy stores it, and
ingest reads that form.

Signed-off-by: Intron7 <[email protected]>
Intron7 added a commit to scverse/rapids-singlecell that referenced this pull request Nov 11, 2026
* Adopt scanpy's use/out parameters in pp, tl and get

Match scanpy 1.13 (scverse/scanpy#4359): `use` names where a function
reads from (an anndata.acc accessor or its string form) and `out` where it
writes (False for the default place, True to return the result, an
accessor, or a mapping for functions with several outputs). Functions
with several outputs return a ...Result NamedTuple for out=True and take a
...Out TypedDict. Groupings and covariates take refs such as
A.obs["batch"].

Deprecate layer, obsm, use_rep, use_raw, neighbors_key, obsp, adjacency,
key_added, batch_key, inplace and copy as scanpy does; filter_cells and
filter_genes keep copy.

Signed-off-by: Intron7 <[email protected]>

* Add PR number to release notes

Signed-off-by: Intron7 <[email protected]>

* Fix docs build for the use/out output types

Signed-off-by: Intron7 <[email protected]>

* Match scanpy's calculate_qc_metrics preset default and umap rep

Signed-off-by: Intron7 <[email protected]>

* Fix scanpy-main compat and sparse score_genes with duplicate var_names

Signed-off-by: Intron7 <[email protected]>

* Explain use/out and the calculate_qc_metrics default in the skill

Signed-off-by: Intron7 <[email protected]>

* Rename mask_var/mask_obs to mask in pca, as scanpy does

Port scverse/scanpy#4333: pp.pca takes `mask` with anndata.acc references
and deprecates `mask_var`; pca, scale and rank_genes_groups share one
`_mask_arg`, the PCA mask is stored in `.uns` as scanpy stores it, and
ingest reads that form.

Signed-off-by: Intron7 <[email protected]>

* Fix review findings for use/out

- normalize_total: norm_factor on sparse and dense Dask input; results
  not written back to their source no longer modify it
- anndata 0.12/0.13.0-0.13.2: guard the anndata.acc imports and
  resolve(vec=...), with a compat test that hides anndata.acc
- scale(inplace=False) returns the matrix again
- regress_out: ndarray/Index keys and vectors held on the GPU
- normalize_shifted_clr(inplace=False) rejects a conflicting out
- use=A.obsm["X"] no longer falls back to adata.X
- embedding_density: reject non-obsm use and non-categorical groupby
  for out=True
- mixscape: the PCA recompute rewrites uns as well
- HVG and scrublet with use= no longer rebuild obs_names or copy the
  whole AnnData
- release notes for the normalize_total, neighbors/bbknn and draw_graph
  alignments with scanpy

Signed-off-by: Intron7 <[email protected]>

* Test harmony_integrate with a list of batch accessors

Signed-off-by: Intron7 <[email protected]>

---------

Signed-off-by: Intron7 <[email protected]>
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.

anndata.acc based API for mask/mask_{obs,var}

2 participants