The spillover metrics (sp) accessor

The spillover metrics (sp) accessor#

The spillover metrics accessor provides metrics to compare the mean spatial distribution of transcripts in relation to the centroid and the segmented outline of the cell.

segtraq.sp.spillover_metrics.centroid_mean_coord_diff(sdata: SpatialData, feature, table_key: str = 'table', gene_key: str = 'feature_name', transcript_key: str = 'transcripts', cell_key: str = 'cell_id', coordinate_key: list = ['x', 'y'], shape_key: str = 'cell_boundaries', centroid_key: list = ['centroid_x', 'centroid_y']) DataFrame#

Calculates the euclidean distance between the mean x,y coordinate of the transcripts indicated by the feature variable and the centroid of each cell. This

Parameters:
  • sdata (sd.SpatialData) – The SpatialData object containing spatial transcriptomics data.

  • feature (str) – String indicating the feature/gene to calculate the mean transcript coordiantes on

  • table_key (str, optional) – The key to access the AnnData table from sdata.tables. Default is “table”.

  • gene_key (str, optional) – The key to access gene names within the transcript data. Default is “feature_name”.

  • transcript_key (str, optional) – The key in the transcript table indicating transcript identifiers. Default is “transcripts”.

  • cell_key (str, optional) – The key in the table indicating cell identifiers. Default is “cell_id”.

  • coordinate_key (list, optional) – The keys to access the coordinates from the sdata transcript_key table. Defaults are “x” and “y”

  • shape_key (str, optional) – The key in sdata.shapes specifying the geometry column. Default is “cell_boundaries”.

  • centroid_key (list, optional) – The keys to access the centroids in the sdata.shapes slot. Defaults are “centroid_x” and “centroid_y”

Returns:

A DataFrame with columns [“centroid_x, “centroid_y”, “x”, “y”, “distance”], where “distance” is the euclidean distance between the coordinates `[“centroid_x, “centroid_y”] and [“x”, “y”].

Return type:

pd.DataFrame

Notes

Requires that the input AnnData table contains a “cell_area” column in .obs.

segtraq.sp.spillover_metrics.distance_to_membrane(sdata: SpatialData, feature, table_key: str = 'table', gene_key: str = 'feature_name', transcript_key: str = 'transcripts', cell_key: str = 'cell_id')#

Calculates the mean distance of the transcript of a feature of interest to the outline of the cell segmentation

Parameters:
  • sdata (sd.SpatialData) – The SpatialData object containing spatial transcriptomics data.

  • feature (str) – String indicating the feature/gene to calculate the mean transcript coordiantes on

  • table_key (str, optional) – The key to access the AnnData table from sdata.tables. Default is “table”.

  • gene_key (str, optional) – The key to access gene names within the transcript data. Default is “feature_name”.

  • transcript_key (str, optional) – The key in the transcript table indicating transcript identifiers. Default is “transcripts”.

  • cell_key (str, optional) – The key in the table indicating cell identifiers. Default is “cell_id”.

Returns:

A DataFrame with columns [“distance_to_outline_inverse”, “distance_to_outline” and “cell_area”]

Return type:

pd.DataFrame

Notes

Requires that the input AnnData table contains a “cell_area” column in .obs.