Dear Scanpy team,
I would like to ask you a question about computing the distances between different cell types. I would like to get the numerical estimate of how close cells of a particular type are to each other. For example, I have cells that come from different labs and would like to estimate the gene expression similarities between them for all genes, or at least for highly variable ones.
One solution could be to compute the dim. reduced representation of data and then compute the distances.
import scanpy as sc
adata.layers[“counts”] = adata.X.copy() # preserve the counts
sc.pp.normalize_total(adata, target_sum=1e4, exclude_highly_expressed=True)
adata.raw = adata #freeze the state in
sc.pp.highly_variable_genes(adata, n_top_genes=2000, subset=False, layer=“counts”, flavor=“seurat_v3”)
My question is, how could I compute the median distance between cells that have different observations. For example, I have cells with obs[‘cell_type’]==‘type_1’ and obs[‘cell_type’]==‘type_2’. How could I compare the distance between type_1 and type_2 cells?