diff --git a/R/filterCells.R b/R/filterCells.R index ba3bcc7..fbd0d1b 100644 --- a/R/filterCells.R +++ b/R/filterCells.R @@ -26,6 +26,15 @@ #' than it are kept. #' Default = TRUE #' +#' @param detected (character) Column name in sce giving the number of unique +#' genes detected per cell. This name is inherited by default from scater's +#' addPerCellQC() function. +#' +#' @param subsets_mito_percent (character) Column name in sce giving the +#' percent of reads mapping to mitochondrial genes. This name is inherited +#' from scater's addPerCellQC() function, provided the subset "mito" with +#' names of all mitochondrial genes is passed in. See examples for details. +#' #' @param verbose (boolean) Whether to report how many cells (columns) are being #' removed from the SingleCellExperiment object. #' Default = TRUE @@ -53,9 +62,13 @@ filterCells <- function(sce, model = NULL, posterior_cutoff = 0.75, keep_all_below_boundary = TRUE, - enforce_left_cutoff = TRUE, verbose = TRUE) { + enforce_left_cutoff = TRUE, + detected = "detected", subsets_mito_percent = "subsets_mito_percent", + verbose = TRUE) { metrics <- as.data.frame(colData(sce)) - + colnames(metrics)[colnames(metrics)==detected] <- "detected" + colnames(metrics)[colnames(metrics)==subsets_mito_percent] <- "subsets_mito_percent" + if (is.null(model)) { warning("call 'mixtureModel' explicitly to get stable model features") model <- mixtureModel(sce) diff --git a/R/get1DCutoff.R b/R/get1DCutoff.R index 475c4b0..945441b 100644 --- a/R/get1DCutoff.R +++ b/R/get1DCutoff.R @@ -44,6 +44,7 @@ get1DCutoff <- function(sce, model = NULL, posterior_cutoff = 0.75, subsets_mito_percent = "subsets_mito_percent") { metrics <- as.data.frame(colData(sce)) + colnames(metrics)[colnames(metrics)==subsets_mito_percent] <- "subsets_mito_percent" if (is.null(model)) { warning("call 'mixtureModel' explicitly to get stable model features") diff --git a/R/mixtureModel.R b/R/mixtureModel.R index 426ba65..c3a3f37 100644 --- a/R/mixtureModel.R +++ b/R/mixtureModel.R @@ -47,6 +47,8 @@ mixtureModel <- function(sce, model_type = "linear", detected = "detected", subsets_mito_percent = "subsets_mito_percent") { metrics <- as.data.frame(colData(sce)) + colnames(metrics)[colnames(metrics)==detected] <- "detected" + colnames(metrics)[colnames(metrics)==subsets_mito_percent] <- "subsets_mito_percent" if (model_type == "linear") { model <- flexmix(subsets_mito_percent~detected, diff --git a/R/plotFiltering.R b/R/plotFiltering.R index 000b5c1..9a959d0 100644 --- a/R/plotFiltering.R +++ b/R/plotFiltering.R @@ -65,7 +65,9 @@ plotFiltering <- function(sce, model = NULL, posterior_cutoff = 0.75, detected = "detected", subsets_mito_percent = "subsets_mito_percent") { metrics <- as.data.frame(colData(sce)) - + colnames(metrics)[colnames(metrics)==detected] <- "detected" + colnames(metrics)[colnames(metrics)==subsets_mito_percent] <- "subsets_mito_percent" + if (is.null(model)) { warning("call 'mixtureModel' explicitly to get stable model features") model <- mixtureModel(sce) diff --git a/R/plotMetrics.R b/R/plotMetrics.R index 6cb0dbf..a9b0b19 100644 --- a/R/plotMetrics.R +++ b/R/plotMetrics.R @@ -43,6 +43,9 @@ plotMetrics <- function(sce, detected = "detected", palette = "#33ADFF") { metrics <- as.data.frame(colData(sce)) + colnames(metrics)[colnames(metrics)==detected] <- "detected" + colnames(metrics)[colnames(metrics)==subsets_mito_percent] <- "subsets_mito_percent" + p <- ggplot(metrics, aes(x = detected, y = subsets_mito_percent)) + labs(x = "Unique genes found", y = "Percent reads mitochondrial") + geom_point(colour = palette) diff --git a/R/plotModel.R b/R/plotModel.R index 8590e70..a3e33b0 100644 --- a/R/plotModel.R +++ b/R/plotModel.R @@ -43,6 +43,8 @@ plotModel <- function(sce, model = NULL, detected = "detected", subsets_mito_percent = "subsets_mito_percent") { metrics <- as.data.frame(colData(sce)) + colnames(metrics)[colnames(metrics)==detected] <- "detected" + colnames(metrics)[colnames(metrics)==subsets_mito_percent] <- "subsets_mito_percent" if (is.null(model)) { warning("call 'mixtureModel' explicitly to get stable model features")