| Title: | A Versatile Visualization Suite |
|---|---|
| Description: | A visualization suite primarily designed for single-cell RNA-sequencing data analysis applications but well-suited for other purposes as well. It introduces novel plots to represent two-variable and frequency data and optimizes some commonly used plotting options (e.g., correlation, network, density, alluvial and volcano plots) for ease of usage and flexibility. |
| Authors: | Andrei-Florian Stoica [aut, cre] (ORCID: <https://orcid.org/0000-0002-5253-0826>) |
| Maintainer: | Andrei-Florian Stoica <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.8.4 |
| Built: | 2026-05-28 07:37:10 UTC |
| Source: | https://github.com/andrei-stoica26/henna |
This function adds a centered title to a ggplot object.
centerTitle(p, title, ...)centerTitle(p, title, ...)
p |
A ggplot object. |
title |
Plot title. |
... |
Other arguments passed to |
A ggplot object.
This function plots bars for item counts grouped and colored by class.
classPlot( df, title = NULL, xLab = "Value", yLab = "Item", legendTitle = "Class", palette = "Spectral", labelSize = 2.5, labelColor = "black", legendTitleSize = 10, legendTextSize = 10, axisTextSize = 12, axisTitleSize = 12, decreasing = TRUE, valueCutoff = 0, ... )classPlot( df, title = NULL, xLab = "Value", yLab = "Item", legendTitle = "Class", palette = "Spectral", labelSize = 2.5, labelColor = "black", legendTitleSize = 10, legendTextSize = 10, axisTextSize = 12, axisTitleSize = 12, decreasing = TRUE, valueCutoff = 0, ... )
df |
A data frame with at least three columns. Its first column (categorical) colors the plot bars. The second column (categorical) labels the plots bars. The third column (numeric) sets the bar lengths. |
title |
Plot title. |
xLab |
x axis label. |
yLab |
y axis label. |
legendTitle |
Legend title. |
palette |
Color palette. |
labelSize |
Label size. |
labelColor |
Label color. |
legendTitleSize |
Legend title size. |
legendTextSize |
Legend text size. |
axisTextSize |
Axis text size. |
axisTitleSize |
Axis title size. |
decreasing |
Whether to display the bars in decreasing order of length. |
valueCutoff |
Cutoff used for filtering the input data frame based on the third (value) column. Only values above this cutoff will be displayed on the plot. |
... |
Additional arguments passed to |
An object of class gg.
df <- data.frame(Class = sample(paste0('C', seq(13)), 25, replace=TRUE), Item = paste0('I', seq(25)), Value = runif(25, 0.5, 1)) classPlot(df) df <- data.frame(Class = sample(paste0('C', seq(13)), 25, replace=TRUE), Item = sample(paste0('I', seq(21)), 25, replace=TRUE), Value = runif(25, 0.5, 1)) classPlot(df)df <- data.frame(Class = sample(paste0('C', seq(13)), 25, replace=TRUE), Item = paste0('I', seq(25)), Value = runif(25, 0.5, 1)) classPlot(df) df <- data.frame(Class = sample(paste0('C', seq(13)), 25, replace=TRUE), Item = sample(paste0('I', seq(21)), 25, replace=TRUE), Value = runif(25, 0.5, 1)) classPlot(df)
This function finds the connected components of a graph represented as a data frame.
connectedComponents(df, colName = "component")connectedComponents(df, colName = "component")
df |
A data frame with two categorical columns representing the edges of a graph. |
colName |
Name of the connected components column to be added. |
A data frame with a column indicating the connected component of each edge.
df <- data.frame( gene1 = paste0('G', c(1, 2, 6, 7, 8, 9, 11, 25, 32, 17, 18)), gene2 = paste0('G', c(2, 8, 8, 8, 1, 25, 32, 24, 24, 26, 26)) ) connectedComponents(df)df <- data.frame( gene1 = paste0('G', c(1, 2, 6, 7, 8, 9, 11, 25, 32, 17, 18)), gene2 = paste0('G', c(2, 8, 8, 8, 1, 25, 32, 24, 24, 26, 26)) ) connectedComponents(df)
This function constructs the convex hull of a set of points.
convexHull(pointsDF, hullIndices = NULL)convexHull(pointsDF, hullIndices = NULL)
pointsDF |
A data frame with the x and y coordinates of the points. |
hullIndices |
Precalculated hull indices. Default is |
The points must be provided as a data frame with two columns.
A data frame with two columns representing the points on the convex hull.
pointsDF <- data.frame(a = c(1, 2, 2, 3, 3, 4, 5, 6, 8, 6, 7, 8, 6, 8, 10, 3, 1), b = c(2, 3, 4, 8, 5, 6, 5, 4, 8, 11, 13, 14, 2, 1, 2, 14, 9)) hull <- convexHull(pointsDF)pointsDF <- data.frame(a = c(1, 2, 2, 3, 3, 4, 5, 6, 8, 6, 7, 8, 6, 8, 10, 3, 1), b = c(2, 3, 4, 8, 5, 6, 5, 4, 8, 11, 13, 14, 2, 1, 2, 14, 9)) hull <- convexHull(pointsDF)
This function plots a correlation matrix.
correlationPlot(mat, title = NULL, legendTitle = "Correlation", ...)correlationPlot(mat, title = NULL, legendTitle = "Correlation", ...)
mat |
A numeric matrix or data frame. |
title |
Plot title. |
legendTitle |
Legend title. |
... |
Additional parameters passed to tilePlot. |
A thin wrapper around tilePlot.
An object of class gg.
mat <- matrix(runif(100, -1, 1), nrow=10) colnames(mat) <- paste0('I', seq(10)) mat <- round(cor(mat), 2) correlationPlot(mat)mat <- matrix(runif(100, -1, 1), nrow=10) colnames(mat) <- paste0('I', seq(10)) mat <- round(cor(mat), 2) correlationPlot(mat)
This function creates a density plot.
densityPlot( df, title = NULL, colorScheme = c("cloudy", "cake", "grapes", "lava", "oasis", "orichalc", "sea", "sky", "custom"), useSchemeDefaults = TRUE, drawNN = TRUE, drawScores = FALSE, xLab = NULL, yLab = NULL, legendTitle = "Density", palette = NULL, segColor = "black", pointSize = 1, pointColor = "red", segType = c("dashed", "solid", "dotted", "dotdash", "longdash", "twodash"), segWidth = 0.4, nGridPoints = 300, expandPerc = 20, labelType = c("free", "boxed"), labelSize = 3, labelColor = "black", labelRepulsion = 1, labelPull = 1, maxOverlaps = 10, labelPadding = 0, boxPadding = 0, labelSegWidth = 0.4, legendPos = c("right", "none"), legendTextSize = 10, legendTitleSize = 10, axisTextSize = 12, axisTitleSize = 12, verbose = FALSE, ... )densityPlot( df, title = NULL, colorScheme = c("cloudy", "cake", "grapes", "lava", "oasis", "orichalc", "sea", "sky", "custom"), useSchemeDefaults = TRUE, drawNN = TRUE, drawScores = FALSE, xLab = NULL, yLab = NULL, legendTitle = "Density", palette = NULL, segColor = "black", pointSize = 1, pointColor = "red", segType = c("dashed", "solid", "dotted", "dotdash", "longdash", "twodash"), segWidth = 0.4, nGridPoints = 300, expandPerc = 20, labelType = c("free", "boxed"), labelSize = 3, labelColor = "black", labelRepulsion = 1, labelPull = 1, maxOverlaps = 10, labelPadding = 0, boxPadding = 0, labelSegWidth = 0.4, legendPos = c("right", "none"), legendTextSize = 10, legendTitleSize = 10, axisTextSize = 12, axisTitleSize = 12, verbose = FALSE, ... )
df |
A data frame with at least two columns, representing the |
title |
Plot title. |
colorScheme |
Color scheme. Choose between 'cake', 'cloudy', 'grapes', 'lava', oasis', 'orichalc', 'sea', 'sky' and 'custom'. Default is 'cloudy'. |
useSchemeDefaults |
Whether to use the default |
drawNN |
Whether to draw segments linking each point to its nearest neighbor. |
drawScores |
Whether to render scores on the plot. If set to
|
xLab |
x axis label. |
yLab |
y axis label. |
legendTitle |
Legend title. |
palette |
A character vector of colors. Used only if color scheme is set to 'custom'. |
segColor |
Nearest neighbor segment color. Ignored if |
pointSize |
Point size. |
pointColor |
Point color. Ignored if |
segType |
Nearest neighbor segment type. Choose between 'solid',
'dashed', 'dotted','dotdash', 'longdash' and 'twodash'. Ignored if
|
segWidth |
Nearest neighbor segment width. Ignored if |
nGridPoints |
Number of grid points in each direction. |
expandPerc |
Percentage by which the grid will be expanded. |
labelType |
Whether to draw a box around labels (option 'boxed') or not (option 'free'). Default is 'free'. |
labelSize |
Label size. |
labelColor |
Label color. Ignored if |
labelRepulsion |
Repulsion strength between labels. |
labelPull |
Attraction strength between a text label and its data point. |
maxOverlaps |
Maximum number of allowed overlaps. |
labelPadding |
Amount of padding around label. |
boxPadding |
Amount of padding around box. |
labelSegWidth |
Thickness of segment connecting label to point. |
legendPos |
Legend position. Choose between 'right' and 'none'. |
legendTextSize |
Legend text size. |
legendTitleSize |
Legend title size. |
axisTextSize |
Axis text size. |
axisTitleSize |
Axis title size. |
verbose |
Whether output should be verbose. |
... |
Additional arguments passed to |
An object of class gg.
x <- c(1, 2, 3, 4, 6, 7, 8, 10, 12, 11, 3, 6, 4, 1, 13, 13, 14, 18, 16) y <- c(1, 3, 1, 4, 3, 2, 8, 2, 1, 11, 8, 8, 10, 14, 13, 11, 11, 12,15) z <- round(runif(19, 75, 100), 2) df <- data.frame(x, y, z) rownames(df) <- paste0('p', rownames(df)) densityPlot(df)x <- c(1, 2, 3, 4, 6, 7, 8, 10, 12, 11, 3, 6, 4, 1, 13, 13, 14, 18, 16) y <- c(1, 3, 1, 4, 3, 2, 8, 2, 1, 11, 8, 8, 10, 14, 13, 11, 11, 12,15) z <- round(runif(19, 75, 100), 2) df <- data.frame(x, y, z) rownames(df) <- paste0('p', rownames(df)) densityPlot(df)
This function returns a palette designed for densityPlot.
dpColors( palette = c("cake", "cloudy", "grapes", "lava", "oasis", "orichalc", "sea", "sky") )dpColors( palette = c("cake", "cloudy", "grapes", "lava", "oasis", "orichalc", "sea", "sky") )
palette |
One of 'lava', 'oasis', 'orichalc', 'sea' and 'sky'. |
A character vector of colors.
dpColors('sea')dpColors('sea')
This function returns the default palette used by hullPlot.
hpColors()hpColors()
A character vector of colors.
This function plots the convex hull of a set of points. It can also draw a vertical or a horizontal line (or both), dividing the hull into areas of different colors.
hullPlot( pointsDF, title = NULL, xInt = NULL, yInt = NULL, palette = hpColors(), lineColor = "navy", lineWidth = 0.3, lineType = c("dashed", "solid", "dotted", "dotdash", "longdash", "twodash"), hullWidth = 0, xLab = NULL, yLab = NULL, legendLabs = paste0("Group ", seq(4)), pointSize = 1, pointShape = 4, alpha = 0.2, labeledPoints = NULL, labelOutside = FALSE, labXThr = NULL, labYThr = NULL, labelType = c("free", "boxed"), labelSize = 2.5, labelColor = "black", labelRepulsion = 1, labelPull = 0, maxOverlaps = 10, legendPos = "bottom", legendTextSize = 10, axisTextSize = 12, axisTitleSize = 12, ... )hullPlot( pointsDF, title = NULL, xInt = NULL, yInt = NULL, palette = hpColors(), lineColor = "navy", lineWidth = 0.3, lineType = c("dashed", "solid", "dotted", "dotdash", "longdash", "twodash"), hullWidth = 0, xLab = NULL, yLab = NULL, legendLabs = paste0("Group ", seq(4)), pointSize = 1, pointShape = 4, alpha = 0.2, labeledPoints = NULL, labelOutside = FALSE, labXThr = NULL, labYThr = NULL, labelType = c("free", "boxed"), labelSize = 2.5, labelColor = "black", labelRepulsion = 1, labelPull = 0, maxOverlaps = 10, legendPos = "bottom", legendTextSize = 10, axisTextSize = 12, axisTitleSize = 12, ... )
pointsDF |
A data frame with the x and y coordinates of the points. |
title |
Plot title. |
xInt |
The coordinate where the vertical line intersects the x axis. |
yInt |
The coordinate where the horizontal line intersects the y axis. |
palette |
Color palette. |
lineColor |
The color of the horizontal and vertical dividing lines,
if provided. If |
lineWidth |
The width of the horizontal and vertical dividing lines.
Ignored if |
lineType |
The type of the horizontal and vertical dividing lines.
Choose between 'dashed','solid', 'dotted', 'dotdash', 'longdash' and
'twodash'. Default is 'dashed'. Ignored if |
hullWidth |
Width of the convex hull. If 0 (as default), the convex hull will not be displayed. |
xLab |
x axis label. |
yLab |
y axis label. |
legendLabs |
Legend labels. |
pointSize |
Point size. |
pointShape |
Point shape. |
alpha |
Opaqueness level. |
labeledPoints |
Point labels to be displayed on the plot. |
labelOutside |
Display labels for points specified by
|
labXThr |
Threshold used to plot labels based on |
labYThr |
Threshold used to plot labels based on |
labelType |
Whether to draw a box around labels (option 'boxed') or not (option 'free'). Default is 'free'. |
labelSize |
Label size. Ignored if |
labelColor |
Label color. Ignored if |
labelRepulsion |
Repulsion strength between labels. |
labelPull |
Attraction strength between a text label and its data point. |
maxOverlaps |
Maximum overlaps. Ignored if |
legendPos |
Legend position. |
legendTextSize |
Legend text size. |
axisTextSize |
Axis text size. |
axisTitleSize |
Axis title size. |
... |
Additional arguments passed to |
An object of class gg.
pointsDF <- data.frame(x = c(1, 2, 4, 7, 10, 12, 13, 15, 16), y = c(1, 1, 2, 3, 3, 2, 1, 2, 1)) hullPlot(pointsDF, 'Hull plot', 7, 1.5)pointsDF <- data.frame(x = c(1, 2, 4, 7, 10, 12, 13, 15, 16), y = c(1, 1, 2, 3, 3, 2, 1, 2, 1)) hullPlot(pointsDF, 'Hull plot', 7, 1.5)
This function checks if a point P is on a polygon boundary.
isPointOnBoundary(xPoint, yPoint, boundary)isPointOnBoundary(xPoint, yPoint, boundary)
xPoint |
x coordinate of point P. |
yPoint |
y coordinate of point P. |
boundary |
A data frame with four columns representing segments comprising the boundary. |
Logical; whether the point is on the boundary.
pointsDF <- data.frame(x = c(1, 2, 4, 7, 10, 12, 13, 15, 16), y = c(1, 1, 2, 3, 3, 2, 1, 2, 1)) hullIndices <- grDevices::chull(pointsDF[, 1], pointsDF[, 2]) hull <- convexHull(pointsDF, hullIndices) hullSegments <- pointsToSegments(hull) isPointOnBoundary(2, 3, hullSegments)pointsDF <- data.frame(x = c(1, 2, 4, 7, 10, 12, 13, 15, 16), y = c(1, 1, 2, 3, 3, 2, 1, 2, 1)) hullIndices <- grDevices::chull(pointsDF[, 1], pointsDF[, 2]) hull <- convexHull(pointsDF, hullIndices) hullSegments <- pointsToSegments(hull) isPointOnBoundary(2, 3, hullSegments)
This function checks if a point P is on a segment AB.
isPointOnSeg(xPoint, yPoint, xStart, yStart, xEnd, yEnd)isPointOnSeg(xPoint, yPoint, xStart, yStart, xEnd, yEnd)
xPoint |
x coordinate of point P. |
yPoint |
y coordinate of point P. |
xStart |
x coordinate of point A. |
yStart |
y coordinate of point A. |
xEnd |
x coordinate of point B. |
yEnd |
y coordinate of point B. |
Logical; whether the point is on the segment.
isPointOnSeg(2, 3, 1, 2, 3, 4) isPointOnSeg(2, 3, 1, 2, 3, 8) isPointOnSeg(4, 5, 1, 2, 3, 4)isPointOnSeg(2, 3, 1, 2, 3, 4) isPointOnSeg(2, 3, 1, 2, 3, 8) isPointOnSeg(4, 5, 1, 2, 3, 4)
This function labels points in a ggplot object.
labelPoints( p, labelDF, pointLabs = rownames(labelDF), labelType = c("free", "boxed"), labelSize = 2.5, labelColor = "black", labelRepulsion = 1, labelPull = 1, maxOverlaps = 50, boxPadding = 0.2, labelPadding = 0.1, labelSegWidth = 0.4, ... )labelPoints( p, labelDF, pointLabs = rownames(labelDF), labelType = c("free", "boxed"), labelSize = 2.5, labelColor = "black", labelRepulsion = 1, labelPull = 1, maxOverlaps = 50, boxPadding = 0.2, labelPadding = 0.1, labelSegWidth = 0.4, ... )
p |
A ggplot object. |
labelDF |
Label data frame. |
pointLabs |
Labels of points. |
labelType |
Whether to draw a box around labels (option 'boxed') or not (option 'free'). Default is 'free'. |
labelSize |
Label size. |
labelColor |
Label color. |
labelRepulsion |
Repulsion strength between labels. |
labelPull |
Attraction strength between a text label and its data point. |
maxOverlaps |
Maximum number of allowed overlaps. |
boxPadding |
Amount of padding around box. |
labelPadding |
Amount of padding around label. |
labelSegWidth |
Thickness of segment connecting label to point. |
... |
Additional arguments passed to |
A ggplot object.
filePath <- system.file('extdata', 'hullPlot.qs2', package='henna') sharedDF <- qs2::qs_read(filePath) name1 <- 'alpha' name2 <- 'delta' legendLabs <- as.factor(c('Non-top', 'Shared', paste0('Top only for ', name2), paste0('Top only for ', name1))) p <- hullPlot(sharedDF, 'Shared markers plot', xInt=1.5, yInt=1.3, xLab=paste0('avg_log2FC (', name1, ')'), yLab=paste0('avg_log2FC (', name2, ')'), legendLabs=legendLabs) labelDF <- sharedDF[sharedDF[, 'avg_log2FC_1'] > 1.5 & sharedDF[, 'avg_log2FC_2'] > 1.3, ] p <- labelPoints(p, labelDF, labelType='boxed', nudge_x=0.1, nudge_y=0.1)filePath <- system.file('extdata', 'hullPlot.qs2', package='henna') sharedDF <- qs2::qs_read(filePath) name1 <- 'alpha' name2 <- 'delta' legendLabs <- as.factor(c('Non-top', 'Shared', paste0('Top only for ', name2), paste0('Top only for ', name1))) p <- hullPlot(sharedDF, 'Shared markers plot', xInt=1.5, yInt=1.3, xLab=paste0('avg_log2FC (', name1, ')'), yLab=paste0('avg_log2FC (', name2, ')'), legendLabs=legendLabs) labelDF <- sharedDF[sharedDF[, 'avg_log2FC_1'] > 1.5 & sharedDF[, 'avg_log2FC_2'] > 1.3, ] p <- labelPoints(p, labelDF, labelType='boxed', nudge_x=0.1, nudge_y=0.1)
This function plots the graph of the data frame and optionally uses different colors for nodes belonging to different connected components.
networkPlot( df, title = NULL, numCol = NULL, numColType = c("weights", "ranks"), nodeSize = 10, nodeTextSize = 2.3, palette = "grDevices::Spectral", nodeColor = NULL, edgeWidth = 1, edgeColor = "black", edgeScales = c(0.2, 0.6), ... )networkPlot( df, title = NULL, numCol = NULL, numColType = c("weights", "ranks"), nodeSize = 10, nodeTextSize = 2.3, palette = "grDevices::Spectral", nodeColor = NULL, edgeWidth = 1, edgeColor = "black", edgeScales = c(0.2, 0.6), ... )
df |
Data frame. |
title |
Plot title. |
numCol |
Name of the numeric column used to vary edge widths. If no
such column is provided, set to |
numColType |
The type of the numeric column used to vary edge widths.
Choose between 'weights' and 'ranks' Ignored if |
nodeSize |
Size of graph nodes. |
nodeTextSize |
Size of text on graph nodes. |
palette |
grDevices palette used for coloring nodes.
Ignored if nodeColor is not |
nodeColor |
Color used for nodes. Default is |
edgeWidth |
Width to be used for all edges before scaling
if |
edgeColor |
Color used for edges. |
edgeScales |
Edge width scales. Must be a numeric vector of size 2 (minimum and maximum). |
... |
Additional arguments passed to |
An object of class ggraph.
df <- data.frame(gene1 = paste0('G', c(1, 2, 5, 6, 7, 17)), gene2 = paste0('G', c(2, 5, 8, 11, 11, 11)), rank = c(1, 1, 3, 3, 3, 3)) networkPlot(df, numCol='rank', numColType='ranks')df <- data.frame(gene1 = paste0('G', c(1, 2, 5, 6, 7, 17)), gene2 = paste0('G', c(2, 5, 8, 11, 11, 11)), rank = c(1, 1, 3, 3, 3, 3)) networkPlot(df, numCol='rank', numColType='ranks')
This function constructs a data frame of segments from a data frame of points.
pointsToSegments(pointsDF, joinEnds = TRUE)pointsToSegments(pointsDF, joinEnds = TRUE)
pointsDF |
A data frame with the x and y coordinates of the points. Each point must appear only once. |
joinEnds |
Whether to join the last point with the first one. |
A data frame of segments represented using four columns
(x, y, xEnd, yEnd).
pointsDF <- data.frame(x = c(1, 2, 4, 7, 10, 12, 13, 15, 16), y = c(1, 1, 2, 3, 3, 2, 1, 2, 1)) hullIndices <- grDevices::chull(pointsDF[, 1], pointsDF[, 2]) hull <- convexHull(pointsDF, hullIndices) pointsToSegments(hull)pointsDF <- data.frame(x = c(1, 2, 4, 7, 10, 12, 13, 15, 16), y = c(1, 1, 2, 3, 3, 2, 1, 2, 1)) hullIndices <- grDevices::chull(pointsDF[, 1], pointsDF[, 2]) hull <- convexHull(pointsDF, hullIndices) pointsToSegments(hull)
This function draws a radial plot for a data frame, plotting positive integer-valued points over concentric circles, with points located more centrally representing higher values.
radialPlot( valuesDF, title = NULL, valueLegendTitle = "Value", groupLegendTitle = NULL, extraCircles = 0, palette = rpColors(length(unique(valuesDF[, 3]))), labelSize = 3, pointSize = 0.8, legendTitleSize = 10, legendTextSize = 10, labelRepulsion = 1, labelPull = 0, maxOverlaps = 15, breakDensity = 6, seed = 50, ... )radialPlot( valuesDF, title = NULL, valueLegendTitle = "Value", groupLegendTitle = NULL, extraCircles = 0, palette = rpColors(length(unique(valuesDF[, 3]))), labelSize = 3, pointSize = 0.8, legendTitleSize = 10, legendTextSize = 10, labelRepulsion = 1, labelPull = 0, maxOverlaps = 15, breakDensity = 6, seed = 50, ... )
valuesDF |
A data frame with names on the first column and positive integers on the second column. |
title |
Plot title. |
valueLegendTitle |
Legend title corresponding to the positive integer column. |
groupLegendTitle |
Legend title corresponding to the categorical column. |
extraCircles |
Number of circles drawn beyond those required to include the points. |
palette |
Color palette. |
labelSize |
Label size. |
pointSize |
Point size. |
legendTitleSize |
Legend title size. |
legendTextSize |
Legend text size. |
labelRepulsion |
Repulsion strength between labels. |
labelPull |
Attraction strength between a text label and its data point. |
maxOverlaps |
Maximum number of allowed overlaps. |
breakDensity |
Factor used in calculating the number of breaks for the values legend. Higher values of this argument add more breaks to the legend, but no breaks at a distance below 1 will be allowed. |
seed |
Random seed. |
... |
Additional arguments passed to |
An object of class gg.
valuesDF <- data.frame(Protein = paste0('P', seq(20)), Value = sample(10, 20, replace=TRUE), Group = sample(3, 20, replace=TRUE)) radialPlot(valuesDF, groupLegendTitle='Group')valuesDF <- data.frame(Protein = paste0('P', seq(20)), Value = sample(10, 20, replace=TRUE), Group = sample(3, 20, replace=TRUE)) radialPlot(valuesDF, groupLegendTitle='Group')
This function creates a rank plot.
rankPlot( df, title = NULL, summarize = TRUE, viridisPal = "turbo", xLab = "Item", yLab = "Rank count", legendTitle = "Rank", sigDigits = NULL, labelSize = 2.5, labelColor = "black", labelFace = c("plain", "bold", "italic", "bold-italic"), legendTextSize = 10, legendTitleSize = 10, axisTextSize = 12, axisTitleSize = 12, xAngle = 45, vJust = 1, hJust = 1, labelScalingFactor = 0.9, labelOffset = 0.05, ... )rankPlot( df, title = NULL, summarize = TRUE, viridisPal = "turbo", xLab = "Item", yLab = "Rank count", legendTitle = "Rank", sigDigits = NULL, labelSize = 2.5, labelColor = "black", labelFace = c("plain", "bold", "italic", "bold-italic"), legendTextSize = 10, legendTitleSize = 10, axisTextSize = 12, axisTitleSize = 12, xAngle = 45, vJust = 1, hJust = 1, labelScalingFactor = 0.9, labelOffset = 0.05, ... )
df |
A data frame with ranks as columns and items as rows, or a
summary data frame generated with |
title |
Plot title. |
summarize |
Whether to summarize the ranks with |
viridisPal |
Viridis palette. |
xLab |
Label of x axis. |
yLab |
y axis label. |
legendTitle |
Legend title. |
sigDigits |
Number of significant digits used when displaying mean
ranks. If |
labelSize |
Size of label marking average rank for each item.
Ignored if |
labelColor |
Color of label marking average rank for each item.
Ignored if |
labelFace |
Font face of label marking average rank for each item. Must
be one among 'plain', 'bold', 'italic' and 'bold-italic'.
Ignored if |
legendTextSize |
Legend text size. |
legendTitleSize |
Legend title size. |
axisTextSize |
Axis text size. |
axisTitleSize |
Axis title size. |
xAngle |
Angle of x axis text. |
vJust |
Vertical justification in [0, 1]. |
hJust |
Horizontal justification in [0, 1]. |
labelScalingFactor |
Scaling factor used when displaying mean ranks.
Ignored if |
labelOffset |
Vertical offset used when displaying mean ranks.
Ignored if |
... |
Additional arguments passed to |
An object of class gg.
df <- do.call(cbind, lapply(seq(30), function(i) sample(10, 10))) rownames(df) <- paste0('M', seq(10)) colnames(df) <- paste0('R', seq(30)) rankPlot(df)df <- do.call(cbind, lapply(seq(30), function(i) sample(10, 10))) rownames(df) <- paste0('M', seq(10)) colnames(df) <- paste0('R', seq(30)) rankPlot(df)
This function creates a summary of multiple ranks provided for input items.
rankSummary(df)rankSummary(df)
df |
A data frame with ranks as columns and items as rows. |
A rank summary data frame with three columns: 'Rank', 'Item' and 'Count'.
df <- do.call(cbind, lapply(seq(30), function(i) sample(10, 10))) rownames(df) <- paste0('M', seq(10)) colnames(df) <- paste0('R', seq(30)) rankSummary(df)df <- do.call(cbind, lapply(seq(30), function(i) sample(10, 10))) rownames(df) <- paste0('M', seq(10)) colnames(df) <- paste0('R', seq(30)) rankSummary(df)
This function sort a data frame by the first column and convert the second to a factor.
reorderDF(df)reorderDF(df)
df |
A data frame. |
An object of class gg.
df <- data.frame(a = c(2, 4, 1, 3, 6), b = c(2, 8, 3, 19, 3)) reorderDF(df)df <- data.frame(a = c(2, 4, 1, 3, 6), b = c(2, 8, 3, 19, 3)) reorderDF(df)
This function creates an alluvial plot.
riverPlot( df, title = NULL, fillColIndex = 2, curveType = "sigmoid", alpha = 0.8, strataFill = "lightgoldenrod1", labelSize = 3, axisTextSize = 12, axisTitleSize = 12, viridisPal = "turbo", ... )riverPlot( df, title = NULL, fillColIndex = 2, curveType = "sigmoid", alpha = 0.8, strataFill = "lightgoldenrod1", labelSize = 3, axisTextSize = 12, axisTitleSize = 12, viridisPal = "turbo", ... )
df |
A data frame with two categorical columns and a numeric column. |
title |
Plot title. |
fillColIndex |
Index of column used for coloring the alluvia. |
curveType |
Curve type. |
alpha |
Opaqueness level for the colors of the alluvia. |
strataFill |
Color used for the strata. |
labelSize |
Size of labels of strata elements. |
axisTextSize |
Axis text size. |
axisTitleSize |
Axis title size. |
viridisPal |
Viridis palette. |
... |
Other arguments passed to |
An object of class gg.
df <- data.frame(x = sample(c('a','b', 'c', 'd', 'e', 'f'), 20, replace=TRUE), y = sample(c('p','q', 'r', 's', 't', 'u', 'v', 'w'), 20, replace=TRUE), z = runif(20, 1, 3)) riverPlot(df)df <- data.frame(x = sample(c('a','b', 'c', 'd', 'e', 'f'), 20, replace=TRUE), y = sample(c('p','q', 'r', 's', 't', 'u', 'v', 'w'), 20, replace=TRUE), z = runif(20, 1, 3)) riverPlot(df)
This function returns a 10-color palette used as the default
of radialPlot.
rpColors(nColors = 10)rpColors(nColors = 10)
nColors |
Number of colors. |
A character vector of colors.
This function plots a numeric matrix or data frame.
tilePlot( mat, title = NULL, xLab = NULL, yLab = NULL, doMelt = TRUE, legendTitle = "Value", palette = "Spectral", reverseColors = TRUE, showNumbers = TRUE, sigDigits = 2, limits = NULL, labelSize = 3, labelColor = "black", legendTextSize = 10, legendTitleSize = 10, axisTextSize = 12, axisTitleSize = 12, tileBoundaryColor = "white", tileBoundaryWidth = 0.2, xAngle = 45, vJust = 1, hJust = 1, ... )tilePlot( mat, title = NULL, xLab = NULL, yLab = NULL, doMelt = TRUE, legendTitle = "Value", palette = "Spectral", reverseColors = TRUE, showNumbers = TRUE, sigDigits = 2, limits = NULL, labelSize = 3, labelColor = "black", legendTextSize = 10, legendTitleSize = 10, axisTextSize = 12, axisTitleSize = 12, tileBoundaryColor = "white", tileBoundaryWidth = 0.2, xAngle = 45, vJust = 1, hJust = 1, ... )
mat |
A numeric matrix or data frame. |
title |
Plot title. |
xLab |
x axis label. |
yLab |
y axis label. |
doMelt |
Whether the input needs to be melted using
|
legendTitle |
Legend title. |
palette |
Color palette. |
reverseColors |
Whether to reverse the order of colors in the palette. |
showNumbers |
Whether to show a numeric value for each matrix element. |
sigDigits |
Number of significant digits to be displayed for each matrix element. |
limits |
Limits of the color scale. If |
labelSize |
Label size. |
labelColor |
Label color. |
legendTextSize |
Legend text size. |
legendTitleSize |
Legend title size. |
axisTextSize |
Axis text size. |
axisTitleSize |
Axis title size. |
tileBoundaryColor |
Tile boundary color. |
tileBoundaryWidth |
Tile boundary width. |
xAngle |
Angle of x axis text. |
vJust |
Vertical justification in [0, 1]. |
hJust |
Horizontal justification in [0, 1]. |
... |
Additional arguments passed to |
An object of class gg.
mat <- matrix(round(runif(100, 0, 1), 2), nrow=10) rownames(mat) <- paste0('R', seq(10)) colnames(mat) <- paste0('C', seq(10)) tilePlot(mat)mat <- matrix(round(runif(100, 0, 1), 2), nrow=10) rownames(mat) <- paste0('R', seq(10)) colnames(mat) <- paste0('C', seq(10)) tilePlot(mat)
This function returns the connected components of vertices from a graph data frame in which edges have been assigned connected components.
vertexComponents(df, colName = "component")vertexComponents(df, colName = "component")
df |
A data frame with two categorical columns representing graph edges and a connected components column. |
colName |
Name of the connected components column. |
A factor vector representing the connected component of each vertex.
df <- data.frame(gene1 = c('A', 'B', 'C', 'A'), gene2 = c('B', 'D', 'F', 'G'), component = c(1, 1, 2, 1)) vertexComponents(df)df <- data.frame(gene1 = c('A', 'B', 'C', 'A'), gene2 = c('B', 'D', 'F', 'G'), component = c(1, 1, 2, 1)) vertexComponents(df)
This function creates a volcano plot for a data frame with a log column and a p-value column. The gene names must be provided as row names.
volcanoPlot( df, title = NULL, logCol = "avg_log2FC", pvalCol = "p_val_adj", xLab = expression(log[2] ~ fold ~ change), yLab = expression(-log[10] ~ `p-value`), legendTitle = "Significance", legendLabs = c("Not significant", expression(log[2] ~ FC), "p-value", expression(`p-value` ~ and ~ log[2] ~ FC)), legendPos = c("right", "top", "left", "bottom"), logFCThr = 1, pvalThr = 1e-05, labeledGenes = NULL, labelOutside = FALSE, labLogFCThr = 1.8, labPvalThr = 1e-12, labelType = c("boxed", "free"), labelSize = 2.2, labelColor = "black", labelRepulsion = 1, labelPull = 0, maxOverlaps = 100, boxPadding = 0.2, labelPadding = 0.1, labelSegWidth = 0.4, pointSize = 0.8, alpha = 0.6, palette = c("gray31", "goldenrod2", "orchid3", "red2"), legendTextSize = 10, legendTitleSize = 10, axisTextSize = 12, axisTitleSize = 12, theme = c("minimal", "bw", "classic", "linedraw"), ... )volcanoPlot( df, title = NULL, logCol = "avg_log2FC", pvalCol = "p_val_adj", xLab = expression(log[2] ~ fold ~ change), yLab = expression(-log[10] ~ `p-value`), legendTitle = "Significance", legendLabs = c("Not significant", expression(log[2] ~ FC), "p-value", expression(`p-value` ~ and ~ log[2] ~ FC)), legendPos = c("right", "top", "left", "bottom"), logFCThr = 1, pvalThr = 1e-05, labeledGenes = NULL, labelOutside = FALSE, labLogFCThr = 1.8, labPvalThr = 1e-12, labelType = c("boxed", "free"), labelSize = 2.2, labelColor = "black", labelRepulsion = 1, labelPull = 0, maxOverlaps = 100, boxPadding = 0.2, labelPadding = 0.1, labelSegWidth = 0.4, pointSize = 0.8, alpha = 0.6, palette = c("gray31", "goldenrod2", "orchid3", "red2"), legendTextSize = 10, legendTitleSize = 10, axisTextSize = 12, axisTitleSize = 12, theme = c("minimal", "bw", "classic", "linedraw"), ... )
df |
A data frame with rownames as genes, a log column and a p-value column. |
title |
Plot title. |
logCol |
Log column. |
pvalCol |
P-value column. |
xLab |
x axis label. |
yLab |
y axis label. |
legendTitle |
Legend title. |
legendLabs |
Legend labels. |
legendPos |
Legend position. |
logFCThr |
Threshold used to separate significant log values. |
pvalThr |
Threshold used to separate significant p-values. |
labeledGenes |
Gene labels to be displayed on the plot. Default is
|
labelOutside |
Display labels for points specified by
|
labLogFCThr |
Threshold used to plot gene labels based on log values.
Ignored if |
labPvalThr |
Threshold used to plot gene labels based on p-values.
Ignored if |
labelType |
Whether to draw a box around labels (option 'boxed') or not (option 'free'). Default is 'free'. |
labelSize |
Label size. |
labelColor |
Label color. |
labelRepulsion |
Repulsion strength between labels. |
labelPull |
Attraction strength between a text label and its data point. |
maxOverlaps |
Maximum number of allowed overlaps. |
boxPadding |
Amount of padding around box. |
labelPadding |
Amount of padding around label. |
labelSegWidth |
Thickness of segment connecting label to point. |
pointSize |
Point size. |
alpha |
Opaqueness level of point color. |
palette |
Color palette. |
legendTextSize |
Legend text size. |
legendTitleSize |
Legend title size. |
axisTextSize |
Axis text size. |
axisTitleSize |
Axis title size. |
theme |
Plot theme. Choose between 'bw', 'classic', 'linedraw' and 'minimal'. Default is 'minimal'. |
... |
Additional arguments passed to
|
Users can input labeled genes in two ways:
1) By using p-value and log fold-change thresholds (the default option).
2) By inputting a list of labels.
An object of class gg.
if (requireNamespace("EnhancedVolcano", quietly=TRUE)){ filePath <- system.file('extdata', 'volcanoPlot.qs2', package='henna') df <- qs2::qs_read(filePath) p <- volcanoPlot(df, title='Volcano plot - beta cells', pvalThr=1e-10, logFCThr=1, labPvalThr=1e-150, labLogFCThr=5.3) }if (requireNamespace("EnhancedVolcano", quietly=TRUE)){ filePath <- system.file('extdata', 'volcanoPlot.qs2', package='henna') df <- qs2::qs_read(filePath) p <- volcanoPlot(df, title='Volcano plot - beta cells', pvalThr=1e-10, logFCThr=1, labPvalThr=1e-150, labLogFCThr=5.3) }