From 0affc7367be5a7fe007dbd08038cdc6bbf86514b Mon Sep 17 00:00:00 2001 From: vertesy Date: Wed, 4 Dec 2024 17:54:05 +0100 Subject: [PATCH] nf Convert10Xfolders NormalizeData --- R/Seurat.Utils.Metadata.R | 10 +++++----- R/Seurat.Utils.R | 5 +++++ man/Convert10Xfolders.Rd | 3 +++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/R/Seurat.Utils.Metadata.R b/R/Seurat.Utils.Metadata.R index 147dd74..a537ec3 100644 --- a/R/Seurat.Utils.Metadata.R +++ b/R/Seurat.Utils.Metadata.R @@ -526,6 +526,11 @@ addMetaFraction <- function( layer = "data", gene.set = FALSE, verbose = TRUE) { + # + message("Should rather use the default `Seurat::PercentageFeatureSet`") + message("Assay: ", assay) + message("Layer: ", layer) + stopifnot( is(obj, "Seurat"), is.character(col.name), is.character(assay), is.character(layer), @@ -533,11 +538,6 @@ addMetaFraction <- function( assay %in% Assays(obj), layer %in% Layers(obj) ) - message("Should rather use the default `Seurat::PercentageFeatureSet`") - message("Assay: ", assay) - message("Layer: ", layer) - - stopif(condition = isFALSE(gene.set) && isFALSE(gene.symbol.pattern), "Either gene.set OR gene.symbol.pattern has to be defined (!= FALSE).") if (!isFALSE(gene.set) && !isFALSE(gene.symbol.pattern) && verbose) print("Both gene.set AND gene.symbol.pattern are defined. Only using gene.set.") diff --git a/R/Seurat.Utils.R b/R/Seurat.Utils.R index 17ee1ba..25fe55d 100644 --- a/R/Seurat.Utils.R +++ b/R/Seurat.Utils.R @@ -4421,6 +4421,7 @@ PlotUpdateStats <- function(mat = UpdateStatMat, column.names = c("Updated (%)", #' @param suffix A character string specifying the suffix of the files saved. #' @param min.cells An integer value specifying the minimum number of cells. Default: 5. #' @param min.features An integer value specifying the minimum number of features. Default: 200. +#' @param normalize_data Add normalized "data" layer?. Default: `TRUE`. #' @param updateHGNC A logical value indicating whether to update the HGNC. Default: `TRUE`. #' @param save Save .qs object? Default: `TRUE`. #' @param ShowStats A logical value indicating whether to show statistics. Default: `TRUE`. @@ -4441,6 +4442,7 @@ Convert10Xfolders <- function( suffix = strsplit(folderPattern, "_")[[1]][1], depth = 4, min.cells = 5, min.features = 200, + normalize_data = TRUE, updateHGNC = TRUE, ShowStats = TRUE, writeCBCtable = TRUE, nthreads = .getNrCores(), @@ -4499,6 +4501,9 @@ Convert10Xfolders <- function( # update --- --- --- if (updateHGNC) seu <- UpdateGenesSeurat(seu, EnforceUnique = TRUE, ShowStats = TRUE) + # NormalizeData --- --- --- + if (normalize_data) seu <- NormalizeData(seu, normalization.method = "LogNormalize", scale.factor = 10000, verbose = TRUE) + # write out --- --- --- if (save) qs::qsave(x = seu, file = f.path.out, nthreads = nthreads, preset = preset) diff --git a/man/Convert10Xfolders.Rd b/man/Convert10Xfolders.Rd index a5f01f0..b922633 100644 --- a/man/Convert10Xfolders.Rd +++ b/man/Convert10Xfolders.Rd @@ -12,6 +12,7 @@ Convert10Xfolders( depth = 4, min.cells = 5, min.features = 200, + normalize_data = TRUE, updateHGNC = TRUE, ShowStats = TRUE, writeCBCtable = TRUE, @@ -38,6 +39,8 @@ Convert10Xfolders( \item{min.features}{An integer value specifying the minimum number of features. Default: 200.} +\item{normalize_data}{Add normalized "data" layer?. Default: \code{TRUE}.} + \item{updateHGNC}{A logical value indicating whether to update the HGNC. Default: \code{TRUE}.} \item{ShowStats}{A logical value indicating whether to show statistics. Default: \code{TRUE}.}