Skip to content

Commit

Permalink
update plotRLExpr function by adding the sce_thres parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
ningbioinfo committed Sep 6, 2024
1 parent 9b6bcd6 commit 6cd0c44
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
15 changes: 10 additions & 5 deletions R/plotRLE.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
#'
Expand Down Expand Up @@ -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
Expand All @@ -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)
}
Expand All @@ -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(...)
Expand All @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion man/plotRLExpr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6cd0c44

Please sign in to comment.