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

Question about 'tangram_ct_pred' results for final cell type annotation call #129

Open
KunHHE opened this issue Jan 15, 2025 · 0 comments
Open

Comments

@KunHHE
Copy link

KunHHE commented Jan 15, 2025

Hi @ziqlu0722, for Tangram run finished and got 'tangram_ct_pred', I don't feel confident for the downstream analysis step; can you help me a little? Thanks!

For example, should I do normalization for the probability value and then project to cell types? like using the scripts below:

probabilities = np.array(comb_adata.obsm['tangram_pred'])
n_voxels = probabilities.shape[0]
n_cell_types = probabilities.shape[1]

predicted_cell_types = [XXXX cell types
]
assert len(predicted_cell_types) == n_cell_types, f"Mismatch: {len(predicted_cell_types)} vs {n_cell_types}"
sampled_cell_types = []
for voxel_idx in range(n_voxels):
voxel_probabilities = probabilities[voxel_idx, :]
voxel_probabilities /= np.sum(voxel_probabilities)
sampled_cell_type_idx = np.random.choice(n_cell_types, p=voxel_probabilities)
sampled_cell_type = predicted_cell_types[sampled_cell_type_idx]
sampled_cell_types.append(sampled_cell_type)
comb_adata.obs['sampled_cell_type'] = sampled_cell_types

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

1 participant