tangram.utils.count_cell_annotations

tangram.utils.count_cell_annotations(adata_map, adata_sc, adata_sp, annotation='cell_type', threshold=0.5)

Count cells in a voxel for each annotation.

Parameters
  • adata_map (AnnData) – cell-by-spot AnnData returned by train function.

  • adata_sc (AnnData) – cell-by-gene AnnData.

  • adata_sp (AnnData) – spatial AnnData data used to save the mapping result.

  • annotation (str) – Optional. Cell annotations matrix with shape (number_cells, number_annotations). Default is ‘cell_type’.

  • threshold (float) – Optional. Valid for using with adata_map.obs[‘F_out’] from ‘constrained’ mode mapping. Cell’s probability below this threshold will be dropped. Default is 0.5.

Returns

None. Update spatial AnnData by creating obsm tangram_ct_count field which contains a dataframe that each row is a spot and each column has the cell count for each cell annotation (number_spots, number_annotations).