Assign cell label to each spot using DestVI

Good day!

I am using DestVI to deconvolve Visium data, and after obtaining the proportions of cell types per spot, would like to assign the highest score to each spot to perform quick labeling of the spatial data. Do you have any suggestions on how I can achieve this, please?

Thanks in advance!

So the get_proportions method of the model will give you a dataframe of cells by cell types.

st_adata.obsm["proportions"] = st_model.get_proportions()

You can use this pandas function to quickly convert to max proportion assignment

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.idxmax.html

st_adata.obs["hard_assign"]  = st_adata.obsm["proportions"].idxmax(1)

Thank you very much!