File: test-qc-quick.R

package info (click to toggle)
r-bioc-scuttle 1.0.4%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 728 kB
  • sloc: cpp: 356; sh: 17; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 1,223 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# This tests the quickPerCellQC function.
# library(testthat); library(scuttle); source("setup.R"); source("test-qc-quick.R")

original <- sce

test_that("quickPerCellQC works correctly", {
    df <- perCellQCMetrics(original)
    df$sum[1] <- 0
    df$detected[2] <- 0

    out <- quickPerCellQC(df)
    expect_true(out$low_lib_size[1])
    expect_true(out$low_n_features[2])

    expect_identical(out$discard, out$low_lib_size | out$low_n_features)
})

test_that("quickPerCellQC works correctly with subsets", {
    df <- perCellQCMetrics(original)
    df$subsets_BLAH_percent <- c(1, rep(0, nrow(df)-1))
    df$altexps_WHEE_percent <- c(0, 1, rep(0, nrow(df)-2))
    df$sum[3] <- 0
    df$detected[4] <- 0

    out <- quickPerCellQC(df, sub.fields=c("subsets_BLAH_percent", "altexps_WHEE_percent"))
    expect_true(out$high_subsets_BLAH_percent[1])
    expect_true(out$high_altexps_WHEE_percent[2])
    expect_identical(out$discard, Reduce("|", out[,1:4]))

    out2 <- quickPerCellQC(df, sub.fields=TRUE)
    expect_identical(out, out2)
})

test_that("quickPerCellQC works correctly with SCEs", {
    df <- perCellQCMetrics(original)
    out <- quickPerCellQC(df)
    expect_identical(out, quickPerCellQC(original))
})