spamosaic.build_graph.remove_outlier

spamosaic.build_graph.remove_outlier(mnn_set, ad1, ad2, contamination='auto')[source]

Filter spatial outliers from an MNN pair set using Isolation Forest.

A feature matrix is built from the concatenated spatial coordinates of both cells and their differences. Pairs predicted as outliers (label -1) are removed.

Parameters:
  • mnn_set (set of tuple of str) – Set of MNN barcode pairs (cell_id_1, cell_id_2).

  • ad1 (AnnData) – Dataset of the first cell; must contain .obsm['spatial'].

  • ad2 (AnnData) – Dataset of the second cell; must contain .obsm['spatial'].

  • contamination ({'auto', float}, optional) – Expected outlier fraction; passed to sklearn.ensemble.IsolationForest.

Returns:

Filtered set with spatial outliers removed.

Return type:

set of tuple of str