Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sc 41 optimize flowsom clustering #82

Merged
merged 11 commits into from
Jan 8, 2025
4 changes: 2 additions & 2 deletions src/harpy/image/pixel_clustering/_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def flowsom(
sdata
The input SpatialData object.
img_layer
The image layer(s) of `sdata` on which flowsom is run. It is recommended to preprocess the data with `harpy.im.pixel_clustering_preprocess`.
The image layer(s) of `sdata` on which flowsom is run. It is recommended to preprocess the data with :func:`harpy.im.pixel_clustering_preprocess`.
output_layer_clusters
The output labels layer in `sdata` to which labels layer with predicted flowsom SOM clusters are saved.
output_layer_metaclusters
Expand Down Expand Up @@ -107,7 +107,7 @@ def flowsom(
Warnings
--------
- The function is intended for use with spatial proteomics data. Input data should be appropriately preprocessed
(e.g. via `harpy.im.pixel_clustering_preprocess`) to ensure meaningful clustering results.
(e.g. via :func:`harpy.im.pixel_clustering_preprocess`) to ensure meaningful clustering results.
- The cluster and metacluster ID's found in `output_layer_clusters` and `output_layer_metaclusters` count from 1, while they count from 0 in the `FlowSOM` object.
"""
assert 0 < fraction <= 1, "Value must be between 0 and 1"
Expand Down
16 changes: 10 additions & 6 deletions src/harpy/plot/_flowsom.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def pixel_clusters(
**kwargs, # passed to pl.show() of spatialdata_plot
):
"""
Visualize spatial distribution of pixel clusters based on labels in a `SpatialData` object, obtained using `harpy.im.flowsom`.
Visualize spatial distribution of pixel clusters based on labels in a `SpatialData` object, obtained using :func:`harpy.im.flowsom`.

Parameters
----------
Expand Down Expand Up @@ -163,7 +163,7 @@ def pixel_clusters_heatmap(
sdata
The input SpatialData object.
table_layer
The table layer in `sdata` containing cluster intensity for clusters and metaclusters, obtained via `hp.tb.cluster_intensity`.
The table layer in `sdata` containing cluster intensity for clusters and metaclusters, obtained via :func:`harpy.tb.cluster_intensity`.
metaclusters
Whether to display mean channel intensity per metacluster (`True`) or per cluster (`False`).
z_score
Expand All @@ -172,13 +172,17 @@ def pixel_clusters_heatmap(
The value to clip the z-scored data to, for better visualization. If `None`, no clipping is performed.
Ignored if `z_score` is `False`.
output
The path to save the generated heatmap. If `None`, the heatmap will be displayed directly using `plt.show()`.
The path to save the generated heatmap. If `None`, the heatmap will be displayed directly using :func:`matplotlib.pyplot.show`.
figsize
Size of the figure in inches (width, height).
Tuple specifying the size of the figure in inches as `(width, height)`.
The width determines the spacing available for cluster IDs, while the height adjusts space for channels.
If labels (cluster IDs or channel names) are truncated, increase the respective dimension.
Increase `width` if cluster IDs or are not fully visible.
Increase `height` if channel names are not fully visible.
fig_kwargs
Additional keyword arguments passed to `plt.figure`, such as `dpi`.
Additional keyword arguments passed to :func:`matplotlib.pyplot.figure`, such as `dpi`.
**kwargs
Additional keyword arguments passed to `sns.heatmap`, such as `annot`, `cmap`, or `cbar_kws`.
Additional keyword arguments passed to :func:`seaborn.heatmap`, such as `annot`, `cmap`, or `cbar_kws`.

Returns
-------
Expand Down
Loading