Skip to content

Commit

Permalink
feat: Updates to QC flag print out and associated markdown vignettes,…
Browse files Browse the repository at this point in the history
… tests, and fixtures
  • Loading branch information
escauley committed Jan 30, 2024
1 parent 6f434ab commit f3f5879
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 14 deletions.
22 changes: 17 additions & 5 deletions R/qc_preprocessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,18 @@ qcProc <- function(object,
# Gather the additional QC data

## Additional QC column names
add.qc.column.names <- c("Raw",
"NTC",
add.qc.column.names <- c("Raw",
"Trimmed (%)",
"Stitched (%)",
"Aligned (%)",
"Saturated (%)",
"NegGeoMean")

## Check for NTC column
if("NTC" %in% colnames(segment.qc.data)){
add.qc.column.names <- c("NTC", add.qc.column.names)
}

## Additional QC data
add.qc.columns <- segment.qc.data[, add.qc.column.names]
add.qc.columns <- rownames_to_column(add.qc.columns, var = "SampleID")
Expand All @@ -373,12 +377,19 @@ qcProc <- function(object,

add.qc.columns$TrimmedPerc <- sapply(add.qc.columns$`Trimmed (%)`,
function(x) unname(unlist(x)))
add.qc.columns$TrimmedPerc <- as.vector(add.qc.columns$TrimmedPerc[,1])

add.qc.columns$StitchedPerc <- sapply(add.qc.columns$`Stitched (%)`,
function(x) unname(unlist(x)))
add.qc.columns$StitchedPerc <- as.vector(add.qc.columns$StitchedPerc[,1])

add.qc.columns$AlignedPerc <- sapply(add.qc.columns$`Aligned (%)`,
function(x) unname(unlist(x)))
add.qc.columns$AlignedPerc <- as.vector(add.qc.columns$AlignedPerc[,1])

add.qc.columns$SaturatedPerc <- sapply(add.qc.columns$`Saturated (%)`,
function(x) unname(unlist(x)))
add.qc.columns$SaturatedPerc <- as.vector(add.qc.columns$SaturatedPerc[,1])

## Remove the nested data frames
add.qc.columns <- add.qc.columns[, -which(names(add.qc.columns) == "Trimmed (%)")]
Expand Down Expand Up @@ -406,12 +417,13 @@ qcProc <- function(object,
"LowAligned",
"SaturatedPerc",
"LowSaturation",
"NTC",
"HighNTC",
"NegGeoMean",
"LowNegatives")

## Add area and/or nuclei if part of annotation
## Add NTC, area, and/or nuclei if part of annotation
if("NTC" %in% annotation.column.names){
final.column.order <- c(final.column.order, "NTC", "HighNTC")
}
if("area" %in% annotation.column.names){
final.column.order <- c(final.column.order, "area", "LowArea")
}
Expand Down
Binary file not shown.
Binary file modified tests/testthat/fixtures/Human_Colon/studyDesignHumanColon.RDS
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/testthat/fixtures/Human_NSCLC/studyDesignHumanNSCLC.RDS
Binary file not shown.
Binary file not shown.
Binary file modified tests/testthat/fixtures/Mouse_Thymus/studyDesignMouseThymus.RDS
Binary file not shown.
8 changes: 4 additions & 4 deletions tests/testthat/test-qc_preprocessing.R
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
test_that("Test Human Kidney dataset", {
kidney.dat <- selectDatasetQC("kidney")
output <- do.call(qcProc, kidney.dat)
expected.elements <- c("object", "plot","table")
expected.elements <- c("object", "plot","table","segment.flags","probe.flags")

Check warning on line 4 in tests/testthat/test-qc_preprocessing.R

View workflow job for this annotation

GitHub Actions / Activating_Parser / Activate_Action_Pack / Check_Pushed_Scripts_version_main / Check_on_Changed_Scripts

file=/__w/DSPWorkflow/DSPWorkflow/tests/testthat/test-qc_preprocessing.R,line=4,col=43,[commas_linter] Commas should always have a space after.

Check warning on line 4 in tests/testthat/test-qc_preprocessing.R

View workflow job for this annotation

GitHub Actions / Activating_Parser / Activate_Action_Pack / Check_Pushed_Scripts_version_main / Check_on_Changed_Scripts

file=/__w/DSPWorkflow/DSPWorkflow/tests/testthat/test-qc_preprocessing.R,line=4,col=51,[commas_linter] Commas should always have a space after.

Check warning on line 4 in tests/testthat/test-qc_preprocessing.R

View workflow job for this annotation

GitHub Actions / Activating_Parser / Activate_Action_Pack / Check_Pushed_Scripts_version_main / Check_on_Changed_Scripts

file=/__w/DSPWorkflow/DSPWorkflow/tests/testthat/test-qc_preprocessing.R,line=4,col=67,[commas_linter] Commas should always have a space after.
expect_equal(length(setdiff(expected.elements, names(output))), 0)
})
test_that("Test Mouse Thymus Dataset", {
thymus.dat <- selectDatasetQC("thymus")
output <- do.call(qcProc, thymus.dat)
expected.elements <- c("object", "plot","table")
expected.elements <- c("object", "plot","table","segment.flags","probe.flags")

Check warning on line 10 in tests/testthat/test-qc_preprocessing.R

View workflow job for this annotation

GitHub Actions / Activating_Parser / Activate_Action_Pack / Check_Pushed_Scripts_version_main / Check_on_Changed_Scripts

file=/__w/DSPWorkflow/DSPWorkflow/tests/testthat/test-qc_preprocessing.R,line=10,col=43,[commas_linter] Commas should always have a space after.

Check warning on line 10 in tests/testthat/test-qc_preprocessing.R

View workflow job for this annotation

GitHub Actions / Activating_Parser / Activate_Action_Pack / Check_Pushed_Scripts_version_main / Check_on_Changed_Scripts

file=/__w/DSPWorkflow/DSPWorkflow/tests/testthat/test-qc_preprocessing.R,line=10,col=51,[commas_linter] Commas should always have a space after.

Check warning on line 10 in tests/testthat/test-qc_preprocessing.R

View workflow job for this annotation

GitHub Actions / Activating_Parser / Activate_Action_Pack / Check_Pushed_Scripts_version_main / Check_on_Changed_Scripts

file=/__w/DSPWorkflow/DSPWorkflow/tests/testthat/test-qc_preprocessing.R,line=10,col=67,[commas_linter] Commas should always have a space after.
expect_equal(length(setdiff(expected.elements, names(output))), 0)
})
test_that("Test Colon Dataset", {
colon.dat <- selectDatasetQC("colon")
expect_warning(output <- do.call(qcProc, colon.dat), regexp = NULL)
expected.elements <- c("object", "plot","table")
expected.elements <- c("object", "plot","table","segment.flags","probe.flags")

Check warning on line 16 in tests/testthat/test-qc_preprocessing.R

View workflow job for this annotation

GitHub Actions / Activating_Parser / Activate_Action_Pack / Check_Pushed_Scripts_version_main / Check_on_Changed_Scripts

file=/__w/DSPWorkflow/DSPWorkflow/tests/testthat/test-qc_preprocessing.R,line=16,col=43,[commas_linter] Commas should always have a space after.

Check warning on line 16 in tests/testthat/test-qc_preprocessing.R

View workflow job for this annotation

GitHub Actions / Activating_Parser / Activate_Action_Pack / Check_Pushed_Scripts_version_main / Check_on_Changed_Scripts

file=/__w/DSPWorkflow/DSPWorkflow/tests/testthat/test-qc_preprocessing.R,line=16,col=51,[commas_linter] Commas should always have a space after.

Check warning on line 16 in tests/testthat/test-qc_preprocessing.R

View workflow job for this annotation

GitHub Actions / Activating_Parser / Activate_Action_Pack / Check_Pushed_Scripts_version_main / Check_on_Changed_Scripts

file=/__w/DSPWorkflow/DSPWorkflow/tests/testthat/test-qc_preprocessing.R,line=16,col=67,[commas_linter] Commas should always have a space after.
expect_equal(length(setdiff(expected.elements, names(output))), 0)
})
test_that("Test Human NSCLC Dataset", {
nsclc.dat <- selectDatasetQC("nsclc")

Check warning on line 20 in tests/testthat/test-qc_preprocessing.R

View workflow job for this annotation

GitHub Actions / Activating_Parser / Activate_Action_Pack / Check_Pushed_Scripts_version_main / Check_on_Changed_Scripts

file=/__w/DSPWorkflow/DSPWorkflow/tests/testthat/test-qc_preprocessing.R,line=20,col=40,[trailing_whitespace_linter] Trailing whitespace is superfluous.
expect_warning(output <- do.call(qcProc, nsclc.dat), regexp = NULL)
expected.elements <- c("object", "plot","table")
expected.elements <- c("object", "plot","table","segment.flags","probe.flags")
expect_equal(length(setdiff(expected.elements, names(output))), 0)
})
test_that(
Expand Down
6 changes: 4 additions & 2 deletions vignettes/Integration_Test_Colon.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ This runs the DSPworkflow package to completion using the Human Colon Dataset:
nuclei.col = "nuclei")
# For creating fixture RDS
create.rds <- TRUE
create.rds <- FALSE
if(create.rds) {
study.design.human.colon <- sdesign.list$object
saveRDS(study.design.human.colon, file = "tests/testthat/fixtures/Human_Colon/studyDesignHumanColon.RDS")
Expand All @@ -97,8 +97,10 @@ This runs the DSPworkflow package to completion using the Human Colon Dataset:
min.area = 1000,
print.plots = TRUE)
print(qc.output$segments.qc)
print(qc.output$segment.flags)
print(qc.output$probe.flags)
create.rds <- TRUE
create.rds <- FALSE
if(create.rds) {
qc.human.colon<- qc.output$object
saveRDS(qc.human.colon, file = "tests/testthat/fixtures/Human_Colon/qcHumanColon.RDS")
Expand Down
6 changes: 4 additions & 2 deletions vignettes/Integration_Test_Mouse_Thymus.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ This runs the DSPworkflow package to completion using the Mouse Thymus Dataset:
nuclei.col = "nuclei")
# For creating fixture RDS
create.rds <- TRUE
create.rds <- FALSE
if(create.rds) {
study.design.mouse.thymus <- sdesign.list$object
saveRDS(study.design.mouse.thymus, file = "tests/testthat/fixtures/Mouse_Thymus/studyDesignMouseThymus.RDS")
Expand Down Expand Up @@ -99,8 +99,10 @@ qc.output <- qcProc(object = sdesign.list$object,
min.area = 16000,
print.plots = TRUE)
print(qc.output$segments.qc)
print(qc.output$segment.flags)
print(qc.output$probe.flags)
create.rds <- TRUE
create.rds <- FALSE
if(create.rds) {
qc.mouse.thymus <- qc.output$object
saveRDS(qc.mouse.thymus, file = "tests/testthat/fixtures/Mouse_Thymus/qcMouseThymus.RDS")
Expand Down
2 changes: 1 addition & 1 deletion vignettes/Integration_Test_NSCLC.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ qc.output <- qcProc(object = sdesign.list$object,
print(qc.output$segments.qc)
# For creating a fixture RDS
create.rds <- TRUE
create.rds <- FALSE
if(create.rds) {
qc.human.nsclc <- qc.output$object
saveRDS(qc.human.nsclc, file = "tests/testthat/fixtures/Human_NSCLC/qcHumanNSCLC.RDS")
Expand Down

0 comments on commit f3f5879

Please sign in to comment.