Statistic

cell_components

spatialtis.cell_components(adata, groupby=None, type_key=None, export=True, export_key=None, return_df=False)[source]

Count the proportion of each types of cells in each group

Parameters
  • adataAnnData object to perform analysis

  • groupby – How your experiments data grouped, (Default: spatialtis.CONFIG.EXP_OBS)

  • type_key – The key to store cell types in AnnData.obs (Default: spatialtis.CONFIG.CELL_TYPE_KEY)

  • export – Whether export the result to AnnData.uns

  • export_key – The name of key used to stored the exported result

  • return_df – Whether to return the result dataframe

cell_co_occurrence

spatialtis.cell_co_occurrence(adata, groupby=None, threshold=50, pval=0.01, type_key=None, export=True, export_key=None, return_df=False)[source]

The likelihood of two type of cells occur simultaneously in a ROI

Using chi-square test to determine the significance of co-occurrence.

Parameters
  • adataAnnData object to perform analysis

  • groupby – How your experiments data grouped, (Default: spatialtis.CONFIG.EXP_OBS)

  • threshold – The threshold value (number of cells) determines the presence/absence of a cell type in ROI

  • pval – The p-value threshold to determine significance

  • type_key – The key to store cell types in AnnData.obs (Default: spatialtis.CONFIG.CELL_TYPE_KEY)

  • export – Whether export the result to AnnData.uns

  • export_key – The name of key used to stored the exported result

  • return_df – Whether to return the result dataframe

cell_density

spatialtis.cell_density(adata, groupby=None, size=None, ratio=1.0, type_key=None, centroid_key=None, export=True, export_key=None, return_df=False)[source]

Calculating cell density in each ROI

Parameters
  • adataAnnData object to perform analysis

  • groupby – How your experiments data grouped, (Default: spatialtis.CONFIG.EXP_OBS)

  • size – The size of each ROI. If some ROI is different, please specific each ROI size in a list, the order must follow the index order in AnnData object; If None, it will automatically computed the area of every ROI;

  • ratio – The ratio between 1 pixel and real size, default is 1.0; For example, if your density unit is n cells/mm^2, your resolution is 1μm, then you should set the ratio as 0.001, 1 pixels represent 0.001mm length.

  • type_key – The key to store cell types in AnnData.obs (Default: spatialtis.CONFIG.CELL_TYPE_KEY)

  • centroid_key – The key to store cell centroid in AnnData.obs (Default: spatialtis.CONFIG.CENTROID_KEY)

  • export – Whether export the result to AnnData.uns

  • export_key – The name of key used to stored the exported result

  • return_df – Whether to return the result dataframe

cell_morphology

spatialtis.cell_morphology(adata, groupby=None, metric_key=None, type_key=None, export=True, export_key=None, return_df=False)[source]

Cell morphology variation between different groups

Parameters
  • adataAnnData object to perform analysis

  • groupby – How your experiments data grouped, (Default: spatialtis.CONFIG.EXP_OBS)

  • metric_key – {metric_key}

  • type_key – The key to store cell types in AnnData.obs (Default: spatialtis.CONFIG.CELL_TYPE_KEY)

  • export – Whether export the result to AnnData.uns

  • export_key – The name of key used to stored the exported result

  • return_df – Whether to return the result dataframe