Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions R/filterCells.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Comment on lines +69 to +70

if (is.null(model)) {
warning("call 'mixtureModel' explicitly to get stable model features")
model <- mixtureModel(sce)
Expand Down
1 change: 1 addition & 0 deletions R/get1DCutoff.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions R/mixtureModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion R/plotFiltering.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment on lines +68 to +69

if (is.null(model)) {
warning("call 'mixtureModel' explicitly to get stable model features")
model <- mixtureModel(sce)
Expand Down
3 changes: 3 additions & 0 deletions R/plotMetrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment on lines +46 to +47

p <- ggplot(metrics, aes(x = detected, y = subsets_mito_percent)) +
labs(x = "Unique genes found", y = "Percent reads mitochondrial") +
geom_point(colour = palette)
Expand Down
2 changes: 2 additions & 0 deletions R/plotModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment on lines +46 to +47

if (is.null(model)) {
warning("call 'mixtureModel' explicitly to get stable model features")
Expand Down