spatialtis_core.cell_interaction#

Module Contents#

class spatialtis_core.cell_interaction.CellCombs(types: List[str], order: bool = False)#

Profile cell-cell interaction using permutation test

Parameters
  • types – All the type of cells in your research

  • order – bool (False); If False, A->B and A<-B is the same

bootstrap(types: List[str], neighbors: spatialtis_core.types.Neighbors, labels: spatialtis_core.types.Labels, times: int = 1000, pval: float = 0.05, method: str = 'pval') List[Tuple[str, str, float]]#

Bootstrap functions

1.0 means association, -1.0 means avoidance, 0.0 means insignificance.

Parameters
  • types – The type of all the cells

  • neighbors – List of neighbors

  • labels – List of labels

  • times – How many times to perform bootstrap

  • pval – The threshold of p-value

  • method – ‘pval’ or ‘zscore’

Returns

List of tuples, eg.(‘a’, ‘b’, 1.0), the type a and type b has a relationship as association

spatialtis_core.cell_interaction.comb_bootstrap(exp_matrix: numpy.ndarray, markers: List[str], neighbors: spatialtis_core.types.Neighbors, labels: spatialtis_core.types.Labels, pval: float = 0.05, times: int = 1000) List[Tuple[str, str, float]]#

Bootstrap between two types

If you want to test co-localization between protein X and Y, first determine if the cell is X-positive and/or Y-positive. True is considered as positive and will be counted.

Parameters
  • exp_matrix – The expression matrix, each row should be a marker

  • markers – Match to the row of exp_matrix

  • neighbors – List of neighbors

  • labels – List of labels

  • pval – The threshold of p-value

  • times – How many times to perform bootstrap

Returns

The significance between markers List of (marker1, marker2, p-value)

spatialtis_core.cell_interaction.neighbor_components(neighbors: spatialtis_core.types.Neighbors, labels: spatialtis_core.types.Labels, types: List[str])#

Compute the number of different cells at neighbors

Parameters
  • neighbors – The neighbors dict

  • labels – Integer to label points

  • types – A list of types match to points

Returns

can be used to construct dataframe

Return type

(header, data)