scverse / spatialdata

An open and interoperable data framework for spatial omics data
https://spatialdata.scverse.org/
BSD 3-Clause "New" or "Revised" License
235 stars 43 forks source link

Extra AnnData in Table? #270

Closed AdemSaglamRB closed 1 year ago

AdemSaglamRB commented 1 year ago

Hello,

For multi-omics data, is it possible to add more tables to Table in a spatialdata object?

LucaMarconato commented 1 year ago

Hi @AdemSaglamRB 😊

When we designed the package we had extensive discussions on having one versus multiple tables (see for example some notes here https://github.com/scverse/spatialdata/issues/43). For instance one disadvantage of not having multiple tables in the same object is that one would have to use separate objects to represent multimodal data, but in turn one advantage is that the APIs for data manipulation are generally simpler to implement.

After balancing the pros and cons we decided to support single tables in our first release, collect feedbacks from the users, and see how to relax this limitation.

To represent multiple modalities you can go for one of the following:

Our preferred ways are the first two, but we recognize that none of these is optimal and we are exploring alternatives. To this regard, it would be appreciated if you could share an outline of your use cases (which multi-modal data you want to store and which types of cross-modality operations/manipulations you want to perform).

AdemSaglamRB commented 1 year ago

Hi @LucaMarconato ,

Thank you for your answer. Using several SpatialData is definitely the easiest way to go.

The multi-omics data I have been dealing with encompass RNA, protein and ATAC-seq information. These have always the same number of cells but different number of features. The count matrix for each will look like this:

Because of the different size of the count matrices, having different layers in AnnData won't work as each layer is required to have the same sizes.

On the other side, the solution I was thinking about was that the sdata.table could hold a MuData object rather than AnnData. I don't know if this is easy or complicated to implement though.

Out of curiosity, how do you use multiple AnnData table to replace the sdata.table slot?

Thank you for your help.

LucaMarconato commented 1 year ago

Thank you for the explanation of your use case, we will consider this feedback when discussion the new table designs. Having a MuData object instead than an AnnData object would work in this case, and the implementation is feasible, but there would be some drawbacks:

AdemSaglamRB commented 1 year ago

Thank you for your answer @LucaMarconato . Then we can close this thread.