From 6732e3cf4d3b569f182c78b1e1e12da8cfc35e90 Mon Sep 17 00:00:00 2001 From: vertesy Date: Wed, 3 Jan 2024 19:33:19 +0100 Subject: [PATCH] ... --- R/Seurat.Utils.R | 2 +- R/Seurat.Utils.Visualization.R | 17 +++++++++++------ man/AutoLabelTop.logFC.Rd | 2 +- man/plot.clust.size.distr.Rd | 2 +- man/qSeuViolin.Rd | 12 ++++++++++-- man/remove.residual.small.clusters.Rd | 2 +- 6 files changed, 25 insertions(+), 12 deletions(-) diff --git a/R/Seurat.Utils.R b/R/Seurat.Utils.R index 1654aa5..dd7eda0 100644 --- a/R/Seurat.Utils.R +++ b/R/Seurat.Utils.R @@ -74,7 +74,7 @@ parallel.computing.by.future <- function(cores = 4, maxMemSize = 4000 * 1024^2) #' #' @export IntersectGeneLsWithObject <- function(genes, obj = combined.obj, n_genes_shown = 10, strict = TRUE) { - message("IntersectGeneLsWithObject()") + message(">>> Running IntersectGeneLsWithObject(), formerly IntersectWithExpressed()") stopifnot( is.character(genes), diff --git a/R/Seurat.Utils.Visualization.R b/R/Seurat.Utils.Visualization.R index f2a2679..e60a68b 100644 --- a/R/Seurat.Utils.Visualization.R +++ b/R/Seurat.Utils.Visualization.R @@ -707,29 +707,34 @@ qFeatureScatter <- function( # _________________________________________________________________________________________________ -#' qSeuViolin +#' @title qSeuViolin #' -#' This function creates a violin plot of a single feature in a Seurat object, split by a grouping variable. +#' @description This function creates a violin plot of a single feature in a Seurat object, +#' split by a grouping variable. #' @param object A Seurat object. #' @param suffix A string to append to the title of the plot. #' @param features The name of the feature to plot. +#' @param hline hline +#' @param caption caption #' @param split.by The grouping variable to split the plot by. #' @param logY Whether to plot the y-axis on a log scale. #' #' @return A ggplot object. #' #' @export - qSeuViolin <- function( object = ls.Seurat[[1]], suffix = GEX_library, - features = "nFeature_RNA", split.by = "orig.ident", logY = TRUE) { - # Create a violin plot of the feature, split by the grouping variable. - p <- VlnPlot(object = object, features = features, split.by = split.by) + + features = "nFeature_RNA", split.by = "orig.ident", logY = TRUE, hline = FALSE, caption = FALSE + , ...) { + + p <- VlnPlot(object = object, features = features, split.by = split.by, ...) + ggtitle(label = features, subtitle = paste(suffix, "by", split.by)) + theme(axis.title.x = element_blank()) + labs(y = "Top UVI's depth") # If `logY` is TRUE, plot the y-axis on a log scale. if (logY) p <- p + ggplot2::scale_y_log10() + if (hline) p <- p + ggplot2::geom_hline(yintercept = hline) + if (!isFALSE(caption)) p <- p + ggplot2::labs(caption = caption) # Save the plot. title_ <- ppp(as.character(features), suffix, flag.nameiftrue(logY)) diff --git a/man/AutoLabelTop.logFC.Rd b/man/AutoLabelTop.logFC.Rd index 8b9bd5e..9cb2f71 100644 --- a/man/AutoLabelTop.logFC.Rd +++ b/man/AutoLabelTop.logFC.Rd @@ -6,7 +6,7 @@ \usage{ AutoLabelTop.logFC( obj = combined.obj, - group.by = GetClusteringRuns()[1], + group.by = GetClusteringRuns(obj)[1], res = 0.1, plot.top.genes = TRUE, suffix = res, diff --git a/man/plot.clust.size.distr.Rd b/man/plot.clust.size.distr.Rd index 74c6823..3442725 100644 --- a/man/plot.clust.size.distr.Rd +++ b/man/plot.clust.size.distr.Rd @@ -6,7 +6,7 @@ \usage{ \method{plot}{clust.size.distr}( obj = combined.obj, - ident = GetClusteringRuns()[2], + ident = GetClusteringRuns(obj)[2], plot = TRUE, thr.hist = 30, ... diff --git a/man/qSeuViolin.Rd b/man/qSeuViolin.Rd index bcc76a0..f359948 100644 --- a/man/qSeuViolin.Rd +++ b/man/qSeuViolin.Rd @@ -9,7 +9,10 @@ qSeuViolin( suffix = GEX_library, features = "nFeature_RNA", split.by = "orig.ident", - logY = TRUE + logY = TRUE, + hline = FALSE, + caption = FALSE, + ... ) } \arguments{ @@ -22,10 +25,15 @@ qSeuViolin( \item{split.by}{The grouping variable to split the plot by.} \item{logY}{Whether to plot the y-axis on a log scale.} + +\item{hline}{hline} + +\item{caption}{caption} } \value{ A ggplot object. } \description{ -This function creates a violin plot of a single feature in a Seurat object, split by a grouping variable. +This function creates a violin plot of a single feature in a Seurat object, +split by a grouping variable. } diff --git a/man/remove.residual.small.clusters.Rd b/man/remove.residual.small.clusters.Rd index a35eec3..f3586ce 100644 --- a/man/remove.residual.small.clusters.Rd +++ b/man/remove.residual.small.clusters.Rd @@ -6,7 +6,7 @@ \usage{ remove.residual.small.clusters( obj = combined.obj, - identitites = GetClusteringRuns(obj = obj), + identitites = GetClusteringRuns(obj), max.cells = max(round((ncol(obj))/2000), 5) ) }