Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpretation of tangram_ct_pred #112

Open
abhishekmaj08 opened this issue Jan 12, 2024 · 2 comments
Open

Interpretation of tangram_ct_pred #112

abhishekmaj08 opened this issue Jan 12, 2024 · 2 comments

Comments

@abhishekmaj08
Copy link

Greetings,

I am using Tangram to annotate my spatial data (10X) using single cell data. I would like to better understand the output of project_cell_annotations().

It says “INFO:root:spatial prediction dataframe is saved in obsm tangram_ct_pred of the spatial AnnData.”

I looked at the tangram_ct_pred matrix. It is a voxel X annotation matrix. I would like to understand each entry in the matrix. From the values, it does not seem like probability value ( there are values > 2). So is it some kind of score? What is its scale. How do I convert each row in to a set of probability values over the different annotations for each individual cell (each row sum = 1)? Or like a percentage composition set of values for each cell (each row sum = 1). How to best interpret values?

@gaddamshreya1
Copy link
Collaborator

Hi @abhishekmaj08, thank you for your patience!! More importantly, thank you for your interest in Tangram.

project_cell_annotations is a method which leads to the creation of tangram_ct_pred dataframe inobsm which transfers cell annotations onto to space using the mapping matrix. You are right, these aren't probability values. When we take a look at this method, we can see that tangram_ct_pred is a dot product between mapping matrix.T(voxel x cell) and one hot encoding of cell types across all cells in the single cell data.

df = one_hot_encoding(adata_map.obs[annotation])
tangram_ct_pred = ad_map.X.T @ df

The idea behind this dataframe to support plotting cell type annotations in space in case of a soft assignment mapping. The tangram_ct_pred is clipped and normalized and then these values become the proportion of a certain cell type in each spot.

May I ask: are you trying to compute out the percentage of each cell type within each voxel? or like assign a single cell type to each voxel? Because for either of these tasks I would recommend using the mapping matrix which is the probability values of assigning each cell to a voxel.

I hope this explanation is useful to you! Otherwise, please let me know. I'm happy to help :)

@Li-ZhiD
Copy link

Li-ZhiD commented May 23, 2024

Hi,
I would like to know how to assign a cell type to each spot. Would using the maximum value in tangram_ct_pred to determine the cell type for each spot be suitable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants