Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
vertesy committed Sep 25, 2024
1 parent a78a650 commit 809f8ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 8 additions & 6 deletions R/Seurat.Utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ processSeuratObject <- function(obj, param.list = p, add.meta.fractions = FALSE,
#' Default: TRUE.
#' @param plot.DGEA Logical determining if results should be plotted.
#' Default: TRUE.
#' @param umap_caption Character string specifying the caption for the UMAP plot. Default: "".
#' @param plot.av.enrichment.hist Logical indicating whether to plot the average enrichment histogram.
#' Default: TRUE.
#' @param plot.log.top.gene.stats Logical indicating whether to plot the log top gene statistics.
Expand Down Expand Up @@ -229,6 +230,7 @@ runDGEA <- function(obj,
save.obj = TRUE,
calculate.DGEA = TRUE,
plot.DGEA = TRUE,
umap_caption = "",
plot.av.enrichment.hist = TRUE,
plot.log.top.gene.stats = TRUE,
auto.cluster.naming = TRUE,
Expand Down Expand Up @@ -275,21 +277,21 @@ runDGEA <- function(obj,
message("Resolutions analyzed:")
df.markers.all <- Idents.for.DEG <- list.fromNames(x = res.analyzed.DE)

# browser()
if (clean.misc.slot) {
message("Erasing up the misc slot: df.markers and top.markers.resX")
# obj@misc$'df.markers' <- NULL
topMslots <- grepv("top.markers.res", names(obj@misc))
obj@misc[topMslots] <- NULL
}

if (clean.meta.data) {
message("Erasing up the meta.data clustering columns.")
topMslots <- grepv("top.markers.res", names(obj@meta.data))

cl.ordered <- GetOrderedClusteringRuns(obj = obj)
cl.names <- GetNamedClusteringRuns(obj = obj, pat = "^cl.names.*[0-1]\\.[0-9]",
find.alternatives = FALSE)
obj@meta.data[, c(cl.ordered, cl.names)] <- NULL
obj@meta.data[, cl.ordered ] <- NULL
# cl.names <- GetNamedClusteringRuns(obj = obj, pat = "^cl.names.*[0-1]\\.[0-9]",
# find.alternatives = FALSE)
# [email protected][, c(cl.ordered, cl.names)] <- NULL
}

# Loop through each resolution setting to find markers ________________________________________
Expand Down Expand Up @@ -418,7 +420,7 @@ runDGEA <- function(obj,
obj <- StoreAllMarkers(df_markers = df.markers, res = res, obj = obj)
obj <- AutoLabelTop.logFC(group.by = Idents.for.DEG[[i]], obj = obj, plot.top.genes = FALSE) # already plotted above

clUMAP(ident = ppp("cl.names.top.gene", Idents.for.DEG[[i]]), obj = obj, caption = "")
clUMAP(ident = ppp("cl.names.top.gene", Idents.for.DEG[[i]]), obj = obj, caption = umap_caption)
} # end if auto.cluster.naming

# Plot per-cluster gene enrichment histogram ________________________________________
Expand Down
6 changes: 3 additions & 3 deletions R/Seurat.Utils.Visualization.R
Original file line number Diff line number Diff line change
Expand Up @@ -2527,7 +2527,7 @@ multiFeaturePlot.A4 <- function(
ParentDir <- OutDir
if (is.null(foldername)) foldername <- "genes"
final.foldername <- FixPlotName(paste0(foldername, "-", plot.reduction, suffix))
if (subdir) create_set_SubDir(final.foldername, "/")
if (subdir) create_set_SubDir(final.foldername, "/", verbose = FALSE)

list.of.genes.found <- check.genes(
list.of.genes = list.of.genes, obj = obj,
Expand Down Expand Up @@ -2579,7 +2579,7 @@ multiFeaturePlot.A4 <- function(
)
}

if (subdir) MarkdownReports::create_set_OutDir(ParentDir)
if (subdir) MarkdownReports::create_set_OutDir(ParentDir, verbose = FALSE)
if (saveGeneList) {
if (is.null(obj@misc$gene.lists)) obj@misc$gene.lists <- list()
obj@misc$gene.lists[[substitute(list.of.genes)]] <- list.of.genes.found
Expand Down Expand Up @@ -2657,7 +2657,7 @@ multiSingleClusterHighlightPlots.A4 <- function(
tictoc::tic()
ParentDir <- OutDir
if (is.null(foldername)) foldername <- "clusters"
if (subdir) create_set_SubDir(paste0(foldername, "-", plot.reduction), "/")
if (subdir) MarkdownReports::create_set_SubDir(paste0(foldername, "-", plot.reduction), "/")

clusters <- unique(obj@meta.data[[ident]])

Expand Down

0 comments on commit 809f8ae

Please sign in to comment.