Skip to content

Commit

Permalink
bf processSeuratObject calling suPlotVariableFeatures
Browse files Browse the repository at this point in the history
  • Loading branch information
vertesy committed Jun 6, 2024
1 parent dd2e759 commit 34cbd5b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
19 changes: 7 additions & 12 deletions R/Seurat.Utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
20 changes: 14 additions & 6 deletions R/Seurat.Utils.Visualization.R
Original file line number Diff line number Diff line change
Expand Up @@ -3998,30 +3998,38 @@ 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)
)

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(
Expand Down
1 change: 1 addition & 0 deletions man/suPlotVariableFeatures.Rd

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

0 comments on commit 34cbd5b

Please sign in to comment.