Repository navigation
Adopt scanpy's use/out parameters - #882
Merged
Merged
Conversation
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]>
Signed-off-by: Intron7 <[email protected]>
Signed-off-by: Intron7 <[email protected]>
Signed-off-by: Intron7 <[email protected]>
Signed-off-by: Intron7 <[email protected]>
Signed-off-by: Intron7 <[email protected]>
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]>
- 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]>
flying-sheep
approved these changes
Nov 10, 2026
flying-sheep
left a comment
Member
There was a problem hiding this comment.
Surface-level this looks good, I like that you converted the non-scanpy functions too. Of course I couldn’t look into the details, it’s too much.
| *, | ||
| batch_key: str | None = None, | ||
| use_rep: str | None = None, | ||
| batches: AdRef | str | None = None, |
Member
There was a problem hiding this comment.
this is called batch in other APIs. might be that I introduced the same inconsistency in scanpy.
Member
There was a problem hiding this comment.
yup I did, fixing now! scverse/scanpy#4505
good thing I spotted it here
Signed-off-by: Intron7 <[email protected]>
Intron7
added a commit
that referenced
this pull request
Nov 11, 2026
After the rebase onto #882 as merged: - import `A` through `pytest.importorskip("anndata.acc")` in the seven test modules this branch adds it to, as the other tests do since #882 - test_pca_deprecated_params: assert the `mask_var` deprecation warning of the check added with the `mask` rename Signed-off-by: Intron7 <[email protected]>
Zethson
added a commit
that referenced
this pull request
Nov 15, 2026
Bumps notebooks 0b059a3 -> f2a9c13, pulling in scverse/rapids-singlecell-tutorials#13, #14 and #15: explicit read_h5ad readers, mask_var=None in brain_1M, read_elem_lazy without the anndata<0.12 gate, rsc.gr.spatial_neighbors_grid in 04_squidpy (re-executed), and removal of a broken trailing cell in 03_decoupler. The notebooks target the released 0.18.1 API; the scanpy 1.13 use/out migration from #882 is not applied to them yet.
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.
This matches scanpy 1.13's switch to
use/out(scverse/scanpy#4359) for every scanpy-mirrored function inpp,tlandget, plus the rsc-only functions that take the same kinds of arguments (dsb,wnn,harmony_integrate,kmeans, …).usenames where a function reads from: ananndata.accaccessor (A.layers["counts"],A.obsm["pca"], a graphA.obsp["nn"]) or its string form ("layers.counts").outnames where it writes:Falsefor the default place,Trueto return the result, an accessor, or for functions with several outputs a mapping of only the outputs to write. A single accessor names the secondary outputs after the primary one, e.g.neighbors(out=A.obsp["nn"])writesnn,nn_distancesanduns["nn"].…ResultNamedTuple forout=Trueand take a…OutTypedDict (NormalizeTotalResult,QcMetricsResult,ScaleResult,PcaResult,ScrubletResult,NeighborsResult,WnnResult,CellCycleResult); they are exported fromrsc.pp/rsc.tland listed in the API docs.A.obs["batch"](batch,covariates).scanpy-v1, stringbatchvalues ofharmony_integrateare obs column names, as in scanpy (compat=True); underscanpy-v2-previewthey are resolved as accessors.layer,obsm,use_rep,use_raw,neighbors_key,obsp,adjacency,key_added,batch_key,inplaceandcopyare deprecated like in scanpy and keep working with aFutureWarning;filter_cells/filter_geneskeepcopy.The shared helpers live in
get/_out.py, a trimmed port of scanpy'sget/_use.pyandget/_out.py.Behaviour changes:
calculate_qc_metricsnow follows the preset like scanpy: it returns the metrics underscanpy-v1(scanpy's oldinplace=Falsedefault) and writes them underscanpy-v2-preview. Passout=Falseto keep writing them.umapaccepts scanpy'srep. cuML lays out the graph's connected components from the graph alone, so it is not read.key_added=Noneunder the v2 preset now writes to the v2 keys, as in scanpy.scrubletfills NaN for cells its internal filter removed, instead of raising aKeyErrorin batched runs.Tests: the non-dask suite passes apart from failures that also happen on main (
test_gpu_lda_matches_sklearn, decoupler gsea). The dask tests match main file by file.