scanpy icon indicating copy to clipboard operation
scanpy copied to clipboard

docs: document array type support

Open flying-sheep opened this issue 1 month ago • 8 comments

  • [x] Closes #3892
  • [x] Tests included or not required because:

I double-checked everything in #2578 and mostly winged it for the rest.

Would be nice if one of you could take a look if I mis-specified something.

  • I didn’t check if some flavors of highly_variable_genes supports only CSR. Any idea?
  • I tried to document things that implicitly convert to csr as “not supporting csc”, except when that’s conditional (i.e sc.pp.scale supports CSC if you don’t specify mask_obs, so that’s detailed in mask_obs).

flying-sheep avatar Nov 14 '25 16:11 flying-sheep

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 76.80%. Comparing base (b85d814) to head (c9c352b). :warning: Report is 1 commits behind head on main. :white_check_mark: All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3895      +/-   ##
==========================================
+ Coverage   76.77%   76.80%   +0.03%     
==========================================
  Files         116      117       +1     
  Lines       12398    12440      +42     
==========================================
+ Hits         9518     9554      +36     
- Misses       2880     2886       +6     
Flag Coverage Δ
hatch-test.pre 76.80% <100.00%> (+0.03%) :arrow_up:

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

Files with missing lines Coverage Δ
src/scanpy/_utils/_docs.py 100.00% <100.00%> (ø)
...c/scanpy/experimental/pp/_highly_variable_genes.py 18.44% <ø> (ø)
src/scanpy/get/_aggregated.py 92.78% <ø> (ø)
src/scanpy/neighbors/__init__.py 80.05% <ø> (ø)
src/scanpy/preprocessing/_combat.py 88.46% <ø> (ø)
src/scanpy/preprocessing/_highly_variable_genes.py 94.71% <ø> (ø)
src/scanpy/preprocessing/_normalization.py 94.66% <ø> (ø)
src/scanpy/preprocessing/_pca/__init__.py 90.65% <ø> (ø)
src/scanpy/preprocessing/_qc.py 95.83% <ø> (ø)
src/scanpy/preprocessing/_scale.py 91.20% <ø> (ø)
... and 15 more

... and 1 file with indirect coverage changes

codecov[bot] avatar Nov 14 '25 16:11 codecov[bot]

How hard would it be to make an overview page that lists all functions in a single table?

grst avatar Nov 20 '25 18:11 grst

@flying-sheep I'll try to look tomorrow more closely but I do like @grst's suggestion. That being said, I don't think it should be instead of what is here, this is really cool!

ilan-gold avatar Nov 21 '25 01:11 ilan-gold

Can you draft how that would look like? Tables for something like PCA are already quite big, and I can’t imagine how to lay out one big table in a way that it would be clear what’s going on.

image

flying-sheep avatar Dec 04 '25 14:12 flying-sheep

I had in mind something like this

✅ = supported ❌ = not supported ⚡= supported in dask

Function numpy.ndarray csr_array csr_matrix csc_array csc_matrix
sc.tl.pca ✅⚡ ✅⚡ ✅⚡
sc.tl.tsne
sc.tl.umap ✅⚡
...

grst avatar Dec 04 '25 14:12 grst

@flying-sheep I have not checked how this work or not. But do umap and tsne work with sp_matrix and arrays?

Intron7 avatar Dec 08 '25 09:12 Intron7

Yes! In umap, doing sc.pp.neighbors(adata, use_rep="X") results in X being passed to simplicial_set_embedding, which will do a TruncatedSVD on it.

TSNE calls validate_data(self, X, accept_sparse=["csr", "csc", "coo"], ...) which very likely also means it supports it.

Thanks, thinking like this is exactly the reason I requested your reviews! Could have easily been that I messed this up.

flying-sheep avatar Dec 08 '25 10:12 flying-sheep

The table leads to horizontal scrolling for me

image

Also not sure if the top of the API page is the best place to place it? Maybe even have a dedicated page for it?

grst avatar Dec 09 '25 15:12 grst