diff --git a/NEWS.md b/NEWS.md index 89da748..191c848 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,14 +18,17 @@ - Added `ligerToH5AD()` allowing reticulate/Python free export of liger object to H5AD format. This might not be releasable due to the need of calling non-exported functions from *hdf5r* library. - Changed `runMarkerDEG()` and `runPairwiseDEG()` default method from `"wilcoxon"` to `"pseudoBulk"` - Fixed `runMarkerDEG(method = "pseudobulk")` bug in assigning pseudo-replicates, and optimized error/warning signaling. +- Optimized DE test memory usage scalability for both pseudo-bulk method and wilcoxon test - Added `plotProportionBox()` for visualizing compositional analysis - Added `plotBarcodeRank()` for basic QC visualization - Added `plotPairwiseDEGHeatmap()` for visualizing pairwise DEG results - Added `plotGODot()` for visualizing GO enrichment results +- Optimized `plotVolcano()` text annotation positioning +- Optimized visualization function additional argument documentation - Added `calcNMI()` for evaluating clustering results against ground truth - Fixed bug in `calcAlignment()`, `subsetMemLigerDataset()`, `cellMeta()` -- Optimized `plotVolcano()` text annotation positioning -- Optimized DE test memory usage scalability for both pseudo-bulk method and wilcoxon test + + ## rliger 2.0.1 diff --git a/R/DEG_marker.R b/R/DEG_marker.R index ef06fb4..28ae659 100644 --- a/R/DEG_marker.R +++ b/R/DEG_marker.R @@ -1115,6 +1115,7 @@ plotMarkerHeatmap <- function( #' @param useCellMeta Cell metadata variable names for cell grouping. Default #' \code{NULL} includes dataset source and the default cluster. #' @param column_title Title on the column. Default \code{NULL}. +#' @param seed Random seed for reproducibility. Default \code{1}. #' @param ... Parameter passed to wrapped functions in the inheritance order: #' \code{\link{plotGeneHeatmap}}, \code{\link{.plotHeatmap}}, #' \code{ComplexHeatmap::\link[ComplexHeatmap]{Heatmap}} diff --git a/R/ggplotting.R b/R/ggplotting.R index 180b01a..68a9415 100644 --- a/R/ggplotting.R +++ b/R/ggplotting.R @@ -47,6 +47,8 @@ #' @param titles Title text. A character scalar or a character vector with as #' many elements as multiple plots are supposed to be generated. Default #' \code{NULL}. +#' @inheritDotParams .ggScatter dotOrder dotSize dotAlpha trimHigh trimLow zeroAsNA raster labelBy labelText labelTextSize seed +#' @inheritDotParams .ggplotLigerTheme title subtitle xlab ylab legendColorTitle legendShapeTitle showLegend legendPosition baseSize titleSize subtitleSize xTextSize xTitleSize yTextSize yTitleSize legendTextSize legendTitleSize legendDotSize panelBorder legendNRow legendNCol colorLabels colorValues colorPalette colorDirection naColor colorLow colorMid colorHigh colorMidPoint plotly #' @param ... More plot setting arguments. See \code{\link{.ggScatter}} and #' \code{\link{.ggplotLigerTheme}}. #' @return A ggplot object when a single plot is intended. A list of ggplot @@ -178,7 +180,7 @@ plotDimRed <- function( #' @param zeroAsNA Logical, whether to set zero values in continuous #' \code{colorBy} variable to \code{NA} so the color of these value. #' @param raster Logical, whether to rasterize the plot. Default \code{NULL} -#' automatically rasterize the plot when number of total cells to be plotted +#' automatically rasterize the plot when number of total dots to be plotted #' exceeds 100,000. #' @param labelBy A variable name available in \code{plotDF}. If the variable is #' categorical (a factor), the label position will be the median coordinates of @@ -564,9 +566,17 @@ plotCellViolin <- function( #' By default, no main title or subtitle will be set, and X/Y axis title will be #' the names of variables used for plotting. Use \code{NULL} to hide elements. #' \code{TRUE} for \code{xlab} or \code{ylab} shows default values. -#' @param legendColorTitle,legendFillTitle,legendShapeTitle,legendSizeTitle Set -#' alternative title text for legend on aes of color, fill, shape and size, -#' respectively. Default \code{NULL} shows the original variable name. +#' @param legendColorTitle Legend title text for color aesthetics, often used +#' for categorical or continuous coloring of dots. Default \code{NULL} shows the +#' original variable name. +#' @param legendFillTitle Legend title text for fill aesthetics, often used for +#' violin, box, bar plots. Default \code{NULL} shows the original variable name. +#' @param legendShapeTitle Legend title text for shape aesthetics, often used +#' for shaping dots by categorical variable. Default \code{NULL} shows the +#' original variable name. +#' @param legendSizeTitle Legend title text for size aesthetics, often used for +#' sizing dots by continuous variable. Default \code{NULL} shows the original +#' variable name. #' @param showLegend Whether to show the legend. Default \code{TRUE}. #' @param legendPosition Text indicating where to place the legend. Choose from #' \code{"top"}, \code{"bottom"}, \code{"left"} or \code{"right"}. Default @@ -585,12 +595,13 @@ plotCellViolin <- function( #' the colors/shapes clearly. Default \code{4}. #' @param panelBorder Whether to show rectangle border of the panel instead of #' using ggplot classic bottom and left axis lines. Default \code{FALSE}. -#' @param colorLabels,colorValues Each a vector with as many values as the -#' number of categories for the categorical coloring aesthetics. Labels will be -#' the shown text and values will be the color code. These are passed to -#' \code{\link[ggplot2]{scale_color_manual}}. Default uses an internal selected -#' palette if there are <= 26 colors needed, or ggplot hues otherwise, and plot -#' original labels (levels of the factor). +#' @param colorLabels Character vector for modifying category names in a +#' color legend. Passed to \code{ggplot2::scale_color_manual(labels)}. Default +#' \code{NULL} uses original levels of the factor. +#' @param colorValues Character vector of colors for modifying category colors +#' in a color legend. Passed to \code{ggplot2::scale_color_manual(values)}. +#' Default \code{NULL} uses internal selected palette when <= 26 categories are +#' presented, otherwise ggplot hues. #' @param legendNRow,legendNCol Integer, when too many categories in one #' variable, arranges number of rows or columns. Default \code{NULL}, #' automatically split to \code{ceiling(levels(variable)/10)} columns. @@ -656,20 +667,16 @@ plotCellViolin <- function( plot <- plot + ggplot2::ggtitle(title, subtitle = subtitle) # Broadcast one-param setting to each - Subtitle <- xText <- yText <- legendText <- baseSize - Title <- xTitle <- yTitle <- legendTitle <- baseSize + 2 - xFacet <- yFacet <- baseSize - 2 - # And set specific ones if specified - if (!is.null(titleSize)) Title <- titleSize - if (!is.null(subtitleSize)) Subtitle <- subtitleSize - if (!is.null(xTextSize)) xText <- xTextSize - if (!is.null(xFacetSize)) xFacet <- xFacetSize - if (!is.null(xTitleSize)) xTitle <- xTitleSize - if (!is.null(yTextSize)) yText <- yTextSize - if (!is.null(yFacetSize)) yFacet <- yFacetSize - if (!is.null(yTitleSize)) yTitle <- yTitleSize - if (!is.null(legendTextSize)) legendText <- legendTextSize - if (!is.null(legendTitleSize)) legendTitle <- legendTitleSize + titleSize <- titleSize %||% baseSize + 2 + subtitleSize <- subtitleSize %||% baseSize + xTextSize <- xTextSize %||% baseSize + xFacetSize <- xFacetSize %||% baseSize - 2 + xTitleSize <- xTitleSize %||% baseSize + 2 + yTextSize <- yTextSize %||% baseSize + yFacetSize <- yFacetSize %||% baseSize - 2 + yTitleSize <- yTitleSize %||% baseSize + 2 + legendTextSize <- legendTextSize %||% baseSize + legendTitleSize <- legendTitleSize %||% baseSize + 2 # Set x/y axis titles if (!isTRUE(xlab)) { @@ -689,16 +696,16 @@ plotCellViolin <- function( plot <- plot + ggplot2::theme_classic() + ggplot2::theme( - plot.title = ggplot2::element_text(size = Title), - plot.subtitle = ggplot2::element_text(size = Subtitle), - axis.text.x = ggplot2::element_text(size = xText), - axis.title.x = ggplot2::element_text(size = xTitle), - axis.text.y = ggplot2::element_text(size = yText), - axis.title.y = ggplot2::element_text(size = yTitle), - strip.text.x = ggplot2::element_text(size = xFacet), - strip.text.y = ggplot2::element_text(size = yFacet), - legend.text = ggplot2::element_text(size = legendText), - legend.title = ggplot2::element_text(size = legendTitle) + plot.title = ggplot2::element_text(size = titleSize), + plot.subtitle = ggplot2::element_text(size = subtitleSize), + axis.text.x = ggplot2::element_text(size = xTextSize), + axis.title.x = ggplot2::element_text(size = xTitleSize), + axis.text.y = ggplot2::element_text(size = yTextSize), + axis.title.y = ggplot2::element_text(size = yTitleSize), + strip.text.x = ggplot2::element_text(size = xFacetSize), + strip.text.y = ggplot2::element_text(size = yFacetSize), + legend.text = ggplot2::element_text(size = legendTextSize), + legend.title = ggplot2::element_text(size = legendTitleSize) ) if (isTRUE(panelBorder)) { diff --git a/R/visualization.R b/R/visualization.R index 7e5d71c..2dd0e47 100644 --- a/R/visualization.R +++ b/R/visualization.R @@ -2,8 +2,7 @@ # Scatter Plots of DimRed #### #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -#' Generate Dimensionality Reduction Plot with Coloring -#' @description some text +#' @rdname plotDimRed #' @param object A \linkS4class{liger} object. #' @param useCluster Name of variable in \code{cellMeta(object)}. Default #' \code{NULL} uses default cluster. @@ -30,10 +29,6 @@ #' for gene expression and \code{"D"} ("viridis") for factor loading. #' @return ggplot object when only one feature (e.g. cluster variable, gene, #' factor) is set. List object when multiple of those are specified. -#' @seealso Please refer to \code{\link{plotDimRed}}, -#' \code{\link{.ggScatter}}, \code{\link{.ggplotLigerTheme}} for additional -#' graphic setting -#' @rdname plotDimRed #' @export #' @examples #' plotClusterDimRed(pbmcPlot) @@ -182,13 +177,10 @@ plotFactorDimRed <- function( #' \code{\link[cowplot]{plot_grid}}. #' @param legendNRow Arrangement of the legend, number of rows. Default #' \code{1}. -#' @param ... Additional graphic setting arguments passed to -#' \code{\link{plotDimRed}}. +#' @inheritDotParams .ggScatter shapeBy dotOrder dotSize dotAlpha raster labelText labelTextSize seed +#' @inheritDotParams .ggplotLigerTheme subtitle baseSize titleSize subtitleSize xTextSize xTitleSize yTextSize yTitleSize panelBorder colorValues naColor plotly #' @return ggplot object when only one feature (e.g. cluster variable, gene, #' factor) is set. List object when multiple of those are specified. -#' @seealso Please refer to \code{\link{plotDimRed}}, -#' \code{\link{.ggScatter}}, \code{\link{.ggplotLigerTheme}} for additional -#' graphic setting #' @export #' @examples #' plotGroupClusterDimRed(pbmcPlot) @@ -274,6 +266,9 @@ plotGroupClusterDimRed <- function( #' @param groupBy Names of available categorical variable in \code{cellMeta} #' slot. Use \code{FALSE} for no grouping. Default \code{NULL} looks clustering #' result but will not group if no clustering found. +#' @inheritDotParams plotCellViolin slot yFunc cellIdx titles +#' @inheritDotParams .ggCellViolin violin violinAlpha violinWidth box boxAlpha boxWidth dot dotColor dotSize raster seed +#' @inheritDotParams .ggplotLigerTheme subtitle xlab ylab legendFillTitle showLegend legendPosition baseSize titleSize subtitleSize xTextSize xTitleSize yTextSize yTitleSize legendTextSize legendTitleSize legendNRow legendNCol colorLabels colorValues panelBorder plotly #' @param ... Additional arguments passed to \code{\link{plotCellViolin}}. #' @return ggplot if using a single gene and not splitting by dataset. #' Otherwise, list of ggplot. @@ -623,7 +618,7 @@ plotProportionPie <- function( #' \code{1} if not set. #' @param dotJitter Logical, whether to jitter the dot to avoid overlapping #' within a box when many dots are presented. Default \code{FALSE}. -#' @inheritDotParams .ggplotLigerTheme title subtitle xlab ylab legendColorTitle legendFillTitle legendShapeTitle legendSizeTitle showLegend legendPosition baseSize titleSize subtitleSize xTextSize xTitleSize yTextSize yTitleSize legendTextSize legendTitleSize panelBorder legendNRow legendNCol colorLabels colorValues colorPalette colorDirection naColor colorLow colorMid colorHigh colorMidPoint plotly +#' @inheritDotParams .ggplotLigerTheme title subtitle xlab ylab legendFillTitle showLegend legendPosition baseSize titleSize subtitleSize xTextSize xTitleSize yTextSize yTitleSize legendTextSize legendTitleSize panelBorder legendNRow legendNCol colorLabels colorValues colorPalette colorDirection naColor colorLow colorMid colorHigh colorMidPoint plotly #' @export #' @return A ggplot object or a list of ggplot objects if #' \code{splitByCluster = TRUE}. @@ -770,10 +765,10 @@ plotProportionBox <- function( #' \code{EnhancedVolcano::EnhancedVolcano()}, which has provides #' substantial amount of arguments for graphical control. However, that requires #' the installation of package "EnhancedVolcano". -#' @rdname plotVolcano #' @param result Data frame table returned by \code{\link{runMarkerDEG}} or #' \code{\link{runPairwiseDEG}}. -#' @param group Selection of one group available from \code{result$group} +#' @param group Selection of one group available from \code{result$group}. If +#' only one group is available from \code{result}, default \code{NULL} uses it. #' @param logFCThresh Number for the threshold on the absolute value of the log2 #' fold change statistics. Default \code{1}. #' @param padjThresh Number for the threshold on the adjusted p-value @@ -787,9 +782,8 @@ plotProportionBox <- function( #' \code{"top"}. #' @param labelSize Size of labeled top features and line annotations. Default #' \code{4}. -#' @param ... For \code{plotVolcano}, more theme setting arguments passed to -#' \code{\link{.ggplotLigerTheme}}. For \code{plotEnhancedVolcano}, arguments -#' passed to \code{EnhancedVolcano::EnhancedVolcano()}. +#' @inheritDotParams .ggScatter dotOrder raster labelText labelTextSize seed +#' @inheritDotParams .ggplotLigerTheme title subtitle legendColorTitle showLegend baseSize titleSize subtitleSize xTextSize xTitleSize yTextSize yTitleSize legendTextSize legendTitleSize panelBorder #' @return ggplot #' @export #' @examples @@ -800,14 +794,12 @@ plotProportionBox <- function( #' groupTest = "stim", #' groupCtrl = "ctrl", #' variable1 = "dataset", -#' splitBy = "defaultCluster", -#' nPsdRep = 3, -#' minCellPerRep = 3 +#' splitBy = "defaultCluster" #' ) #' plotVolcano(result, "0.stim") plotVolcano <- function( result, - group, + group = NULL, logFCThresh = 1, padjThresh = 0.01, labelTopN = 20, @@ -817,9 +809,20 @@ plotVolcano <- function( labelSize = 4, ... ) { - if (!group %in% result$group) { + if (!is.factor(result$group)) result$group <- factor(result$group) + result$group <- droplevels(result$group) + if (is.null(group)) { + if (nlevels(result$group) == 1) group <- levels(result$group) + else { + cli::cli_abort( + c("Please specify one group to visualize", + i = "Available ones: {.val {levels(result$group)}}") + ) + } + } else if (length(group) != 1 || + !group %in% result$group) { cli::cli_abort( - c("Selected group does not exist in {.code result$group}", + c("Please specify one available group to visualize", i = "Available ones: {.val {unique(result$group)}}") ) } @@ -892,8 +895,26 @@ plotVolcano <- function( return(p) } -#' @rdname plotVolcano +#' Create volcano plot with EnhancedVolcano +#' @inheritParams plotVolcano +#' @param ... Arguments passed to EnhancedVolcano::EnhancedVolcano(), except +#' that \code{toptable}, \code{lab}, \code{x} and \code{y} are prefilled by this +#' wrapper. +#' @returns ggplot #' @export +#' @examples +#' if (requireNamespace("EnhancedVolcano", quietly = TRUE)) { +#' defaultCluster(pbmc) <- pbmcPlot$leiden_cluster +#' # Test the DEG between "stim" and "ctrl", within each cluster +#' result <- runPairwiseDEG( +#' pbmc, +#' groupTest = "stim", +#' groupCtrl = "ctrl", +#' variable1 = "dataset", +#' splitBy = "defaultCluster" +#' ) +#' plotEnhancedVolcano(result, "0.stim") +#' } plotEnhancedVolcano <- function( result, group, @@ -955,8 +976,7 @@ plotEnhancedVolcano <- function( #' \code{\link[ggplot2]{scale_fill_viridis_c}}. Default \code{"magma"}. #' @param colorDirection Color gradient direction for #' \code{\link[ggplot2]{scale_fill_viridis_c}}. Default \code{-1}. -#' @param ... More theme setting arguments passed to -#' \code{\link{.ggplotLigerTheme}}. +#' @inheritDotParams .ggplotLigerTheme title subtitle xlab ylab showLegend legendPosition baseSize titleSize xTitleSize yTitleSize legendTitleSize subtitleSize xTextSize yTextSize legendTextSize panelBorder plotly #' @return A ggplot object when only one plot is generated, A ggplot object #' combined with \code{\link[cowplot]{plot_grid}} when multiple plots and #' \code{combinePlot = TRUE}. A list of ggplot when multiple plots and @@ -1115,8 +1135,9 @@ plotDensityDimRed <- function( #' Default \code{15}. #' @param nPlot Integer, number of top genes to be shown in the loading rank #' plot. Default \code{30}. -#' @param ... Additional plot theme setting arguments passed to -#' \code{\link{.ggScatter}} and \code{\link{.ggplotLigerTheme}}. +#' @inheritDotParams plotDimRed colorByFunc cellIdx shapeBy titles +#' @inheritDotParams .ggScatter dotSize dotAlpha trimHigh trimLow raster +#' @inheritDotParams .ggplotLigerTheme xlab ylab legendColorTitle legendShapeTitle showLegend legendPosition baseSize titleSize subtitleSize xTextSize xTitleSize yTextSize yTitleSize legendTextSize legendTitleSize colorPalette colorDirection naColor panelBorder #' @export #' @examples #' result <- getFactorMarkers(pbmcPlot, "ctrl", "stim") @@ -1130,12 +1151,42 @@ plotGeneLoadings <- function( nPlot = 30, ... ) { - p1 <- plotDimRed( - object, colorBy = useFactor, useDimRed = useDimRed, slot = "H.norm", - zeroAsNA = TRUE, dotOrder = "asc", splitBy = NULL, ... + allDotArgs <- list(...) + pdrArgs <- names(as.list(args(plotDimRed))) + pglrArgs <- names(as.list(args(plotGeneLoadingRank))) + pdrDotArgs <- intersect(names(allDotArgs), pdrArgs) + pglrDotArgs <- intersect(names(allDotArgs), pglrArgs) + otherDotArgs <- setdiff(names(allDotArgs), c(pdrDotArgs, pglrDotArgs)) + p1 <- do.call( + what = plotDimRed, + args = c( + list( + object = object, + colorBy = useFactor, + useDimRed = useDimRed, + slot = "H.norm", + zeroAsNA = TRUE, + dotOrder = "asc", + splitBy = NULL + ), + allDotArgs[pdrDotArgs], + allDotArgs[otherDotArgs] + ) + ) + bottom <- do.call( + what = plotGeneLoadingRank, + args = c( + list( + object = object, + markerTable = markerTable, + useFactor = useFactor, + nLabel = nLabel, + nPlot = nPlot + ), + allDotArgs[pglrDotArgs], + allDotArgs[otherDotArgs] + ) ) - bottom <- plotGeneLoadingRank(object, markerTable, useFactor, - nLabel, nPlot, ...) bottom <- bottom[c(1, 3, 2)] bottomComb <- cowplot::plot_grid(plotlist = bottom, nrow = 1) cowplot::plot_grid(p1, bottomComb, nrow = 2) @@ -1430,21 +1481,23 @@ makeRiverplot <- function(object, cluster1, cluster2, cluster_consensus = NULL, #' Visualize a spatial dataset +#' @description +#' Simple visualization of spatial coordinates. See example code for how to have +#' information preset in the object. Arguments to the liger object method are +#' passed down to ligerDataset method. #' @export #' @rdname plotSpatial #' @param object Either a \linkS4class{liger} object containing a spatial #' dataset or a \linkS4class{ligerSpatialDataset} object. -#' @param ... Arguments passed to other methods. \code{.liger} method passes -#' everything to \code{.ligerSpatialDataset} method, and the latter passes -#' everything to \code{\link{.ggScatter}} and then -#' \code{\link{.ggplotLigerTheme}}. +#' @inheritDotParams .ggScatter dotOrder dotSize dotAlpha raster labelTextSize seed +#' @inheritDotParams .ggplotLigerTheme title subtitle showLegend legendPosition baseSize titleSize xTitleSize yTitleSize legendTitleSize subtitleSize xTextSize yTextSize legendTextSize legendDotSize legendNRow legendNCol colorLabels colorValues naColor #' @return A ggplot object #' @examples #' ctrl.fake.spatial <- as.ligerDataset(dataset(pbmc, "ctrl"), modal = "spatial") #' fake.coords <- matrix(rnorm(2 * ncol(ctrl.fake.spatial)), ncol = 2) -#' dimnames(fake.coords) <- list(colnames(ctrl.fake.spatial), c("x", "y")) #' coordinate(ctrl.fake.spatial) <- fake.coords #' dataset(pbmc, "ctrl") <- ctrl.fake.spatial +#' defaultCluster(pbmc) <- pbmcPlot$leiden_cluster #' plotSpatial2D(pbmc, dataset = "ctrl") plotSpatial2D <- function(object, ...) { UseMethod("plotSpatial2D", object) @@ -1493,6 +1546,8 @@ plotSpatial2D.liger <- function( #' it. #' @param labelText Logical, whether to label annotation onto the scatter plot. #' Default \code{FALSE}. +#' @param panelBorder Whether to show rectangle border of the panel instead of +#' using ggplot classic bottom and left axis lines. Default \code{TRUE}. plotSpatial2D.ligerSpatialDataset <- function( object, useCluster = NULL, @@ -1501,6 +1556,7 @@ plotSpatial2D.ligerSpatialDataset <- function( xlab = NULL, ylab = NULL, labelText = FALSE, + panelBorder = TRUE, ...) { .checkArgLen(useCluster, ncol(object), repN = FALSE, class = "factor") @@ -1516,21 +1572,20 @@ plotSpatial2D.ligerSpatialDataset <- function( if (is.null(useCluster)) { .ggScatter(plotDF = plotDF, x = "x", y = "y", - xlab = xlab, ylab = ylab, ...) + - ggplot2::theme_bw() + - ggplot2::theme(panel.grid = ggplot2::element_blank(), - axis.ticks = ggplot2::element_blank(), - axis.text = ggplot2::element_blank()) + + xlab = xlab, ylab = ylab, panelBorder = panelBorder, ...) + + ggplot2::theme(axis.ticks = ggplot2::element_blank(), + axis.text.x = ggplot2::element_blank(), + axis.text.y = ggplot2::element_blank()) + ggplot2::coord_fixed(xlim = xRange, ylim = yRange) } else { plotDF[[legendColorTitle]] <- factor(useCluster) .ggScatter(plotDF = plotDF, x = "x", y = "y", colorBy = legendColorTitle, xlab = xlab, ylab = ylab, labelText = labelText, - legendColorTitle = legendColorTitle, ...) + - ggplot2::theme_bw() + - ggplot2::theme(panel.grid = ggplot2::element_blank(), - axis.ticks = ggplot2::element_blank(), - axis.text = ggplot2::element_blank()) + + legendColorTitle = legendColorTitle, + panelBorder = panelBorder, ...) + + ggplot2::theme(axis.ticks = ggplot2::element_blank(), + axis.text.x = ggplot2::element_blank(), + axis.text.y = ggplot2::element_blank()) + ggplot2::coord_fixed(xlim = xRange, ylim = yRange) } } diff --git a/man/dot-ggScatter.Rd b/man/dot-ggScatter.Rd index 7de33ec..003bdac 100644 --- a/man/dot-ggScatter.Rd +++ b/man/dot-ggScatter.Rd @@ -50,7 +50,7 @@ continuous \code{colorBy} variable. Default \code{NULL}.} \code{colorBy} variable to \code{NA} so the color of these value.} \item{raster}{Logical, whether to rasterize the plot. Default \code{NULL} -automatically rasterize the plot when number of total cells to be plotted +automatically rasterize the plot when number of total dots to be plotted exceeds 100,000.} \item{labelBy}{A variable name available in \code{plotDF}. If the variable is diff --git a/man/dot-ggplotLigerTheme.Rd b/man/dot-ggplotLigerTheme.Rd index 533dfab..2b87e06 100644 --- a/man/dot-ggplotLigerTheme.Rd +++ b/man/dot-ggplotLigerTheme.Rd @@ -51,9 +51,20 @@ By default, no main title or subtitle will be set, and X/Y axis title will be the names of variables used for plotting. Use \code{NULL} to hide elements. \code{TRUE} for \code{xlab} or \code{ylab} shows default values.} -\item{legendColorTitle, legendFillTitle, legendShapeTitle, legendSizeTitle}{Set -alternative title text for legend on aes of color, fill, shape and size, -respectively. Default \code{NULL} shows the original variable name.} +\item{legendColorTitle}{Legend title text for color aesthetics, often used +for categorical or continuous coloring of dots. Default \code{NULL} shows the +original variable name.} + +\item{legendFillTitle}{Legend title text for fill aesthetics, often used for +violin, box, bar plots. Default \code{NULL} shows the original variable name.} + +\item{legendShapeTitle}{Legend title text for shape aesthetics, often used +for shaping dots by categorical variable. Default \code{NULL} shows the +original variable name.} + +\item{legendSizeTitle}{Legend title text for size aesthetics, often used for +sizing dots by continuous variable. Default \code{NULL} shows the original +variable name.} \item{showLegend}{Whether to show the legend. Default \code{TRUE}.} @@ -85,12 +96,14 @@ using ggplot classic bottom and left axis lines. Default \code{FALSE}.} variable, arranges number of rows or columns. Default \code{NULL}, automatically split to \code{ceiling(levels(variable)/10)} columns.} -\item{colorLabels, colorValues}{Each a vector with as many values as the -number of categories for the categorical coloring aesthetics. Labels will be -the shown text and values will be the color code. These are passed to -\code{\link[ggplot2]{scale_color_manual}}. Default uses an internal selected -palette if there are <= 26 colors needed, or ggplot hues otherwise, and plot -original labels (levels of the factor).} +\item{colorLabels}{Character vector for modifying category names in a +color legend. Passed to \code{ggplot2::scale_color_manual(labels)}. Default +\code{NULL} uses original levels of the factor.} + +\item{colorValues}{Character vector of colors for modifying category colors +in a color legend. Passed to \code{ggplot2::scale_color_manual(values)}. +Default \code{NULL} uses internal selected palette when <= 26 categories are +presented, otherwise ggplot hues.} \item{colorPalette}{For continuous coloring, an index or a palette name to select from available options from ggplot diff --git a/man/plotBarcodeRank.Rd b/man/plotBarcodeRank.Rd index 7cb98e6..cef4d5f 100644 --- a/man/plotBarcodeRank.Rd +++ b/man/plotBarcodeRank.Rd @@ -15,7 +15,7 @@ plotBarcodeRank(object, ...) \item{\code{dotSize,dotAlpha}}{Numeric, controls the size or transparency of all dots. Default \code{getOption("ligerDotSize")} (1) and \code{0.9}.} \item{\code{raster}}{Logical, whether to rasterize the plot. Default \code{NULL} -automatically rasterize the plot when number of total cells to be plotted +automatically rasterize the plot when number of total dots to be plotted exceeds 100,000.} \item{\code{title,subtitle,xlab,ylab}}{Main title, subtitle or X/Y axis title text. By default, no main title or subtitle will be set, and X/Y axis title will be diff --git a/man/plotDensityDimRed.Rd b/man/plotDensityDimRed.Rd index 75f9af8..c0196a0 100644 --- a/man/plotDensityDimRed.Rd +++ b/man/plotDensityDimRed.Rd @@ -74,8 +74,31 @@ of character vector input should match with number of plots generated.} \item{colorDirection}{Color gradient direction for \code{\link[ggplot2]{scale_fill_viridis_c}}. Default \code{-1}.} -\item{...}{More theme setting arguments passed to -\code{\link{.ggplotLigerTheme}}.} +\item{...}{ + Arguments passed on to \code{\link[=.ggplotLigerTheme]{.ggplotLigerTheme}} + \describe{ + \item{\code{title,subtitle,xlab,ylab}}{Main title, subtitle or X/Y axis title text. +By default, no main title or subtitle will be set, and X/Y axis title will be +the names of variables used for plotting. Use \code{NULL} to hide elements. +\code{TRUE} for \code{xlab} or \code{ylab} shows default values.} + \item{\code{showLegend}}{Whether to show the legend. Default \code{TRUE}.} + \item{\code{legendPosition}}{Text indicating where to place the legend. Choose from +\code{"top"}, \code{"bottom"}, \code{"left"} or \code{"right"}. Default +\code{"right"}.} + \item{\code{baseSize}}{One-parameter control of all text sizes. Individual text +element sizes can be controlled by other size arguments. "Title" sizes are +2 points larger than "text" sizes when being controlled by this.} + \item{\code{titleSize,xTitleSize,yTitleSize,legendTitleSize}}{Size of main title, +axis titles and legend title. Default \code{NULL} controls by +\code{baseSize + 2}.} + \item{\code{subtitleSize,xTextSize,yTextSize,legendTextSize}}{Size of subtitle text, +axis texts and legend text. Default \code{NULL} controls by \code{baseSize}.} + \item{\code{panelBorder}}{Whether to show rectangle border of the panel instead of +using ggplot classic bottom and left axis lines. Default \code{FALSE}.} + \item{\code{plotly}}{Whether to use plotly to enable web based interactive browsing +for the plot. Requires installation of package "plotly". Default +\code{FALSE}.} + }} } \value{ A ggplot object when only one plot is generated, A ggplot object diff --git a/man/plotDimRed.Rd b/man/plotDimRed.Rd index 1b7b98d..f7e39c5 100644 --- a/man/plotDimRed.Rd +++ b/man/plotDimRed.Rd @@ -102,8 +102,79 @@ categorical annotation to be reflected by dot shapes. Default \code{NULL}.} many elements as multiple plots are supposed to be generated. Default \code{NULL}.} -\item{...}{More plot setting arguments. See \code{\link{.ggScatter}} and -\code{\link{.ggplotLigerTheme}}.} +\item{...}{ + Arguments passed on to \code{\link[=.ggScatter]{.ggScatter}}, \code{\link[=.ggplotLigerTheme]{.ggplotLigerTheme}} + \describe{ + \item{\code{dotOrder}}{Controls the order that each dot is added to the plot. Choose +from \code{"shuffle"}, \code{"ascending"}, or \code{"descending"}. Default +\code{"shuffle"}, useful when coloring by categories that overlaps (e.g. +"dataset"), \code{"ascending"} can be useful when coloring by a continuous +variable (e.g. gene expression) where high values needs more +highlight. \code{NULL} use default order.} + \item{\code{dotSize,dotAlpha}}{Numeric, controls the size or transparency of all +dots. Default \code{getOption("ligerDotSize")} (1) and \code{0.9}.} + \item{\code{trimHigh,trimLow}}{Numeric, limit the largest or smallest value of +continuous \code{colorBy} variable. Default \code{NULL}.} + \item{\code{raster}}{Logical, whether to rasterize the plot. Default \code{NULL} +automatically rasterize the plot when number of total dots to be plotted +exceeds 100,000.} + \item{\code{labelBy}}{A variable name available in \code{plotDF}. If the variable is +categorical (a factor), the label position will be the median coordinates of +all dots within the same group. Unique labeling in character vector for each +dot is also acceptable. Default \code{colorBy}.} + \item{\code{labelText}}{Logical, whether to show text label at the median position +of each categorical group specified by \code{colorBy}. Default \code{TRUE}. +Does not work when continuous coloring is specified.} + \item{\code{labelTextSize}}{Numeric, controls the size of label size when +\code{labelText = TRUE}. Default \code{4}.} + \item{\code{seed}}{Random seed for reproducibility. Default \code{1}.} + \item{\code{title,subtitle,xlab,ylab}}{Main title, subtitle or X/Y axis title text. +By default, no main title or subtitle will be set, and X/Y axis title will be +the names of variables used for plotting. Use \code{NULL} to hide elements. +\code{TRUE} for \code{xlab} or \code{ylab} shows default values.} + \item{\code{legendColorTitle}}{Legend title text for color aesthetics, often used +for categorical or continuous coloring of dots. Default \code{NULL} shows the +original variable name.} + \item{\code{legendShapeTitle}}{Legend title text for shape aesthetics, often used +for shaping dots by categorical variable. Default \code{NULL} shows the +original variable name.} + \item{\code{showLegend}}{Whether to show the legend. Default \code{TRUE}.} + \item{\code{legendPosition}}{Text indicating where to place the legend. Choose from +\code{"top"}, \code{"bottom"}, \code{"left"} or \code{"right"}. Default +\code{"right"}.} + \item{\code{baseSize}}{One-parameter control of all text sizes. Individual text +element sizes can be controlled by other size arguments. "Title" sizes are +2 points larger than "text" sizes when being controlled by this.} + \item{\code{titleSize,xTitleSize,yTitleSize,legendTitleSize}}{Size of main title, +axis titles and legend title. Default \code{NULL} controls by +\code{baseSize + 2}.} + \item{\code{subtitleSize,xTextSize,yTextSize,legendTextSize}}{Size of subtitle text, +axis texts and legend text. Default \code{NULL} controls by \code{baseSize}.} + \item{\code{legendDotSize}}{Allow dots in legend region to be large enough to see +the colors/shapes clearly. Default \code{4}.} + \item{\code{panelBorder}}{Whether to show rectangle border of the panel instead of +using ggplot classic bottom and left axis lines. Default \code{FALSE}.} + \item{\code{colorLabels}}{Character vector for modifying category names in a +color legend. Passed to \code{ggplot2::scale_color_manual(labels)}. Default +\code{NULL} uses original levels of the factor.} + \item{\code{colorValues}}{Character vector of colors for modifying category colors +in a color legend. Passed to \code{ggplot2::scale_color_manual(values)}. +Default \code{NULL} uses internal selected palette when <= 26 categories are +presented, otherwise ggplot hues.} + \item{\code{legendNRow,legendNCol}}{Integer, when too many categories in one +variable, arranges number of rows or columns. Default \code{NULL}, +automatically split to \code{ceiling(levels(variable)/10)} columns.} + \item{\code{colorDirection}}{Choose \code{1} or \code{-1}. Applied when +\code{colorPalette} is from Viridis options. Default \code{-1} use darker +color for higher value, while \code{1} reverses this direction.} + \item{\code{colorLow,colorMid,colorHigh,colorMidPoint}}{All four of these must be +specified to customize palette with} + \item{\code{naColor}}{The color code for \code{NA} values. Default \code{"#DEDEDE"}. +\code{\link[ggplot2]{scale_colour_gradient2}}. Default \code{NULL}.} + \item{\code{plotly}}{Whether to use plotly to enable web based interactive browsing +for the plot. Requires installation of package "plotly". Default +\code{FALSE}.} + }} \item{useCluster}{Name of variable in \code{cellMeta(object)}. Default \code{NULL} uses default cluster.} @@ -151,8 +222,6 @@ unnormalized or aligned factor loading. Multiple coloring variable is allowed from the same specification of \code{slot}, and this returns a list of plots with different coloring values. Users can further split the plot(s) by grouping on cells (e.g. datasets). - -some text } \details{ Available option for \code{slot} include: \code{"cellMeta"}, @@ -188,8 +257,3 @@ plotByDatasetAndCluster(pbmcPlot) plotGeneDimRed(pbmcPlot, varFeatures(pbmcPlot)[1]) plotFactorDimRed(pbmcPlot, 2) } -\seealso{ -Please refer to \code{\link{plotDimRed}}, -\code{\link{.ggScatter}}, \code{\link{.ggplotLigerTheme}} for additional -graphic setting -} diff --git a/man/plotEnhancedVolcano.Rd b/man/plotEnhancedVolcano.Rd new file mode 100644 index 0000000..b4453a4 --- /dev/null +++ b/man/plotEnhancedVolcano.Rd @@ -0,0 +1,39 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/visualization.R +\name{plotEnhancedVolcano} +\alias{plotEnhancedVolcano} +\title{Create volcano plot with EnhancedVolcano} +\usage{ +plotEnhancedVolcano(result, group, ...) +} +\arguments{ +\item{result}{Data frame table returned by \code{\link{runMarkerDEG}} or +\code{\link{runPairwiseDEG}}.} + +\item{group}{Selection of one group available from \code{result$group}. If +only one group is available from \code{result}, default \code{NULL} uses it.} + +\item{...}{Arguments passed to EnhancedVolcano::EnhancedVolcano(), except +that \code{toptable}, \code{lab}, \code{x} and \code{y} are prefilled by this +wrapper.} +} +\value{ +ggplot +} +\description{ +Create volcano plot with EnhancedVolcano +} +\examples{ +if (requireNamespace("EnhancedVolcano", quietly = TRUE)) { + defaultCluster(pbmc) <- pbmcPlot$leiden_cluster + # Test the DEG between "stim" and "ctrl", within each cluster + result <- runPairwiseDEG( + pbmc, + groupTest = "stim", + groupCtrl = "ctrl", + variable1 = "dataset", + splitBy = "defaultCluster" + ) + plotEnhancedVolcano(result, "0.stim") +} +} diff --git a/man/plotGODot.Rd b/man/plotGODot.Rd index f69976e..3372dc4 100644 --- a/man/plotGODot.Rd +++ b/man/plotGODot.Rd @@ -41,6 +41,12 @@ considered as significant. Default \code{0.05}.} \item{...}{ Arguments passed on to \code{\link[=.ggplotLigerTheme]{.ggplotLigerTheme}} \describe{ + \item{\code{legendColorTitle}}{Legend title text for color aesthetics, often used +for categorical or continuous coloring of dots. Default \code{NULL} shows the +original variable name.} + \item{\code{legendSizeTitle}}{Legend title text for size aesthetics, often used for +sizing dots by continuous variable. Default \code{NULL} shows the original +variable name.} \item{\code{showLegend}}{Whether to show the legend. Default \code{TRUE}.} \item{\code{legendPosition}}{Text indicating where to place the legend. Choose from \code{"top"}, \code{"bottom"}, \code{"left"} or \code{"right"}. Default diff --git a/man/plotGeneLoadings.Rd b/man/plotGeneLoadings.Rd index 6aad65c..bfd2ef4 100644 --- a/man/plotGeneLoadings.Rd +++ b/man/plotGeneLoadings.Rd @@ -40,8 +40,58 @@ Default \code{15}.} \item{nPlot}{Integer, number of top genes to be shown in the loading rank plot. Default \code{30}.} -\item{...}{Additional plot theme setting arguments passed to -\code{\link{.ggScatter}} and \code{\link{.ggplotLigerTheme}}.} +\item{...}{ + Arguments passed on to \code{\link[=plotDimRed]{plotDimRed}}, \code{\link[=.ggScatter]{.ggScatter}}, \code{\link[=.ggplotLigerTheme]{.ggplotLigerTheme}} + \describe{ + \item{\code{colorByFunc}}{Default \code{NULL}. A function object that expects a +vector/factor/data.frame retrieved by \code{colorBy} as the only input, and +returns an object of the same size, so that the all color "aes" are replaced +by this output. Useful when, for example, users need to scale the gene +expression shown on plot.} + \item{\code{cellIdx}}{Character, logical or numeric index that can subscribe cells. +Missing or \code{NULL} for all cells.} + \item{\code{shapeBy}}{Available variable name in \code{cellMeta} slot to look for +categorical annotation to be reflected by dot shapes. Default \code{NULL}.} + \item{\code{titles}}{Title text. A character scalar or a character vector with as +many elements as multiple plots are supposed to be generated. Default +\code{NULL}.} + \item{\code{dotSize,dotAlpha}}{Numeric, controls the size or transparency of all +dots. Default \code{getOption("ligerDotSize")} (1) and \code{0.9}.} + \item{\code{trimHigh,trimLow}}{Numeric, limit the largest or smallest value of +continuous \code{colorBy} variable. Default \code{NULL}.} + \item{\code{raster}}{Logical, whether to rasterize the plot. Default \code{NULL} +automatically rasterize the plot when number of total dots to be plotted +exceeds 100,000.} + \item{\code{legendColorTitle}}{Legend title text for color aesthetics, often used +for categorical or continuous coloring of dots. Default \code{NULL} shows the +original variable name.} + \item{\code{legendShapeTitle}}{Legend title text for shape aesthetics, often used +for shaping dots by categorical variable. Default \code{NULL} shows the +original variable name.} + \item{\code{showLegend}}{Whether to show the legend. Default \code{TRUE}.} + \item{\code{legendPosition}}{Text indicating where to place the legend. Choose from +\code{"top"}, \code{"bottom"}, \code{"left"} or \code{"right"}. Default +\code{"right"}.} + \item{\code{baseSize}}{One-parameter control of all text sizes. Individual text +element sizes can be controlled by other size arguments. "Title" sizes are +2 points larger than "text" sizes when being controlled by this.} + \item{\code{titleSize,xTitleSize,yTitleSize,legendTitleSize}}{Size of main title, +axis titles and legend title. Default \code{NULL} controls by +\code{baseSize + 2}.} + \item{\code{subtitleSize,xTextSize,yTextSize,legendTextSize}}{Size of subtitle text, +axis texts and legend text. Default \code{NULL} controls by \code{baseSize}.} + \item{\code{panelBorder}}{Whether to show rectangle border of the panel instead of +using ggplot classic bottom and left axis lines. Default \code{FALSE}.} + \item{\code{colorPalette}}{For continuous coloring, an index or a palette name to +select from available options from ggplot +\code{\link[ggplot2]{scale_brewer}} or \code{\link[viridisLite]{viridis}}. +Default \code{"magma"}.} + \item{\code{colorDirection}}{Choose \code{1} or \code{-1}. Applied when +\code{colorPalette} is from Viridis options. Default \code{-1} use darker +color for higher value, while \code{1} reverses this direction.} + \item{\code{naColor}}{The color code for \code{NA} values. Default \code{"#DEDEDE"}. +\code{\link[ggplot2]{scale_colour_gradient2}}. Default \code{NULL}.} + }} } \description{ Visualize factor expression and gene loading diff --git a/man/plotGroupClusterDimRed.Rd b/man/plotGroupClusterDimRed.Rd index 16d6459..879e17b 100644 --- a/man/plotGroupClusterDimRed.Rd +++ b/man/plotGroupClusterDimRed.Rd @@ -55,8 +55,41 @@ of rows and columns. Default \code{NULL} will be automatically handled by \item{legendNRow}{Arrangement of the legend, number of rows. Default \code{1}.} -\item{...}{Additional graphic setting arguments passed to -\code{\link{plotDimRed}}.} +\item{...}{ + Arguments passed on to \code{\link[=.ggScatter]{.ggScatter}}, \code{\link[=.ggplotLigerTheme]{.ggplotLigerTheme}} + \describe{ + \item{\code{dotOrder}}{Controls the order that each dot is added to the plot. Choose +from \code{"shuffle"}, \code{"ascending"}, or \code{"descending"}. Default +\code{"shuffle"}, useful when coloring by categories that overlaps (e.g. +"dataset"), \code{"ascending"} can be useful when coloring by a continuous +variable (e.g. gene expression) where high values needs more +highlight. \code{NULL} use default order.} + \item{\code{dotSize,dotAlpha}}{Numeric, controls the size or transparency of all +dots. Default \code{getOption("ligerDotSize")} (1) and \code{0.9}.} + \item{\code{raster}}{Logical, whether to rasterize the plot. Default \code{NULL} +automatically rasterize the plot when number of total dots to be plotted +exceeds 100,000.} + \item{\code{labelText}}{Logical, whether to show text label at the median position +of each categorical group specified by \code{colorBy}. Default \code{TRUE}. +Does not work when continuous coloring is specified.} + \item{\code{labelTextSize}}{Numeric, controls the size of label size when +\code{labelText = TRUE}. Default \code{4}.} + \item{\code{seed}}{Random seed for reproducibility. Default \code{1}.} + \item{\code{baseSize}}{One-parameter control of all text sizes. Individual text +element sizes can be controlled by other size arguments. "Title" sizes are +2 points larger than "text" sizes when being controlled by this.} + \item{\code{panelBorder}}{Whether to show rectangle border of the panel instead of +using ggplot classic bottom and left axis lines. Default \code{FALSE}.} + \item{\code{colorValues}}{Character vector of colors for modifying category colors +in a color legend. Passed to \code{ggplot2::scale_color_manual(values)}. +Default \code{NULL} uses internal selected palette when <= 26 categories are +presented, otherwise ggplot hues.} + \item{\code{naColor}}{The color code for \code{NA} values. Default \code{"#DEDEDE"}. +\code{\link[ggplot2]{scale_colour_gradient2}}. Default \code{NULL}.} + \item{\code{plotly}}{Whether to use plotly to enable web based interactive browsing +for the plot. Requires installation of package "plotly". Default +\code{FALSE}.} + }} } \value{ ggplot object when only one feature (e.g. cluster variable, gene, @@ -72,8 +105,3 @@ subplot of each group. \examples{ plotGroupClusterDimRed(pbmcPlot) } -\seealso{ -Please refer to \code{\link{plotDimRed}}, -\code{\link{.ggScatter}}, \code{\link{.ggplotLigerTheme}} for additional -graphic setting -} diff --git a/man/plotPairwiseDEGHeatmap.Rd b/man/plotPairwiseDEGHeatmap.Rd index 60927b4..621d916 100644 --- a/man/plotPairwiseDEGHeatmap.Rd +++ b/man/plotPairwiseDEGHeatmap.Rd @@ -53,6 +53,8 @@ specified. Default \code{200}.} \item{column_title}{Title on the column. Default \code{NULL}.} +\item{seed}{Random seed for reproducibility. Default \code{1}.} + \item{...}{Parameter passed to wrapped functions in the inheritance order: \code{\link{plotGeneHeatmap}}, \code{\link{.plotHeatmap}}, \code{ComplexHeatmap::\link[ComplexHeatmap]{Heatmap}}} diff --git a/man/plotProportionBox.Rd b/man/plotProportionBox.Rd index ec90ddc..7b52814 100644 --- a/man/plotProportionBox.Rd +++ b/man/plotProportionBox.Rd @@ -49,9 +49,8 @@ within a box when many dots are presented. Default \code{FALSE}.} By default, no main title or subtitle will be set, and X/Y axis title will be the names of variables used for plotting. Use \code{NULL} to hide elements. \code{TRUE} for \code{xlab} or \code{ylab} shows default values.} - \item{\code{legendColorTitle,legendFillTitle,legendShapeTitle,legendSizeTitle}}{Set -alternative title text for legend on aes of color, fill, shape and size, -respectively. Default \code{NULL} shows the original variable name.} + \item{\code{legendFillTitle}}{Legend title text for fill aesthetics, often used for +violin, box, bar plots. Default \code{NULL} shows the original variable name.} \item{\code{showLegend}}{Whether to show the legend. Default \code{TRUE}.} \item{\code{legendPosition}}{Text indicating where to place the legend. Choose from \code{"top"}, \code{"bottom"}, \code{"left"} or \code{"right"}. Default @@ -66,12 +65,13 @@ axis titles and legend title. Default \code{NULL} controls by axis texts and legend text. Default \code{NULL} controls by \code{baseSize}.} \item{\code{panelBorder}}{Whether to show rectangle border of the panel instead of using ggplot classic bottom and left axis lines. Default \code{FALSE}.} - \item{\code{colorLabels,colorValues}}{Each a vector with as many values as the -number of categories for the categorical coloring aesthetics. Labels will be -the shown text and values will be the color code. These are passed to -\code{\link[ggplot2]{scale_color_manual}}. Default uses an internal selected -palette if there are <= 26 colors needed, or ggplot hues otherwise, and plot -original labels (levels of the factor).} + \item{\code{colorLabels}}{Character vector for modifying category names in a +color legend. Passed to \code{ggplot2::scale_color_manual(labels)}. Default +\code{NULL} uses original levels of the factor.} + \item{\code{colorValues}}{Character vector of colors for modifying category colors +in a color legend. Passed to \code{ggplot2::scale_color_manual(values)}. +Default \code{NULL} uses internal selected palette when <= 26 categories are +presented, otherwise ggplot hues.} \item{\code{legendNRow,legendNCol}}{Integer, when too many categories in one variable, arranges number of rows or columns. Default \code{NULL}, automatically split to \code{ceiling(levels(variable)/10)} columns.} diff --git a/man/plotSpatial.Rd b/man/plotSpatial.Rd index 044e3e8..8084b5f 100644 --- a/man/plotSpatial.Rd +++ b/man/plotSpatial.Rd @@ -18,6 +18,7 @@ plotSpatial2D(object, ...) xlab = NULL, ylab = NULL, labelText = FALSE, + panelBorder = TRUE, ... ) } @@ -25,10 +26,50 @@ plotSpatial2D(object, ...) \item{object}{Either a \linkS4class{liger} object containing a spatial dataset or a \linkS4class{ligerSpatialDataset} object.} -\item{...}{Arguments passed to other methods. \code{.liger} method passes -everything to \code{.ligerSpatialDataset} method, and the latter passes -everything to \code{\link{.ggScatter}} and then -\code{\link{.ggplotLigerTheme}}.} +\item{...}{ + Arguments passed on to \code{\link[=.ggScatter]{.ggScatter}}, \code{\link[=.ggplotLigerTheme]{.ggplotLigerTheme}} + \describe{ + \item{\code{dotOrder}}{Controls the order that each dot is added to the plot. Choose +from \code{"shuffle"}, \code{"ascending"}, or \code{"descending"}. Default +\code{"shuffle"}, useful when coloring by categories that overlaps (e.g. +"dataset"), \code{"ascending"} can be useful when coloring by a continuous +variable (e.g. gene expression) where high values needs more +highlight. \code{NULL} use default order.} + \item{\code{dotSize,dotAlpha}}{Numeric, controls the size or transparency of all +dots. Default \code{getOption("ligerDotSize")} (1) and \code{0.9}.} + \item{\code{raster}}{Logical, whether to rasterize the plot. Default \code{NULL} +automatically rasterize the plot when number of total dots to be plotted +exceeds 100,000.} + \item{\code{labelTextSize}}{Numeric, controls the size of label size when +\code{labelText = TRUE}. Default \code{4}.} + \item{\code{seed}}{Random seed for reproducibility. Default \code{1}.} + \item{\code{showLegend}}{Whether to show the legend. Default \code{TRUE}.} + \item{\code{legendPosition}}{Text indicating where to place the legend. Choose from +\code{"top"}, \code{"bottom"}, \code{"left"} or \code{"right"}. Default +\code{"right"}.} + \item{\code{baseSize}}{One-parameter control of all text sizes. Individual text +element sizes can be controlled by other size arguments. "Title" sizes are +2 points larger than "text" sizes when being controlled by this.} + \item{\code{titleSize,xTitleSize,yTitleSize,legendTitleSize}}{Size of main title, +axis titles and legend title. Default \code{NULL} controls by +\code{baseSize + 2}.} + \item{\code{subtitleSize,xTextSize,yTextSize,legendTextSize}}{Size of subtitle text, +axis texts and legend text. Default \code{NULL} controls by \code{baseSize}.} + \item{\code{legendDotSize}}{Allow dots in legend region to be large enough to see +the colors/shapes clearly. Default \code{4}.} + \item{\code{colorLabels}}{Character vector for modifying category names in a +color legend. Passed to \code{ggplot2::scale_color_manual(labels)}. Default +\code{NULL} uses original levels of the factor.} + \item{\code{colorValues}}{Character vector of colors for modifying category colors +in a color legend. Passed to \code{ggplot2::scale_color_manual(values)}. +Default \code{NULL} uses internal selected palette when <= 26 categories are +presented, otherwise ggplot hues.} + \item{\code{legendNRow,legendNCol}}{Integer, when too many categories in one +variable, arranges number of rows or columns. Default \code{NULL}, +automatically split to \code{ceiling(levels(variable)/10)} columns.} + \item{\code{naColor}}{The color code for \code{NA} values. Default \code{"#DEDEDE"}. +\code{\link[ggplot2]{scale_colour_gradient2}}. Default \code{NULL}.} + }} \item{dataset}{Name of one spatial dataset.} @@ -48,18 +89,23 @@ it.} \item{labelText}{Logical, whether to label annotation onto the scatter plot. Default \code{FALSE}.} + +\item{panelBorder}{Whether to show rectangle border of the panel instead of +using ggplot classic bottom and left axis lines. Default \code{TRUE}.} } \value{ A ggplot object } \description{ -Visualize a spatial dataset +Simple visualization of spatial coordinates. See example code for how to have +information preset in the object. Arguments to the liger object method are +passed down to ligerDataset method. } \examples{ ctrl.fake.spatial <- as.ligerDataset(dataset(pbmc, "ctrl"), modal = "spatial") fake.coords <- matrix(rnorm(2 * ncol(ctrl.fake.spatial)), ncol = 2) -dimnames(fake.coords) <- list(colnames(ctrl.fake.spatial), c("x", "y")) coordinate(ctrl.fake.spatial) <- fake.coords dataset(pbmc, "ctrl") <- ctrl.fake.spatial +defaultCluster(pbmc) <- pbmcPlot$leiden_cluster plotSpatial2D(pbmc, dataset = "ctrl") } diff --git a/man/plotViolin.Rd b/man/plotViolin.Rd index e08151a..a60b2a1 100644 --- a/man/plotViolin.Rd +++ b/man/plotViolin.Rd @@ -24,7 +24,63 @@ dataset. Default \code{TRUE}.} slot. Use \code{FALSE} for no grouping. Default \code{NULL} looks clustering result but will not group if no clustering found.} -\item{...}{Additional arguments passed to \code{\link{plotCellViolin}}.} +\item{...}{ + Arguments passed on to \code{\link[=plotCellViolin]{plotCellViolin}}, \code{\link[=.ggCellViolin]{.ggCellViolin}}, \code{\link[=.ggplotLigerTheme]{.ggplotLigerTheme}} + \describe{ + \item{\code{slot}}{Choose the slot to find the \code{y} variable. See Details. +Default \code{"cellMeta"}.} + \item{\code{yFunc}}{A function object that expects a vector/factor/data.frame +retrieved by \code{y} as the only input, and returns an object of the same +size, so that the y-axis is replaced by this output. Useful when, for +example, users need to scale the gene expression shown on plot.} + \item{\code{cellIdx}}{Character, logical or numeric index that can subscribe cells. +Missing or \code{NULL} for all cells.} + \item{\code{titles}}{Title text. A character scalar or a character vector with as +many elements as multiple plots are supposed to be generated. Default +\code{NULL}.} + \item{\code{violin,box,dot}}{Logical, whether to add violin plot, box plot or dot +(scatter) plot, respectively. Layers are added in the order of dot, violin, +and violin on the top surface. By default, only violin plot is generated.} + \item{\code{violinAlpha,boxAlpha}}{Numeric, controls the transparency of layers. +Default \code{0.8}, \code{0.6}, respectively.} + \item{\code{violinWidth,boxWidth}}{Numeric, controls the width of violin/box +bounding box. Default \code{0.9} and \code{0.4}.} + \item{\code{dotColor,dotSize}}{Numeric, globally controls the appearance of all +dots. Default \code{"black"} and \code{getOption("ligerDotSize")} (1).} + \item{\code{raster}}{Logical, whether to rasterize the dot plot. Default \code{NULL} +automatically rasterizes the dot plot when number of total cells to be +plotted exceeds 100,000.} + \item{\code{seed}}{Random seed for reproducibility. Default \code{1}.} + \item{\code{legendFillTitle}}{Legend title text for fill aesthetics, often used for +violin, box, bar plots. Default \code{NULL} shows the original variable name.} + \item{\code{showLegend}}{Whether to show the legend. Default \code{TRUE}.} + \item{\code{legendPosition}}{Text indicating where to place the legend. Choose from +\code{"top"}, \code{"bottom"}, \code{"left"} or \code{"right"}. Default +\code{"right"}.} + \item{\code{baseSize}}{One-parameter control of all text sizes. Individual text +element sizes can be controlled by other size arguments. "Title" sizes are +2 points larger than "text" sizes when being controlled by this.} + \item{\code{titleSize,xTitleSize,yTitleSize,legendTitleSize}}{Size of main title, +axis titles and legend title. Default \code{NULL} controls by +\code{baseSize + 2}.} + \item{\code{subtitleSize,xTextSize,yTextSize,legendTextSize}}{Size of subtitle text, +axis texts and legend text. Default \code{NULL} controls by \code{baseSize}.} + \item{\code{panelBorder}}{Whether to show rectangle border of the panel instead of +using ggplot classic bottom and left axis lines. Default \code{FALSE}.} + \item{\code{colorLabels}}{Character vector for modifying category names in a +color legend. Passed to \code{ggplot2::scale_color_manual(labels)}. Default +\code{NULL} uses original levels of the factor.} + \item{\code{colorValues}}{Character vector of colors for modifying category colors +in a color legend. Passed to \code{ggplot2::scale_color_manual(values)}. +Default \code{NULL} uses internal selected palette when <= 26 categories are +presented, otherwise ggplot hues.} + \item{\code{legendNRow,legendNCol}}{Integer, when too many categories in one +variable, arranges number of rows or columns. Default \code{NULL}, +automatically split to \code{ceiling(levels(variable)/10)} columns.} + \item{\code{plotly}}{Whether to use plotly to enable web based interactive browsing +for the plot. Requires installation of package "plotly". Default +\code{FALSE}.} + }} } \value{ ggplot if using a single gene and not splitting by dataset. diff --git a/man/plotVolcano.Rd b/man/plotVolcano.Rd index b5627f7..20e3f0d 100644 --- a/man/plotVolcano.Rd +++ b/man/plotVolcano.Rd @@ -2,12 +2,11 @@ % Please edit documentation in R/visualization.R \name{plotVolcano} \alias{plotVolcano} -\alias{plotEnhancedVolcano} \title{Create volcano plot for Wilcoxon test result} \usage{ plotVolcano( result, - group, + group = NULL, logFCThresh = 1, padjThresh = 0.01, labelTopN = 20, @@ -17,14 +16,13 @@ plotVolcano( labelSize = 4, ... ) - -plotEnhancedVolcano(result, group, ...) } \arguments{ \item{result}{Data frame table returned by \code{\link{runMarkerDEG}} or \code{\link{runPairwiseDEG}}.} -\item{group}{Selection of one group available from \code{result$group}} +\item{group}{Selection of one group available from \code{result$group}. If +only one group is available from \code{result}, default \code{NULL} uses it.} \item{logFCThresh}{Number for the threshold on the absolute value of the log2 fold change statistics. Default \code{1}.} @@ -45,9 +43,39 @@ Default \code{2} and \code{0.8}.} \item{labelSize}{Size of labeled top features and line annotations. Default \code{4}.} -\item{...}{For \code{plotVolcano}, more theme setting arguments passed to -\code{\link{.ggplotLigerTheme}}. For \code{plotEnhancedVolcano}, arguments -passed to \code{EnhancedVolcano::EnhancedVolcano()}.} +\item{...}{ + Arguments passed on to \code{\link[=.ggScatter]{.ggScatter}}, \code{\link[=.ggplotLigerTheme]{.ggplotLigerTheme}} + \describe{ + \item{\code{dotOrder}}{Controls the order that each dot is added to the plot. Choose +from \code{"shuffle"}, \code{"ascending"}, or \code{"descending"}. Default +\code{"shuffle"}, useful when coloring by categories that overlaps (e.g. +"dataset"), \code{"ascending"} can be useful when coloring by a continuous +variable (e.g. gene expression) where high values needs more +highlight. \code{NULL} use default order.} + \item{\code{raster}}{Logical, whether to rasterize the plot. Default \code{NULL} +automatically rasterize the plot when number of total dots to be plotted +exceeds 100,000.} + \item{\code{labelText}}{Logical, whether to show text label at the median position +of each categorical group specified by \code{colorBy}. Default \code{TRUE}. +Does not work when continuous coloring is specified.} + \item{\code{labelTextSize}}{Numeric, controls the size of label size when +\code{labelText = TRUE}. Default \code{4}.} + \item{\code{seed}}{Random seed for reproducibility. Default \code{1}.} + \item{\code{legendColorTitle}}{Legend title text for color aesthetics, often used +for categorical or continuous coloring of dots. Default \code{NULL} shows the +original variable name.} + \item{\code{showLegend}}{Whether to show the legend. Default \code{TRUE}.} + \item{\code{baseSize}}{One-parameter control of all text sizes. Individual text +element sizes can be controlled by other size arguments. "Title" sizes are +2 points larger than "text" sizes when being controlled by this.} + \item{\code{titleSize,xTitleSize,yTitleSize,legendTitleSize}}{Size of main title, +axis titles and legend title. Default \code{NULL} controls by +\code{baseSize + 2}.} + \item{\code{subtitleSize,xTextSize,yTextSize,legendTextSize}}{Size of subtitle text, +axis texts and legend text. Default \code{NULL} controls by \code{baseSize}.} + \item{\code{panelBorder}}{Whether to show rectangle border of the panel instead of +using ggplot classic bottom and left axis lines. Default \code{FALSE}.} + }} } \value{ ggplot @@ -68,9 +96,7 @@ result <- runPairwiseDEG( groupTest = "stim", groupCtrl = "ctrl", variable1 = "dataset", - splitBy = "defaultCluster", - nPsdRep = 3, - minCellPerRep = 3 + splitBy = "defaultCluster" ) plotVolcano(result, "0.stim") }