| Title: | Utility functions for working with histopathology images |
|---|---|
| Description: | Utility functions for working with CONCH data, listing remote files. One function assigns HoverNet nuclei to ProvGigaPath tiles with a scale factor to align coordinates. Provides internal utility functions for 'imageFeatureTCGA' and most functions are not meant for end users. |
| Authors: | Marcel Ramos [aut] (ORCID: <https://orcid.org/0000-0002-3242-0582>, affiliation: CUNY Graduate School of Public Health and Health Policy, New York, NY USA), Ilaria Billato [aut, cre] (ORCID: <https://orcid.org/0000-0002-3335-3254>, affiliation: Department of Biology, University of Padova), Eslam Abousamra [ctb] (affiliation: CUNY Graduate School of Public Health and Health Policy, New York, NY USA) |
| Maintainer: | Ilaria Billato <[email protected]> |
| License: | Artistic-2.0 |
| Version: | 1.1.0 |
| Built: | 2026-05-22 18:44:15 UTC |
| Source: | https://github.com/bioc/imageTCGAutils |
This function reads CONCH output stored in an HDF5 (.h5) file
and converts it into a SpatialFeatureExperiment object for downstream
analysis and visualization. The function extracts spatial coordinates and
feature embeddings from the file, ensuring proper formatting for the SFE
class.
importCONCH(file_path, patch_size = 224)importCONCH(file_path, patch_size = 224)
file_path |
|
patch_size |
|
A SpatialFeatureExperiment class object.
conch_file <- system.file( "extdata/mini_tcga_conch.h5", package = "imageTCGAutils", mustWork = TRUE ) importCONCH(conch_file)conch_file <- system.file( "extdata/mini_tcga_conch.h5", package = "imageTCGAutils", mustWork = TRUE ) importCONCH(conch_file)
Functions to list available HoverNet and ProvGiga data for TCGA
cancers. HoverNet data is only available for TCGA-OV, while ProvGiga data
is available for multiple TCGA cancer types at slide and tile levels. See
the TCGAcodesAvailable dataset for a summary of available data. These
functions return a data.frame with filenames and file sizes.
listHoverNet(format = c("geojson", "h5ad", "json", "thumb"), maxkeys = 1000L) listProvGiga(level = c("slide_level", "tile_level"), maxkeys = 1000L)listHoverNet(format = c("geojson", "h5ad", "json", "thumb"), maxkeys = 1000L) listProvGiga(level = c("slide_level", "tile_level"), maxkeys = 1000L)
format |
|
maxkeys |
|
level |
|
listHoverNet,listProvGiga: A tibble listing available HoverNet
or ProvGigaPath files with Filename, Modified, and Size columns.
## List available HoverNet data for TCGA-OV listHoverNet(format = "geojson", maxkeys = 10) ## List available ProvGiga slide-level data for TCGA-BRCA listProvGiga(level = "slide_level", maxkeys = 10)## List available HoverNet data for TCGA-OV listHoverNet(format = "geojson", maxkeys = 10) ## List available ProvGiga slide-level data for TCGA-BRCA listProvGiga(level = "slide_level", maxkeys = 10)
Assigns HoverNet nuclei to ProvGigaPath tiles by computing a scale factor to align coordinate systems, then performing spatial matching. Returns tile-level cell type counts and dominant cell types.
matchHoverNetToTiles( hovernet, tiles, tile_size = 224, cell_x = "x_centroid", cell_y = "y_centroid", tile_x = "tile_x", tile_y = "tile_y", tile_id = "tile_id", cell_type = "type" )matchHoverNetToTiles( hovernet, tiles, tile_size = 224, cell_x = "x_centroid", cell_y = "y_centroid", tile_x = "tile_x", tile_y = "tile_y", tile_id = "tile_id", cell_type = "type" )
hovernet |
A |
tiles |
A |
tile_size |
Numeric. Size of tiles in pixels. Default is |
cell_x |
Character. Name of the x-coordinate column in HoverNet data.
Default is |
cell_y |
Character. Name of the y-coordinate column in HoverNet data.
Default is |
tile_x |
Character. Name of the tile x-coordinate column in tiles data.
Default is |
tile_y |
Character. Name of the tile y-coordinate column in tiles data.
Default is |
tile_id |
Character. Name of the tile ID column in tiles data.
Default is |
cell_type |
Character. Name of the cell type column in HoverNet data.
Default is |
The function performs the following steps:
Computes a scale factor to align nuclei coordinates with tile coordinates
Scales nuclei coordinates using the computed scale factor
Creates bounding boxes for each tile based on tile_size
Assigns nuclei to tiles using spatial overlap
Counts cell types per tile
Identifies the dominant cell type for each tile
Merges results back to the original tiles data
The scale factor is computed as the mean of x and y scale factors, where each is the ratio of coordinate ranges between nuclei and tiles.
A list with three elements:
A data.frame with original tile data plus
cell type counts (N) and labels (cell_type_label) for each tile.
A data.frame with tile IDs and their dominant
(most frequent) cell type.
A list containing the computed scale factor, and separate x and y scale factors.
library(imageFeatureTCGA) hov_file <- paste0( "https://store.cancerdatasci.org/hovernet/h5ad/", "TCGA-23-1021-01Z-00-DX1.F07C221B-D401-47A5-9519-10DE59CA1E9D.h5ad.gz" ) hn_spe <- HoverNet(hov_file, outClass = "SpatialExperiment") |> import() tile_prov_url <- paste0( "https://store.cancerdatasci.org/provgigapath/tile_level/", "TCGA-23-1021-01Z-00-DX1.F07C221B-D401-47A5-9519-10DE59CA1E9D.csv.gz" ) pg_spe <- ProvGiga(tile_prov_url) |> import() result <- matchHoverNetToTiles(hn_spe, pg_spe) tiles_matched <- result$tiles_with_nuclei dominant_types <- result$tiles_dominant scale_info <- result$scale_factorlibrary(imageFeatureTCGA) hov_file <- paste0( "https://store.cancerdatasci.org/hovernet/h5ad/", "TCGA-23-1021-01Z-00-DX1.F07C221B-D401-47A5-9519-10DE59CA1E9D.h5ad.gz" ) hn_spe <- HoverNet(hov_file, outClass = "SpatialExperiment") |> import() tile_prov_url <- paste0( "https://store.cancerdatasci.org/provgigapath/tile_level/", "TCGA-23-1021-01Z-00-DX1.F07C221B-D401-47A5-9519-10DE59CA1E9D.csv.gz" ) pg_spe <- ProvGiga(tile_prov_url) |> import() result <- matchHoverNetToTiles(hn_spe, pg_spe) tiles_matched <- result$tiles_with_nuclei dominant_types <- result$tiles_dominant scale_info <- result$scale_factor