spatialHeterogeneity.neighborhood.estimators module

Summary

Functions:

add2uns

infiltration

Compute infiltration score.

interactions

Compute interaction strength between species.

ripleysK

Compute Ripley’s K as implemented by 1.

Reference

interactions(so, spl, attr, mode='classic', prediction_type='observation', *, n_permutations=100, random_seed=None, alpha=0.01, try_load=True, key_added=None, graph_key='knn', inplace=True)[source]

Compute interaction strength between species.

Parameters
  • so – SpatialOmics instance

  • spl (str) – Spl for which to compute the metric

  • attr (str) – Categorical feature in SpatialOmics.obs to use for the grouping

  • mode (str) – One of {classic, histoCAT, proportion}, see notes

  • n_permutations (int) – Number of permutations to compute p-values and the interactions strength score (mode diff)

  • random_seed – Random seed for permutations

  • alpha (float) – Threshold for significance

  • prediction_type (str) – One of {observation, pvalue, diff}, see Notes

  • try_load (bool) – load pre-computed permutation results if available

  • key_added (Optional[str]) – Key added to SpatialOmics.uns[spl][metric][key_added]

  • graph_key (str) – Specifies the graph representation to use in so.G[spl] if local=True.

  • inplace (bool) – Whether to add the metric to the current SpatialOmics instance or to return a new one.

Returns:

Return type

None

infiltration(so, spl, attr, *, interaction1=('tumor', 'immune'), interaction2=('immune', 'immune'), add_key='infiltration', inplace=True, graph_key='knn', local=False)[source]

Compute infiltration score.

Parameters
  • so – SpatialOmics instance

  • spl (str) – Spl for which to compute the metric

  • attr (str) – Categorical feature in SpatialOmics.obs to use for the grouping

  • interaction1 – labels of enumerator interaction

  • interaction2 – labels of denominator interaction

  • key_added – Key added to SpatialOmics.uns[spl][metric][key_added]

  • inplace – Whether to add the metric to the current SpatialOmics instance or to return a new one.

  • graph_key – Specifies the graph representation to use in so.G[spl] if local=True.

Returns:

Return type

None

ripleysK(so, spl, attr, id, *, mode='K', radii=None, correction='ripley', inplace=True, key_added=None)[source]

Compute Ripley’s K as implemented by 1.

Parameters
  • so – SpatialOmics instance

  • spl (str) – Spl for which to compute the metric

  • attr (str) – Categorical feature in SpatialOmics.obs to use for the grouping

  • id – The category in the categorical feature attr, for which Ripley’s K should be computed

  • mode – {K, csr-deviation}. If K, Ripley’s K is estimated, with csr-deviation the deviation from a poission process is computed.

  • radii – List of radiis for which Ripley’s K is computed

  • correction – Correction method to use to correct for boarder effects, see [1].

  • inplace – Whether to add the metric to the current SpatialOmics instance or to return a new one.

  • key_added – Key added to SpatialOmics.uns[spl][metric][key_added]

Returns

Ripley’s K estimates

References

1(1,2)

https://docs.astropy.org/en/stable/stats/ripley.html

add2uns(so, res, spl, parent_key, key_added)[source]