anndata icon indicating copy to clipboard operation
anndata copied to clipboard

Initial draft of AnnData HTML repr

Open gtca opened this issue 3 years ago • 3 comments

This is a draft to address #675. As with mudata, it is collapsable — check out e.g. this notebook with mudata.

Maybe we can iterate on an implementation of it, and then we'll refactor the code in mudata to re-use AnnData representation inside the MuData representation.

Currently both mudata and muon have a config manager, which is used in mudata for collapse/expand settings. Not sure if we want to introduce it in anndata as the setting is still somewhat reachable:

from anndata._core.repr import repr_html
from IPython.core.display import HTML
display_html = lambda adata, expand: HTML(repr_html(adata, expand=0b11))

HTML(repr_html(adata, 0b11))

I have also just noticed there was a html-repr branch a while ago, maybe we can drag over some ideas with aligned mappings from there, — or vice versa.

gtca avatar Jan 31 '22 16:01 gtca

Codecov Report

Merging #694 (137ee91) into master (555f546) will decrease coverage by 1.99%. The diff coverage is 10.56%.

@@            Coverage Diff             @@
##           master     #694      +/-   ##
==========================================
- Coverage   83.14%   81.15%   -2.00%     
==========================================
  Files          34       35       +1     
  Lines        4403     4526     +123     
==========================================
+ Hits         3661     3673      +12     
- Misses        742      853     +111     
Impacted Files Coverage Δ
anndata/_core/repr.py 9.16% <9.16%> (ø)
anndata/_core/anndata.py 83.35% <66.66%> (-0.07%) :arrow_down:
anndata/_core/merge.py 93.15% <0.00%> (-0.30%) :arrow_down:

codecov[bot] avatar Jan 31 '22 16:01 codecov[bot]

Thanks for opening this! Really excited to get this added.

Examples

This is more a point for tracking of this PR. Could you share examples of what this looks like embedded in the issue? I'd like to be able to easily track changes to what this looks like, and maybe we could just agree now including an image or stable jsfiddle or something?

Also, do you have an example for how dataframes are displayed? I don't think there was one in the linked docs.

Let's start one here: https://jsfiddle.net/325vxk6u/.

The rest makes sense as well, will get back to you with the code refactored.


On the config, I was wondering if we could maybe normalize on a single config for scverse tools? Like a scverse.toml?

As it's a setting adjustable by the user, we would still need to add a config manager to anndata – unless I'm missing the point.

gtca avatar Jan 31 '22 17:01 gtca

As it's a setting adjustable by the user, we would still need to add a config manager to anndata – unless I'm missing the point.

It was a bit of a tangent, but I was thinking we could have either a common config manager or at least a base class. Would be a bit like how bioconductor does it

Plus should be easy enough with pydantic

ivirshup avatar Jan 31 '22 19:01 ivirshup