access via `obsm.X_pca` just like `obs.clusters`
I found it confusing that you can access obs/var keys via obs.clusters and var.n_counts, while you can't do that yet with keys from obsm, varm, uns and layers, i.e. it would be very neat to also make these accessible via e.g. obsm.X_pca.
Further, it would be nice to have all layers accessible just like adata.X, i.e. via adata.S if S is in layers. Happy to discuss.
I definitely agree with the first paragraph. Especially with the upcoming .mode things get pretty long:
# as is now
do_things_with(adata.mode['foo'].layer['bar'])
# with .-access
do_things_with(adata.mode.foo.layer.bar)
I’m not sure if we should implement the shortcut and if yes, if for modes or layers or both:
# with .-access and shortcut for modes
do_things_with(adata.foo.layer.bar)
# with .-access and shortcut for layers
do_things_with(adata.mode.foo.bar)
# with .-access and shortcut for both
do_things_with(adata.foo.bar)
The last option has the potential to be pretty confusing I think, and would need some exception being raised if there’s a mode and layer with the same name
Agree. I think having both layers and mode being directly accessible via adata. would be nice, feasible, and not too confusing (as it is called just like adata.X), when having an exception of having mode and layers with the same name.
I'm not a fan of this. I think it get's confusing about what's part of the API, it limits the set of values you can use for naming, and adding attributes can now break peoples scripts. It also provides multiple ways to do the same thing, which is very un-pythonic. Pandas recently removed most columns access via attribute from their documentation, and that's the only library I can think of that does this.
What's the argument pro dynamic attributes? Interactive use what pandas went with, but we'll have tab completion for all the layers, obsm, varm, etc. in the next release anyways.