Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
Signed-off-by: sara castellano <[email protected]>
  • Loading branch information
sara castellano committed Nov 2, 2023
1 parent b07dd6a commit 9177794
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pipeline-runner/tests/testthat/test-qc-7-embed_and_cluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -631,3 +631,39 @@ test_that("add_duplicate_barcode_column handles a mix of unique and duplicate ba
mixed_result <- add_duplicate_barcode_column(mixed_cl_metadata)
expect_equal(mixed_result$duplicate_barcode, c("no", "yes", "yes", "no"))
})

test_that("duplicate barcodes are not present in the created cellsets", {
config <- mock_config()
scdata <- mock_scdata()
cl_metadata <- mock_cl_metadata(scdata)
cl_metadata <- rbind(cl_metadata, cl_metadata[1:2, ])

cl_metadata_res <- add_duplicate_barcode_column(cl_metadata)
barcode_cell_id_map <- get_cell_id_barcode_map(scdata)
cl_metadata_table <-
make_cl_metadata_table(cl_metadata_res, barcode_cell_id_map)

local_mock_cl_metadata_table(cl_metadata, "mock_experiment_id")

res <- stubbed_make_cl_metadata_cellsets(scdata, config)
withr::defer(unlink(file.path(".", basename(config$metadataS3Path))))

dup_barcodes <- unique(cl_metadata_table[duplicate_barcode == "yes", cells_id])

for (item in res) {
if (item$name != "duplicate_barcode") {
for (child in item$children) {
has_duplicate_barcodes <- any(child$cellIds %in% dup_barcodes)
expect_false(has_duplicate_barcodes,
info = paste(
"Duplicate barcodes detected in", item$name,
"-", child$name
)
)
}
}
}
})



0 comments on commit 9177794

Please sign in to comment.