diff --git a/R/Seurat.Utils.R b/R/Seurat.Utils.R index ff00bc0..e866d41 100644 --- a/R/Seurat.Utils.R +++ b/R/Seurat.Utils.R @@ -141,24 +141,21 @@ processSeuratObject <- function(obj, param.list = p, add.meta.fractions = FALSE, if (plot) { message("------------------- Plotting -------------------") - res.ident <- paste0(DefaultAssay(obj), "_snn_res.", resolutions)[1:4] - print(res.ident) - message("qClusteringUMAPS: ", paste(res.ident)) - qClusteringUMAPS(obj = obj, idents = res.ident) - + try(suPlotVariableFeatures(obj = obj, assay = "RNA"), silent = TRUE) message("scPlotPCAvarExplained") - scPlotPCAvarExplained(obj) + try(scPlotPCAvarExplained(obj), silent = TRUE) message("qQC.plots.BrainOrg") - qQC.plots.BrainOrg(obj = obj) + try(qQC.plots.BrainOrg(obj = obj), silent = TRUE) # message("multi_clUMAP.A4") # multi_clUMAP.A4(obj = obj) - "HERE" - message("suPlotVariableFeatures") - suPlotVariableFeatures(obj = obj) + res.ident <- paste0(DefaultAssay(obj), "_snn_res.", resolutions)[1:4] + message("qClusteringUMAPS: ", paste(res.ident)) + try(qClusteringUMAPS(obj = obj, idents = res.ident), silent = TRUE) + if (ncol(obj) < 50000) { # TEMP message("qMarkerCheck.BrainOrg") @@ -178,7 +175,6 @@ processSeuratObject <- function(obj, param.list = p, add.meta.fractions = FALSE, `Mesenchyme` = "DCN", Glycolytic = "PDK1", `Choroid.Plexus` = "OTX2", `Mesenchyme` = "DCN" ) - message("plotQUMAPsInAFolder") try(plotQUMAPsInAFolder(genes = Signature.Genes.Top20, obj = obj), silent = TRUE) } tictoc::toc() @@ -5440,7 +5436,6 @@ compareVarFeaturesAndRanks <- function( func_slot <- grepv(x = names(obj@commands), pattern = "^ScaleData") message("Slot: ", paste(func_slot)) - if(is.null(func_slot)) { message("No ScaleData slot found in @commands") stop() diff --git a/R/Seurat.Utils.Visualization.R b/R/Seurat.Utils.Visualization.R index 915851c..3182735 100644 --- a/R/Seurat.Utils.Visualization.R +++ b/R/Seurat.Utils.Visualization.R @@ -3998,9 +3998,12 @@ panelCorPearson <- function(x, y, digits = 2, prefix = "", cex.cor = 2, method = suPlotVariableFeatures <- function(obj = combined.obj, NrVarGenes = 15, repel = TRUE, plotWidth = 7, plotHeight = 5, save = TRUE, # suffix = kpp("nVF", .getNrScaledFeatures(obj)), + assay = DefaultAssay(obj), suffix = NULL, ...) { - # Input validation + message(" > Running suPlotVariableFeatures()...") + message(length(Cells(obj)), " cells | assay: ", assay, " | NrVarGenes: ", NrVarGenes) + stopifnot( is(obj, "Seurat"), is.function(ppp), is.logical(repel), is.numeric(plotWidth), is.numeric(plotHeight) @@ -4008,20 +4011,25 @@ suPlotVariableFeatures <- function(obj = combined.obj, NrVarGenes = 15, obj.name <- deparse(substitute(obj)) - plot1 <- Seurat::VariableFeaturePlot(obj) + + cat("1", "\n") + # browser() + plot1 <- Seurat::VariableFeaturePlot(obj, assay = assay) + theme(panel.background = element_rect(fill = "white")) + - ggtitle(label = "Variable Genes", subtitle = kppws(obj.name, suffix)) - + labs(title = "Variable Genes", + subtitle = kppws(obj.name, suffix), + caption = paste("Assay:", assay, "|", idate())) + cat("2", "\n") # Assuming LabelPoints is defined elsewhere and available for use. - TopVarGenes <- VariableFeatures(obj)[1:NrVarGenes] + TopVarGenes <- VariableFeatures(obj, assay = assay)[1:NrVarGenes] labeledPlot <- LabelPoints( plot = plot1, points = TopVarGenes, repel = repel, xnudge = 0, ynudge = 0, max.overlaps = 15 ) + cat("3", "\n") print(labeledPlot) filename <- ppp("Var.genes", obj.name, suffix, idate(), "png") - + cat("4", "\n") # if (save) ggplot2::ggsave(plot = labeledPlot, filename = filename, width = plotWidth, height = plotHeight) if (save) { qqSave( diff --git a/man/suPlotVariableFeatures.Rd b/man/suPlotVariableFeatures.Rd index 626c514..63edf72 100644 --- a/man/suPlotVariableFeatures.Rd +++ b/man/suPlotVariableFeatures.Rd @@ -11,6 +11,7 @@ suPlotVariableFeatures( plotWidth = 7, plotHeight = 5, save = TRUE, + assay = DefaultAssay(obj), suffix = NULL, ... )