Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2290 +/- ##
==========================================
- Coverage 86.78% 85.24% -1.55%
==========================================
Files 46 49 +3
Lines 7365 7785 +420
==========================================
+ Hits 6392 6636 +244
- Misses 973 1149 +176
|
Co-authored-by: Ilan Gold <ilanbassgold@gmail.com>
Co-authored-by: Ilan Gold <ilanbassgold@gmail.com>
|
Yay! I thiiiiink this is cool and exciting, but it's written at a deeper level of abstraction than I can make easy sense of, and that makes me unsure.. :) is there a place where I can read what the user level interface will be for the thing this is working toward? I'd love to provide comment on the user level API 🙏🏻 Maybe to cut to the chase: how do you envision this will allow someone to color a thanks! Also pls feel welcome to direct me elsewhere |
|
Don’t worry! While there are quite some possible usage examples strewn throughout this PR, of course the anndata-plot/hv-anndata/scanpy APIs will be documented with more focused examples. There is currently a prototype for the new scanpy plotting here, but beware as it doesn’t use the final accessor API as defined in this PR. So to answer your questions:
probably one of these import scanpy as sc
from hv_anndata import A # maybe this will also live on `sc`, idk yet
sc.pl.scatter(adata, A.obsm["umap"], color=A.obsm["pca"][:, 2]).opts(cmap="tab10")
# or more explicitly
sc.pl.scatter(adata, A.obsm["umap"][:, [0, 1]], color=A.obsm["pca"][:, 2]).opts(cmap="tab10")
probably just replace the color=[A.obs["leiden"], *A.obsm["pca"][:, [0, 1, 2]]] |
|
@patcon Check out our latest docs: https://anndata.readthedocs.io/en/latest/accessors.html which point at the |
|
Nice! Thanks! I'll probably add my own syntactic sugar, but this will make it really simple :) sc.pl.embedding(adata, basis="umap", color="X_pca[2]")
sc.pl.emvedding(adata, basis="umap", color=["leiden", "X_pca[0, 1, 2]"])I have found it quite easy to wrap scanpy and have the scripts be quite legible to new coders at a weekly event I host, especially with some visuals of the data structure. The above was what I felt seemed most legible -- but I can always do a thin wrapper with the excellent code you've created 🙏🏻 |
|
Don’t make your own, there is already a shortcut syntax: https://anndata.readthedocs.io/en/latest/generated/anndata.acc.AdAcc.html#anndata.acc.AdAcc.resolve If you want to extend it or think it could be better, please present improvements to the design in an issue before we release 0.13, then we can still change it. |
User API design
AdPathinstances by descending into a central accessor constantA:anndata/tests/test_accessors.py
Lines 25 to 42 in 61fc920
AdPathinstance, e.g. to figure out which axes the resulting vector spans:anndata/tests/test_accessors.py
Lines 101 to 107 in 61fc920
AdPathinstance to extract a vector (see 1. for examples)subclassing
… is a direct goal of this, as people should be able to use
AdPathsubclasses. This means thatAdPathAPI is minimal and inspection can be done through.acc(could be even more minimal by just putting it all into a container?):anndata/src/anndata/acc/__init__.py
Lines 56 to 57 in 61fc920
anndata/src/anndata/acc/__init__.py
Lines 63 to 64 in 61fc920
AdAccconstant that produces your ownAdPathsubclass:anndata/src/anndata/acc/__init__.py
Line 415 in 61fc920
VecAcc.__getitem__to get anAdPathor a list of them. In that process,__getitem__callsprocess_idxwhich verifies and simplifies the indexaxes,__repr__, andidx_reprget called too to validate things workAdPathcan be used, which basically just delegates toVecAcc’saxes,__repr__,idx_repr, and__call__So in the end everything except for
__call__is validated, i.e.VecAcc.__getitem__raises exceptions on misuseanndata/src/anndata/acc/__init__.py
Lines 101 to 119 in 61fc920
TODO:
Especially since we already call these accessors! Instance namespaces (
adata.custom) #1869__contains__so it doesn’t try to access the arrayfrom_json/to_json)__dir__)