From 6cd0c44805246fbb783fbf29632e3e194f2ded2c Mon Sep 17 00:00:00 2001 From: ningbioinfo Date: Fri, 6 Sep 2024 09:40:37 +0930 Subject: [PATCH] update plotRLExpr function by adding the sce_thres parameter. --- R/plotRLE.R | 15 ++++++++++----- man/plotRLExpr.Rd | 5 ++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/R/plotRLE.R b/R/plotRLE.R index d523ad8..4093d00 100644 --- a/R/plotRLE.R +++ b/R/plotRLE.R @@ -3,6 +3,8 @@ #' @param ordannots variables or computations to sort samples by (tidy style). #' #' @inheritParams drawPCA +#' @param sce_thresh Integer value. The threshold of sample size for using +#' dot plot instead of box plot. #' @return a ggplot2 object, containing the RLE plot. #' @export #' @@ -59,7 +61,7 @@ setMethod( setMethod( "plotRLExpr", signature("SummarizedExperiment", "ANY"), - function(object, ordannots, assay = 1, ...) { + function(object, ordannots, assay = 1, sce_thresh = 1000, ...) { isSCE <- is(object, "SingleCellExperiment") # extract sample data @@ -70,7 +72,8 @@ setMethod( # create data structure samporder <- orderSamples(sdata, ordannots) rledf <- pdataRLE_intl(object, samporder) - p1 <- plotRLExpr_intl(rledf, sdata, isSCE = isSCE, ...) + p1 <- plotRLExpr_intl(rledf, sdata, isSCE = isSCE, + sce_thresh = sce_thresh, ...) return(p1) } @@ -93,11 +96,12 @@ pdataRLE_intl <- function(emat, sampord) { return(rledf) } -plotRLExpr_intl <- function(plotdf, sdata, isSCE = FALSE, textScale = 1, ...) { +plotRLExpr_intl <- function(plotdf, sdata, isSCE = FALSE, textScale = 1, + sce_thresh = 1000, ...) { # constant - sample size at which standard plot becomes dense dense_thresh <- 50 - sce_thresh <- 1000 + sce_thresh <- sce_thresh # extract aes aesmap <- rlang::enquos(...) @@ -106,7 +110,8 @@ plotRLExpr_intl <- function(plotdf, sdata, isSCE = FALSE, textScale = 1, ...) { plotdf <- addSampleAnnot(plotdf, sdata) # compute plot - aesmap <- aesmap[!names(aesmap) %in% c("x", "ymin", "ymax", "upper", "middle", "lower")] # remove fixed mappings if present + aesmap <- aesmap[!names(aesmap) %in% c("x", "ymin", "ymax", + "upper", "middle", "lower")] # remove fixed mappings if present # split aes params into those that are not aes i.e. static parametrisation if (length(aesmap) > 0) { diff --git a/man/plotRLExpr.Rd b/man/plotRLExpr.Rd index 2240ba8..ea52ca8 100644 --- a/man/plotRLExpr.Rd +++ b/man/plotRLExpr.Rd @@ -13,7 +13,7 @@ plotRLExpr(object, ordannots = c(), ...) \S4method{plotRLExpr}{ExpressionSet}(object, ordannots = c(), ...) -\S4method{plotRLExpr}{SummarizedExperiment}(object, ordannots, assay = 1, ...) +\S4method{plotRLExpr}{SummarizedExperiment}(object, ordannots, assay = 1, sce_thresh = 1000, ...) } \arguments{ \item{object}{a DGEList, SummarizedExperiment or ExpressionSet object @@ -25,6 +25,9 @@ containing gene expression data.} \item{assay}{a numeric or character, specifying the assay to use (for \code{SummarizedExperiment} and its derivative classes).} + +\item{sce_thresh}{Integer value. The threshold of sample size for using +dot plot instead of box plot.} } \value{ a ggplot2 object, containing the RLE plot.