Skip to content

Commit

Permalink
bf qQC.plots.BrainOrg
Browse files Browse the repository at this point in the history
  • Loading branch information
vertesy committed Dec 2, 2024
1 parent c982cba commit 1dea193
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions R/Seurat.Utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#'
#' @param obj A Seurat object to be processed.
#' @param param.list A list of parameters used in the processing steps.
#' @param update_gene_symbols A boolean indicating whether to update gene symbols from HGNC. Default: `TRUE`.
#' @param update_gene_symbols A boolean indicating whether to update gene symbols from HGNC. Default: `FALSE`.
#' @param add.meta.fractions A boolean indicating whether to add meta data for fractions of cells in each cluster. Default: `FALSE`.
#' @param precompute A boolean indicating whether to compute steps: `FindVariableFeatures()`,
#' `calc.q99.Expression.and.set.all.genes()`, `ScaleData()` and `RunPCA()` Default: `TRUE`.
Expand Down Expand Up @@ -58,7 +58,7 @@
#'
#' @export
processSeuratObject <- function(obj, param.list = p,
update_gene_symbols = TRUE,
update_gene_symbols = FALSE,
add.meta.fractions = FALSE,
precompute = TRUE,
compute = TRUE,
Expand Down Expand Up @@ -111,7 +111,7 @@ processSeuratObject <- function(obj, param.list = p,

if (update_gene_symbols) {
message("------------------- UpdateGenesSeurat -------------------")
obj <- UpdateGenesSeurat(objj)
obj <- UpdateGenesSeurat(obj)
}

if (precompute | add.meta.fractions) {
Expand Down
15 changes: 9 additions & 6 deletions R/Seurat.Utils.Visualization.R
Original file line number Diff line number Diff line change
Expand Up @@ -3040,20 +3040,23 @@ qQC.plots.BrainOrg <- function(
message(" > Plotting qQC.plots.BrainOrg...")

# Check that the QC markers are in the object
QC.Features.Found <- intersect(QC.Features, colnames(obj@meta.data))
QC.Features.Found <- intersect(QC.Features, union(colnames(obj@meta.data), rownames(obj)))
QC.Features.Found.in.meta <- intersect(QC.Features, colnames(obj@meta.data))
n.found <- length(QC.Features.Found)
message(kppws(n.found, " found: ", QC.Features.Found))
stopifnot(n.found > 1)


# Count the number of NAs in specified columns
na_counts <- sapply(X = obj@meta.data[, QC.Features.Found], function(x) sum(is.na(x)))
na_counts <- sapply(X = obj@meta.data[, QC.Features.Found.in.meta], function(x) sum(is.na(x)))

# Raise a warning if there are any NAs
if (sum(na_counts) > 0) {
warning(sprintf("There are %d NA values found\n", na_counts),
immediate. = TRUE
)
if(length(na_counts)){
if (sum(na_counts) > 0) {
warning(sprintf("There are %d NA values found\n", na_counts),
immediate. = TRUE
)
}
}

px <- list(
Expand Down

0 comments on commit 1dea193

Please sign in to comment.