basic support for AnnData accessors#147
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #147 +/- ##
==========================================
+ Coverage 91.38% 91.48% +0.10%
==========================================
Files 10 10
Lines 1601 1620 +19
==========================================
+ Hits 1463 1482 +19
Misses 138 138
🚀 New features to boost your workflow:
|
c578182 to
ae0ede1
Compare
2e81f0d to
a5e25fd
Compare
this should keep scanpy plotting working with MuData objects
a5e25fd to
ac1fbd2
Compare
ilan-gold
left a comment
There was a problem hiding this comment.
Let's wait for @flying-sheep to get back to review this. There may be a cleaner way to this aside from violating types
|
|
||
| if isinstance(index, AdRef): | ||
| try: | ||
| return index.acc.get(self, index.idx) |
There was a problem hiding this comment.
So this relies on the fact that MuData carries an obs, var etc. but does not follow the type?
https://anndata.readthedocs.io/en/latest/generated/anndata.acc.RefAcc.html#anndata.acc.RefAcc.get
There was a problem hiding this comment.
Maybe we should use a protocol?
There was a problem hiding this comment.
So this relies on the fact that MuData carries an obs, var etc. but does not follow the type?
Exactly.
There was a problem hiding this comment.
There may be a cleaner way to this aside from violating types.
You're violating types every time you pass a MuData to scanpy, everything there is typed as AnnData. Perhaps a protocol would indeed make sense.
There was a problem hiding this comment.
You're violating types every time you pass a MuData to scanpy, everything there is typed as AnnData. Perhaps a protocol would indeed make sense.
But maybe there's a way we can stop doing this now that scanpy is being redesigned - perhaps with a view to MuData.
The main point of this is to still be able to pass MuData objects to scanpy's plotting functions. This is currently possible due to MuData's implementation of
obs_vectorandvar_vector, but if I understand the scanpy changes correctly (e.g. here) this will stop working as soon as anndata 0.13 is released.The logic is based on the current
_attr_vectorimplementation, which will go away at some point whenobs_vectorandvar_vectorare removed.I'd appreciate some feedback on where else scanpy has switched to accessors. For example, it is currently possible to run
sc.pp.neighborsandsc.tl.umapon a MuData object. Have these also switched to using accessors to access.obsm/obsp?