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
8 changes: 4 additions & 4 deletions CITATION.cff

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions R/filter_cells.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ filter_cells <- function(
) {
nFeature_RNA <- NULL
so_filt <- BiocGenerics::subset(so, subset = nFeature_RNA > 200) # standard low cell read filter
if (method == "miQC") {
so_qc <- so_filt
if (grepl(pattern = "miQC", x = method, ignore.case = TRUE)) {
print("--filtering cells with miQC")

so_qc <- SeuratWrappers::RunMiQC(
Expand All @@ -51,8 +52,7 @@ filter_cells <- function(
model.slot = "flexmix_model"
)
so_qc$keep <- so_qc$miQC.keep
} else if (method == "manual") {
so_qc <- so_filt
} else if (grepl(pattern = "manual", x = method, ignore.case = TRUE)) {
so_qc$keep <- "discard"
so_qc$keep[which(
so_qc$nCount_RNA <= nCount_RNA_max &
Expand All @@ -62,8 +62,7 @@ filter_cells <- function(
so_qc$percent.mt <= percent_mt_max &
so_qc$percent.mt >= percent_mt_min
)] <- "keep"
} else if (method == "mads") {
so_qc <- so_filt
} else if (grepl(pattern = "mads", x = method, ignore.case = TRUE)) {
nCount_out <- Routliers::outliers_mad(
so_qc$nCount_RNA,
threshold = mads
Expand All @@ -82,6 +81,11 @@ filter_cells <- function(
so_qc$nFeature_RNA >= nFeature_out &
so_qc$percent.mt <= percent_mt_out
)] <- "keep"
} else {
warning(
"No valid filtering method selected. All cells with nFeature_RNA > 200 retained"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't hard-code this number

Suggested change
"No valid filtering method selected. All cells with nFeature_RNA > 200 retained"
glue::glue("No valid filtering method selected. All cells with nFeature_RNA > {nFeature_RNA_min} retained")

p.s. is this statement in the warning message accurate? I don't see any filtering logic, so it looks like all cells are kept?

)
so_qc$keep <- "keep"
}

return(so_qc)
Expand Down
3 changes: 1 addition & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Maintained Versions

Actively maintained versions of contained software will vary from repository to repository, or may not be relevant at all.
Actively maintained versions of contained software will vary from repository to repository, or may not be relevant at all.
The developers of this repository will update this section if any actively maintained versions of the software need to be publicly disclosed. Otherwise, contact the developers directly for any version information.

## Vulnerability Disclosure:
Expand All @@ -16,4 +16,3 @@ Follow the instructions listed in the [HHS vulnerability disclosure policy](http
1. Click on the **Security and quality** tab of this repository.
2. Locate the **Report a vulnerability** button. If the button is not on the **Security and quality** landing page, look under the **Advisories** section in the side bar.
3. Click the **Report a vulnerability** button and submit the form. The developers will receive a notification of your submission.

27 changes: 27 additions & 0 deletions tests/testthat/test-filter_cells.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,41 @@ test_that("filter_miQC", {
expect_equal(length(which(pbmc_filt$keep == "keep")), 2140, tolerance = 5)
})

test_that("filter_miQC_case", {
set.seed(42)
pbmc_filt <- filter_cells(pbmc_processed, method = "mIqC")
expect_equal(length(which(pbmc_filt$keep == "keep")), 2140, tolerance = 5)
})

test_that("filter_manual", {
set.seed(42)
pbmc_filt <- filter_cells(pbmc_processed, method = "manual")
expect_equal(length(which(pbmc_filt$keep == "keep")), 2510, tolerance = 5)
})

test_that("filter_manual_case", {
set.seed(42)
pbmc_filt <- filter_cells(pbmc_processed, method = "MAnUal")
expect_equal(length(which(pbmc_filt$keep == "keep")), 2510, tolerance = 5)
})

test_that("filter_mads", {
set.seed(42)
pbmc_filt <- filter_cells(pbmc_processed, method = "mads")
expect_equal(length(which(pbmc_filt$keep == "keep")), 2590, tolerance = 5)
})

test_that("filter_mads_case", {
set.seed(42)
pbmc_filt <- filter_cells(pbmc_processed, method = "maDS")
expect_equal(length(which(pbmc_filt$keep == "keep")), 2590, tolerance = 5)
})

test_that("filter_nonexistent", {
set.seed(42)
expect_warning(
pbmc_filt <- filter_cells(pbmc_processed, method = "whatever"),
"No valid filtering"
)
expect_equal(ncol(pbmc_filt), 2638)
})
Loading