athena.neighborhood.estimators module

Summary

Functions:

add2uns

infiltration

Compute infiltration score.

interactions

Compute interaction strength between species. This is done by counting the number of interactions (edges in the graph)

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. This is done by counting the number of interactions (edges in the graph)

between pair-wise observation types as encdoded by attr. See notes for more information or the methodology section in the docs.

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.

Notes

classic and histoCAT are python implementations of the corresponding methods pubished by the Bodenmiller lab at UZH. The proportion method is similar to the classic method but normalises the score by the number of edges and is thus bound [0,1].

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. Generalises the infiltration score presented in A Structured Tumor-Immune Microenvironment in Triple Negative Breast Cancer Revealed by Multiplexed Ion Beam Imaging The score comptes a ratio between the number of interactions observed between the observation types specified in interactions1 and interaction2 as \(\frac{\texttt{number of interactions 1}}{\texttt{number of interactions 2}}\). This ratio can be undefined. See notes for more information.

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 in attr of enumerator interaction

  • interaction2 – labels in attr 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:

Notes

The default arguments are replicating the immune infiltration score. However, you can compute any kind of “infiltration” between observation types. The attr argument specifies the column in the obs dataframe which encodes different observation types. interaction{1,2} argument defines between which types the score should be computed.

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

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