BodenmillerGroup / steinbock

A toolkit for processing multiplexed tissue images
https://bodenmillergroup.github.io/steinbock
MIT License
49 stars 14 forks source link

Concatenated anndata export does not retain neighborhood information #196

Open jwindhager opened 1 year ago

jwindhager commented 1 year ago

As reported by @cavenel, when running steinbock export anndata in concatenation mode (default) and with --neighbors, the resulting multi-image anndata object does not contain the spatial cell graphs in obsp. This is because anndata.concat does not concatenate obsp by default, see here:

Note that we concatenated along the observations by default, and that most elements aligned to the observations were concatenated as well. A notable exception is obsp, which can be re-enabled with the pairwise keyword argument. This is because it’s not obvious that combining graphs or distance matrices padded with 0s is particularly useful, and may be unintuitive.

It would be good either to enable obsp concatenation (see quote above), or to not allow the --neighbors argument in concatenation mode (i.e., print an error message).