Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
abel.vertesy committed Oct 11, 2023
1 parent d9b2e32 commit ed2b044
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion R/Seurat.Utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -2615,6 +2615,20 @@ qFeatureScatter <- function(feature1 = "TOP2A", feature2 = "ID2", obj = combined
}


# _________________________________________________________________________________________________
#' ww.replace.na.SeuMeta


ww.replace.na.SeuMeta <- function(obj, feature, replacewith = NULL) {
featurez <- obj[[feature]]
n_na <- sum(is.na(featurez))
if (n_na) {
iprint(n_na, "NA values found in", feature, "of", l(featurez))
}
obj[[feature]] <- na.replace(x = featurez, replace = replacewith)
return(obj)
}

# _________________________________________________________________________________________________
#' qSeuViolin
#'
Expand All @@ -2630,8 +2644,10 @@ qFeatureScatter <- function(feature1 = "TOP2A", feature2 = "ID2", obj = combined
#' @export

qSeuViolin <- function(object = ls.Seurat[[1]], suffix = GEX_library
, features = 'nFeature_RNA', split.by = 'orig.ident', logY = TRUE) {
, features = 'nFeature_RNA', split.by = 'orig.ident', logY = TRUE
, replaceNAwith = NaN, caption = FALSE) {

object<- ww.replace.na.SeuMeta(obj = object, feature = features, replacewith = replaceNAwith)
# Create a violin plot of the feature, split by the grouping variable.
p <- VlnPlot(object = object, features = features, split.by = split.by) +
ggtitle(label = features, subtitle = paste(suffix, 'by', split.by)) +
Expand All @@ -2640,6 +2656,8 @@ qSeuViolin <- function(object = ls.Seurat[[1]], suffix = GEX_library
# If `logY` is TRUE, plot the y-axis on a log scale.
if (logY) p <- p + ggplot2::scale_y_log10()

if (!isFALSE(caption)) p <- p + ggplot2::labs(caption = caption)

# Save the plot.
title_ <- ppp(as.character(features), suffix, flag.nameiftrue(logY))
qqSave(p, title = title_, w = 7, h = 5)
Expand Down

0 comments on commit ed2b044

Please sign in to comment.