| Title: | Plotting functionality for Histopathology pipeline datasets |
|---|---|
| Description: | Create side-by-side visualizations of tissue thumbnail image and HoverNet cell segmentation with colored cell type labels. Functionality automatically retrieves the thumbnail image associated with a HoverNet JSON file and overlays the segmentation data. This package is intended for researchers working with histopathological images, facilitating exploratory analysis, and integrates with the imageFeatureTCGA Bioconductor package. |
| Authors: | Ilaria Billato [aut, cre] (ORCID: <https://orcid.org/0000-0002-3335-3254>, affiliation: Department of Biology, University of Padova) |
| Maintainer: | Ilaria Billato <[email protected]> |
| License: | Artistic-2.0 |
| Version: | 1.1.2 |
| Built: | 2026-05-30 09:40:51 UTC |
| Source: | https://github.com/bioc/HistoImagePlot |
Creates a side-by-side visualization of the original tissue thumbnail image and the HoverNet cell segmentation with colored cell type labels. This function works with HoverNet data stored in h5ad format and imported as a SpatialExperiment object.
plotHoverNetH5ADOverlay( hovernet, thumbnail_path, title = NULL, point_size = 0.01, legend_point_size = 2, color_palette = NULL, ncol = 2, rel_widths = c(1, 1.08), title_size = 25, flip_image = TRUE )plotHoverNetH5ADOverlay( hovernet, thumbnail_path, title = NULL, point_size = 0.01, legend_point_size = 2, color_palette = NULL, ncol = 2, rel_widths = c(1, 1.08), title_size = 25, flip_image = TRUE )
hovernet |
A |
thumbnail_path |
Path or URL to the thumbnail PNG image file. |
title |
Optional. Title for the combined plot. If |
point_size |
Numeric value for the size of points in the segmentation
plot. Default is |
legend_point_size |
Numeric value for the size of points in the legend.
Default is |
color_palette |
Optional. A named vector of colors for cell types. If
|
ncol |
Number of columns for the side-by-side plots. Default is |
rel_widths |
Relative widths of the image and segmentation plots.
Default is |
title_size |
Font size for the main title. Default is |
flip_image |
Logical. Whether to flip the image vertically to match
coordinate system. Default is |
The function performs the following steps:
Loads the thumbnail PNG image (from local path or URL with caching)
Creates a segmentation plot colored by cell type using the type
column from colData
Combines the thumbnail and segmentation side-by-side
Adds an optional title
The function expects the SpatialExperiment to have:
spatialCoords with columns x_centroid and y_centroid
colData with a type column for cell type classification
Remote PNG files are automatically cached using BiocFileCache for
efficient handling without manual downloads.
A ggplot object combining the thumbnail image and segmentation
overlay with an optional title.
# Load h5ad HoverNet data h5ad_url <- paste0( "https://store.cancerdatasci.org/hovernet/h5ad/", "TCGA-VG-A8LO-01A-01-DX1.B39A4D64-82A1-4A04-8AB6-918F3058B83B.h5ad" ) hn_spe <- HoverNet(h5ad_url, outClass = "SpatialExperiment") |> import() thumb_url <- paste0( "https://store.cancerdatasci.org/hovernet/thumb/", "TCGA-VG-A8LO-01A-01-DX1.B39A4D64-82A1-4A04-8AB6-918F3058B83B.png" ) plotHoverNetH5ADOverlay(hn_spe, thumbnail_path = thumb_url)# Load h5ad HoverNet data h5ad_url <- paste0( "https://store.cancerdatasci.org/hovernet/h5ad/", "TCGA-VG-A8LO-01A-01-DX1.B39A4D64-82A1-4A04-8AB6-918F3058B83B.h5ad" ) hn_spe <- HoverNet(h5ad_url, outClass = "SpatialExperiment") |> import() thumb_url <- paste0( "https://store.cancerdatasci.org/hovernet/thumb/", "TCGA-VG-A8LO-01A-01-DX1.B39A4D64-82A1-4A04-8AB6-918F3058B83B.png" ) plotHoverNetH5ADOverlay(hn_spe, thumbnail_path = thumb_url)
Creates a side-by-side visualization of the original tissue thumbnail image and the HoverNet cell segmentation with colored cell type labels. The function automatically retrieves the thumbnail image associated with a HoverNet JSON file and overlays the segmentation data.
plotHoverNetOverlay( hovernet, json_path = NULL, title = NULL, point_size = 0.01, legend_point_size = 2, color_palette = NULL, ncol = 2, rel_widths = c(1, 1.08), title_size = 25, flip_image = TRUE )plotHoverNetOverlay( hovernet, json_path = NULL, title = NULL, point_size = 0.01, legend_point_size = 2, color_palette = NULL, ncol = 2, rel_widths = c(1, 1.08), title_size = 25, flip_image = TRUE )
hovernet |
A |
json_path |
Optional. Path or URL to the HoverNet JSON file. Only
required if |
title |
Optional. Title for the combined plot. If |
point_size |
Numeric value for the size of points in the segmentation
plot. Default is |
legend_point_size |
Numeric value for the size of points in the legend.
Default is |
color_palette |
Optional. A named vector of colors for cell types. If
|
ncol |
Number of columns for the side-by-side plots. Default is |
rel_widths |
Relative widths of the image and segmentation plots.
Default is |
title_size |
Font size for the main title. Default is |
flip_image |
Logical. Whether to flip the image vertically to match
coordinate system. Default is |
The function performs the following steps:
If hovernet is a file path, imports it using HoverNet()
and import()
Retrieves the associated thumbnail PNG
Creates a segmentation plot colored by cell type
Combines the thumbnail and segmentation side-by-side
Adds an optional title
The thumbnail is automatically downloaded and cached if a URL is provided.
The segmentation uses the type column from the colData and colors are
taken from the type_map metadata if available.
A ggplot object combining the thumbnail image and segmentation
overlay with an optional title.
json_url <- paste0( "https://store.cancerdatasci.org/hovernet/json/", "TCGA-VG-A8LO-01A-01-DX1.B39A4D64-82A1-4A04-8AB6-918F3058B83B.json.gz" ) plotHoverNetOverlay(json_url, title = "TCGA-VG-A8LO Sample")json_url <- paste0( "https://store.cancerdatasci.org/hovernet/json/", "TCGA-VG-A8LO-01A-01-DX1.B39A4D64-82A1-4A04-8AB6-918F3058B83B.json.gz" ) plotHoverNetOverlay(json_url, title = "TCGA-VG-A8LO Sample")