| Title: | A 'ggplot2' Extension for Visualizing the Colon |
|---|---|
| Description: | Provides a 'ggplot2' extension for creating clear, customizable visualizations of the colon. Includes geometry and label layers for plotting colon anatomy and overlaying related data, along with helpers for converting colon segments to 'sf' polygons and generating heatmap grids across the colon geometry. |
| Authors: | Yoni Sidi [aut, cre], Sanofi [cph] |
| Maintainer: | Yoni Sidi <[email protected]> |
| License: | Apache License (>= 2) |
| Version: | 0.0.6 |
| Built: | 2026-10-15 17:20:16 UTC |
| Source: | https://github.com/cran/ggcolonviz |
ggcolonviz Packageggcolonviz implements a ggplot2 extension for visualizing the colon.
Maintainer: Yoni Sidi [email protected]
Other contributors:
Sanofi [copyright holder]
Useful links:
Report bugs at https://github.com/Sanofi-Public/ggcolonviz/issues
This function creates a grid of points within the colon geometry, which can be used to generate heatmaps or other spatial visualizations. The grid is created by intersecting a dense grid of points with the colon geometry, resulting in a set of points that lie within the colon structure.
colon_heatmap_grid(grid_res = 500, variant = "standard")colon_heatmap_grid(grid_res = 500, variant = "standard")
grid_res |
The resolution of the grid, which determines how many points are generated. A higher resolution will create a denser grid, which can lead to smoother heatmaps but may also increase computation time. |
variant |
A character string specifying the variant of the colon blueprint to use. |
The function first creates a dense grid of points based on the specified resolution, then intersects this grid with the colon geometry to retain only the points that lie within the colon. The resulting sf object contains the coordinates of the points that can be used for further analysis or visualization.
An sf object containing the points that lie within the colon geometry, which can be used for heatmap generation or other spatial analyses.
This function converts the colon blueprint into an sf object, which can be used for spatial operations and visualizations. It groups the blueprint by colon parts and creates polygon geometries for each part.
colon_sf(variant = "standard")colon_sf(variant = "standard")
variant |
A character string specifying the variant of the colon blueprint to use. |
The resulting sf object contains the geometry of the colon parts, which can be used for various spatial analyses or visualizations, such as creating heatmaps or overlaying additional data on the colon structure.
An sf object with polygon geometries for each part of the colon.
This function defines a custom ggplot2 layer that allows users to plot the colon geometry based on the predefined blueprint. It takes in aesthetics for x, y, and part, and uses the StatColon ggproto object to compute the necessary data for plotting the colon structure. The resulting layer can be used in conjunction with other ggplot2 layers to create detailed visualizations of the colon.
geom_colon( mapping = NULL, data = NULL, variant = "standard", show.legend = NA, ... )geom_colon( mapping = NULL, data = NULL, variant = "standard", show.legend = NA, ... )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
variant |
A character string specifying the variant of the colon blueprint to use. |
show.legend |
logical. Should this layer be included in the legends?
|
... |
Additional parameters passed to the layer, such as fill, color, size, etc. |
The geom_colon function creates a layer that can be added to a ggplot2 plot. It requires the aesthetics x, y, and part to be specified, which correspond to the position and the specific part of the colon to be plotted.
The variants can be defined in the colon_variants list, which should contain different blueprints for the colon geometry.
A ggplot2 layer that can be added to a plot to visualize the colon geometry.
This function defines a custom ggplot2 layer that allows users to add labels to the colon parts based on the predefined blueprint. It takes in aesthetics for x, y, and part, and uses the StatColonLabels ggproto object to compute the necessary data for positioning and labeling the colon parts. The resulting layer can be used in conjunction with other ggplot2 layers to create detailed visualizations of the colon with informative labels.
geom_colon_label( mapping = NULL, data = NULL, show.legend = NA, variant = "standard", ... )geom_colon_label( mapping = NULL, data = NULL, show.legend = NA, variant = "standard", ... )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
show.legend |
logical. Should this layer be included in the legends?
|
variant |
A character string specifying the variant of the colon blueprint to use. |
... |
Additional parameters passed to the layer, such as fill, color, size, etc. |
The geom_colon_label function creates a layer that can be added to a ggplot2 plot. It requires the aesthetics x, y, and part to be specified, which correspond to the position and the specific part of the colon to be labeled.
The variants can be defined in the colon_variants list, which should contain different blueprints for the colon geometry.#'
A ggplot2 layer that can be added to a plot to visualize labels on the colon parts.
Returns the names of all variants currently registered in the package
registry, including the built-in "standard" and "sescd" variants plus
any added via register_colon_variant().
list_colon_variants()list_colon_variants()
A character vector of variant names.
list_colon_variants()list_colon_variants()
Adds a new named blueprint to the package's internal variant registry so it
can be referenced by variant arguments in geom_colon(),
geom_colon_label(), colon_sf(), and colon_heatmap_grid().
register_colon_variant(name, data)register_colon_variant(name, data)
name |
A non-empty character string naming the new variant.
Existing variants (including |
data |
A data frame with at least three columns:
Each unique |
The name string, invisibly.
my_blueprint <- data.frame( dx = c(0, 1, 1, 0, 2, 3, 3, 2), dy = c(0, 0, 1, 1, 0, 0, 1, 1), part = c(rep("SegA", 4), rep("SegB", 4)) ) register_colon_variant("my_colon", my_blueprint) list_colon_variants()my_blueprint <- data.frame( dx = c(0, 1, 1, 0, 2, 3, 3, 2), dy = c(0, 0, 1, 1, 0, 0, 1, 1), part = c(rep("SegA", 4), rep("SegB", 4)) ) register_colon_variant("my_colon", my_blueprint) list_colon_variants()