snap-stanford / SATURN

MIT License
108 stars 17 forks source link

How to preserve all the metadata information in the Anndata from two species to the Final AnnData after integration? #53

Closed vishnums007 closed 6 months ago

vishnums007 commented 6 months ago

Hi, I would like to conserve few more information from the metadata of individual anndatas to the final AnnData after integration of both species. For e.g. Before integration Anndata obs had the following information

After loading the anndata zebrafish View of AnnData object with n_obs × n_vars = 81893 × 22744 obs: 'orig.ident', 'nCount_RNA', 'nFeature_RNA', 'percent.mt', 'nCount_SCT', 'nFeature_SCT', 'Timepoint', 'integrated_snn_res.0.4', 'seurat_clusters', 'pANN_0.25_0.29_4310', 'DF.classifications_0.25_0.29_4310', 'Coarse.Cluster.ID', 'Fine.Cluster.ID', 'Fine.Cluster.ID.Timepoint', 'Coarse.Cluster.ID.Timepoint', 'cell_type', 'species', 'species_type_label', 'truth_labels', 'ref_labels' var: 'features' After loading the anndata mouse View of AnnData object with n_obs × n_vars = 66428 × 17097 obs: 'orig.ident', 'nCount_RNA', 'nFeature_RNA', 'percent.mt', 'nCount_SCT', 'nFeature_SCT', 'Timepoint', 'integrated_snn_res.0.1', 'seurat_clusters', 'cell_type', 'merge.ident', 'species', 'species_type_label', 'truth_labels', 'ref_labels'

However, in the final anndata after saturn training, I have only the following information:

AnnData object with n_obs × n_vars = 148321 × 256 obs: 'labels', 'labels2', 'ref_labels', 'species' obsm: 'macrogenes'

I wanted to atleast include the Timepoint information in the final anndata. Is it possible?

My whole analysis code is given here

Thanks in advance, Vishnu

Yanay1 commented 6 months ago

So we don't keep the metadata from the anndata besides those columns, since it might not be common, but you can add it back to the final object since the cells from each species are maintained in the same order as the anndata they come from, so you can safely match them to that metadata from the original object.

vishnums007 commented 6 months ago

Okay, thank you for the swift response!