diff --git a/R/vcf-compare.R b/R/vcf-compare.R index e73ecd9..0105c0a 100644 --- a/R/vcf-compare.R +++ b/R/vcf-compare.R @@ -48,7 +48,7 @@ #' test <- system.file("extdata", "imputed.gt.vcf.gz", package="vcfppR") #' truth <- system.file("extdata", "imputed.gt.vcf.gz", package="vcfppR") #' samples <- "HG00133,HG00143,HG00262" -#' res <- vcfcomp(test, truth, stats="f1", format=c('GT','GT'), samples=samples) +#' res <- vcfcomp(test, truth, stats="f1", format=c('GT','GT'), samples=samples, setid=TRUE) #' str(res) #' @export vcfcomp <- function(test, truth, diff --git a/tests/testthat/test-vcf-comp.R b/tests/testthat/test-vcf-comp.R index b54a406..49da0a1 100644 --- a/tests/testthat/test-vcf-comp.R +++ b/tests/testthat/test-vcf-comp.R @@ -6,7 +6,9 @@ imputedvcf <- system.file("extdata", "imputed.gt.vcf.gz", package="vcfppR") test_that("can work for correlation r2 between DS and GT", { skip_on_os(c("windows"), arch = NULL) samples <- "HG00673,NA10840" - res <- vcfcomp(imputedvcf, imputedvcf, bins = c(0,1), by.sample = TRUE, samples = samples, stats = "all") + res <- vcfcomp(imputedvcf, imputedvcf, bins = c(0,1), + by.sample = TRUE, samples = samples, stats = "all", + setid = TRUE) expect_equal(as.numeric(res$r2[1,]), c(15, 6, 1), tolerance=1e-6) expect_identical(unlist(res$f1[[3]]), rep(1,2)) expect_identical(unlist(res$nrc[[3]]), rep(1,2)) @@ -20,14 +22,16 @@ test_that("can work for r2 with af", { names(af) <- d1$id affile <- tempfile() saveRDS(af, affile) - res <- vcfcomp(imputedvcf, rawvcf, stats = "r2", bins = c(0,1), af = affile, samples = samples) + res <- vcfcomp(imputedvcf, rawvcf, stats = "r2", bins = c(0,1), + af = affile, samples = samples, setid = TRUE) expect_identical(res[[2]][,3], 1) }) test_that("can work for F1 score", { skip_on_os(c("windows"), arch = NULL) samples <- "HG00673,NA10840" - res <- vcfcomp(rawvcf, imputedvcf, stats = "f1", samples = samples, by.sample = TRUE, bins = c(0,1)) + res <- vcfcomp(rawvcf, imputedvcf, stats = "f1", samples = samples, + by.sample = TRUE, bins = c(0,1), setid = TRUE) expect_identical(paste0(res$samples, collapse = ","), samples) expect_identical(unlist(res[[2]][[3]]), rep(1,2)) }) @@ -35,7 +39,8 @@ test_that("can work for F1 score", { test_that("can work for NRC rate by sample", { skip_on_os(c("windows"), arch = NULL) samples <- "HG00673,NA10840" - res <- vcfcomp(rawvcf, imputedvcf, stats = "nrc", samples = samples, by.sample = TRUE, bins = c(0,1)) + res <- vcfcomp(rawvcf, imputedvcf, stats = "nrc", samples = samples, + by.sample = TRUE, bins = c(0,1), setid = TRUE) expect_identical(paste0(res$samples, collapse = ","), samples) expect_identical(unlist(res[[2]][[3]]), rep(1,2)) }) @@ -43,7 +48,7 @@ test_that("can work for NRC rate by sample", { test_that("can work for PSE", { skip_on_os(c("windows"), arch = NULL) samples <- "HG00151,HG00380" - (res <- vcfcomp(imputedvcf, imputedvcf, stats = "pse", samples = samples)) + (res <- vcfcomp(imputedvcf, imputedvcf, stats = "pse", samples = samples, setid = TRUE)) expect_true(is.nan(res[[2]][[1]]$pse)) expect_true((res[[2]][[2]]$pse==0)) expect_true((res[[2]][[2]]$disc==0))