Browse Source

added test for dump matrices

lucananni93 2 years ago
parent
commit
56b0ff8cf5
1 changed files with 28 additions and 3 deletions
  1. 28 3
      tests/testthat/test-main.R

+ 28 - 3
tests/testthat/test-main.R

@@ -62,8 +62,33 @@ test_that("CALDER works with cool files", {
     input_cool_path <- file.path(testthat::test_path("data"), "test.cool")
     output_path <- testthat::test_path("test-main-cool-out")
     handle_input_cool(input_cool_path, output_path)
-    expect_snapshot_file(file.path(output_path, "sub_compartments", "all_sub_compartments.bed"))
-    expect_snapshot_file(file.path(output_path, "sub_compartments", "all_sub_compartments.tsv"))
-    expect_snapshot_file(file.path(output_path, "sub_domains", "all_nested_boundaries.bed"))
+    expect_snapshot_file(file.path(output_path, "sub_compartments", "all_sub_compartments.bed"), name = "TestCool_all_sub_compartments.bed")
+    expect_snapshot_file(file.path(output_path, "sub_compartments", "all_sub_compartments.tsv"), name = "TestCool_all_sub_compartments.tsv")
+    expect_snapshot_file(file.path(output_path, "sub_domains", "all_nested_boundaries.bed"), name = "TestCool_all_nested_boundaries.bed")
     unlink(output_path, recursive=TRUE)
 })
+
+
+test_that("CALDER works with dumps", {
+
+    chrs = c(21:22)
+
+    ## demo contact matrices in dump format
+    contact_file_dump = as.list(system.file("extdata", sprintf("mat_chr%s_10kb_ob.txt.gz", chrs),
+                package='CALDER'))
+    names(contact_file_dump) = chrs
+    output_path <- testthat::test_path("test-main-dump-out")
+    ## Run CALDER to compute compartments but not nested sub-domains
+    CALDER(contact_file_dump=contact_file_dump, 
+            chrs=chrs, 
+            bin_size=10E3,
+            genome='hg19',
+            save_dir=output_path,
+            save_intermediate_data=FALSE,
+            n_cores=2,
+            sub_domains=FALSE)
+    expect_snapshot_file(file.path(output_path, "sub_compartments", "all_sub_compartments.bed"), name = "TestDump_all_sub_compartments.bed")
+    expect_snapshot_file(file.path(output_path, "sub_compartments", "all_sub_compartments.tsv"), name = "TestDump_all_sub_compartments.tsv")
+    unlink(output_path, recursive=TRUE)
+})
+