spatialHeterogeneity.plotting.visualization module¶
Summary¶
Functions:
Plot challnels. |
|
Return the cmap and cmap labels for a given attribute if available, else a default |
|
Visualises a heatmap of the featuer intensity. |
|
Visualise interaction results. |
|
Starts interactive Napari viewer to visualise raw images |
|
Plot results |
|
Visualisation of samples. |
Reference¶
-
spatial(so, spl, attr, *, mode='scatter', node_size=4, coordinate_keys=['x', 'y'], mask_key='cellmasks', graph_key='knn', edges=False, edge_width=0.5, edge_color='black', edge_zorder=2, background_color='white', ax=None, norm=None, set_title=True, cmap=None, cmap_labels=None, cbar=True, cbar_title=True, show=True, save=None, tight_layout=True)[source]¶ Visualisation of samples.
- Parameters
so – SpatialOmics instance
spl (
str) – sample to visualiseattr (
str) – feature to visualisemode (
str) – {scatter, mask}. In scatter mode, observations are represented by their centroid, in mask mode by their actual segmentation masknode_size (
float) – size of the node when plotting the graph representationcoordinate_keys (
list) – column names in SpatialOmics.obs[spl] that indicates the x and y coordinatesmask_key (
str) – key for the segmentation masks when in mask modegraph_key (
str) – which graph representation to useedges (
bool) – whether to plot the graph or notedge_width (
float) – width of edgesedge_color (
str) – color of edges as stringedge_zorder (
int) – z-order of edgesbackground_color (
str) – background color of plotax (
Optional[Axes]) – axes object in which to plotnorm – normalisation instance to normalise the values of attr
set_title (
bool) – title of plotcmap – colormap to use
cmap_labels (
Optional[list]) – colormap labels to usecbar (
bool) – whether to plot a colorbar or notcbar_title (
bool) – whether to plot the attr name as title of the colorbarshow (
bool) – whether to show the plot or notsave (
Optional[str]) – path to the file in which the plot is savedtight_layout (
bool) – whether to apply tight_layout or not.
Returns:
-
napari_viewer(so, spl, attrs, censor=0.95, add_masks='cellmasks', attrs_key='target', index_key='fullstack_index')[source]¶ Starts interactive Napari viewer to visualise raw images
- Parameters
so – SpatialOmics instance
spl (
str) – sample to visualiseattrs (
list) – list of attributes to add as channels to the viewercensor (
float) – percentil to use to censore pixle values in the raw imagesadd_masks – segmentation masks to add as channels to the viewer
Returns:
-
channel(so, spl, attrs, ax=None, colors=None, censor=None, show=True)[source]¶ Plot challnels. Decreapted, will be removed.
- Parameters
so –
spl (
str) –attrs (
str) –ax –
colors –
censor (
Optional[float]) –show –
Returns:
-
interactions(so, spl, attr, mode='proportion', prediction_type='diff', graph_key='knn', linewidths=0.5, cmap=None, norm=None, ax=None, show=True)[source]¶ Visualise interaction results.
- Parameters
so – SpatialOmics instance
spl – Spl for which to compute the metric
attr – Categorical feature in SpatialOmics.obs to use for the grouping
mode – One of {classic, histoCAT, proportion}, see notes
prediction_type – prediction_type: One of {observation, pvalue, diff}
graph_key – Specifies the graph representation to use in so.G[spl]
linewidths – Space between tiles
cmap – colormap to use
norm – normalisation to use
ax – axes object to use
show – whether to show the plot
Returns:
-
get_cmap(so, attr, data)[source]¶ Return the cmap and cmap labels for a given attribute if available, else a default
- Parameters
so (IMCData) – so object form which to fetch the data
spl (str) – spl for which to get data
attr (str) – attribute for which to get the cmap and cmap labels if available
- Returns
- Return type
cmap and cmap labels for attribute
-
ripleysK(so, spl, attr, ids, *, mode='K', correction='ripley', key=None, ax=None, legend='auto')[source]¶ Plot results
- Parameters
so – SpatialOmics instance
spl (
str) – Spl for which to compute the metricattr (
str) – Categorical feature in SpatialOmics.obs to use for the groupingids – The category in the categorical feature attr, for which Ripley’s K should be plotted
mode – {K, csr-deviation}. If K, Ripley’s K is estimated, with csr-deviation the deviation from a poission process is computed.
correction – Correction method to use to correct for boarder effects, see [1].
key – key to use in so.uns[‘ripleysK’] for the plot, if None it is constructed from spl,attr,ids,mode and correction
ax – axes to use for the plot
- Returns
None
-
infiltration(so, spl, attr='infiltration', step_size=10, interpolation='gaussian', cmap='plasma', collision_strategy='mean', ax=None, show=True)[source]¶ Visualises a heatmap of the featuer intensity.
Approximates the sample with a grid representation and colors each grid square according to the value of the attribute. If multiple observations map to the same grid square a the aggregation specified in collision_strategy is employed (any value accepted by pandas aggregate function, i.e. ‘mean’, ‘max’, …)
- Parameters
so – SpatialOmics instance
spl (
str) – Spl for which to compute the metricattr (
str) – feature in SpatialOmics.obs to plotstep_size (
int) – grid step sizeinterpolation (
str) – interpolation method to use between grid values, see [1]cmap (
str) – colormap to usecollision_strategy – aggragation strategy to use if multiple obseravtion values map to the same grid value
ax – axes to use for the plot
show – whether to show the plot or not. Will be set to False if axes is provided.
- Returns
None
Notes