scverse / anndata

Annotated data.
http://anndata.readthedocs.io
BSD 3-Clause "New" or "Revised" License
570 stars 152 forks source link

Adding multiple "visits" (clinical data) to a single .obs #1617

Open Rafael-Silva-Oliveira opened 1 month ago

Rafael-Silva-Oliveira commented 1 month ago

Hello

I'm trying to add some clinical data to each of 75 individual samples (.obs) from bulk RNA sequencing. However, each individual sample can have 3-5 visits (treatments, etc) and I can't quite "expand" from 75 samples to 190+ samples as it throws an error, since the original adata is of size (75, 42000)

For example:

Say we have an ID called R1_70 and this ID (patient) had 5 visits and each visit has new information (Treatment type, visit date, etc). How can I add this and associate it with R1_70 on my .obs without expanding over the original size of 75 samples? One hot encoding wouldn't work here. Maybe if I "explode" each column to have "col_A_visit_1","col_B_visit_2", etc, but then this would make it quite awkward to run DEG, functional, analysis, etc with tools like scanpy or decoupler.

Any help on how to do this is welcome!

Thanks