test_that("Testing get_consensus.R", {
input_object <- list(A = Matrix::sparseMatrix(i = rep(1,2), j = c(1,2), x = c(8,2), dims = c(1,4), dimnames = list("chrM_2_A_A", paste0("Cell_", 1:4))),
C = Matrix::sparseMatrix(i = rep(1,3), j = c(1,3,4), x = c(4,1,1), dims = c(1,4), dimnames = list("chrM_4_C_A", paste0("Cell_", 1:4))),
G = Matrix::sparseMatrix(i = rep(1,3), j = c(1,2,4), x = c(2,3,8), dims = c(1,4), dimnames = list("chrM_1_G_A", paste0("Cell_", 1:4))),
T = Matrix::sparseMatrix(i = rep(1,1), j = 1, x = 1, dims = c(1,4), dimnames = list("chrM_3_T_A", paste0("Cell_", 1:4))),
N = Matrix::sparseMatrix(i = rep(1,4), j = 1:4, x = c(8,4,2,1), dims = c(1,4), dimnames = list("chrM_3107_N_A", paste0("Cell_", 1:4))))
test_A_C <- get_consensus(alt_base = "C", ref_base = "A", input_matrix = as.matrix(input_object[[1]]), chromosome_prefix = "chrM")
test_A_G <- get_consensus(alt_base = "G", ref_base = "A", input_matrix = as.matrix(input_object[[1]]), chromosome_prefix = "chrM")
test_A_T <- get_consensus(alt_base = "T", ref_base = "A", input_matrix = as.matrix(input_object[[1]]), chromosome_prefix = "chrM")
test_C_A <- get_consensus(alt_base = "A", ref_base = "C", input_matrix = as.matrix(input_object[[2]]), chromosome_prefix = "chrM")
test_C_G <- get_consensus(alt_base = "G", ref_base = "C", input_matrix = as.matrix(input_object[[2]]), chromosome_prefix = "chrM")
test_C_T <- get_consensus(alt_base = "T", ref_base = "C", input_matrix = as.matrix(input_object[[2]]), chromosome_prefix = "chrM")
test_G_A <- get_consensus(alt_base = "A", ref_base = "G", input_matrix = as.matrix(input_object[[3]]), chromosome_prefix = "chrM")
test_G_C <- get_consensus(alt_base = "C", ref_base = "G", input_matrix = as.matrix(input_object[[3]]), chromosome_prefix = "chrM")
test_G_T <- get_consensus(alt_base = "T", ref_base = "G", input_matrix = as.matrix(input_object[[3]]), chromosome_prefix = "chrM")
test_T_A <- get_consensus(alt_base = "A", ref_base = "T", input_matrix = as.matrix(input_object[[4]]), chromosome_prefix = "chrM")
test_T_C <- get_consensus(alt_base = "C", ref_base = "T", input_matrix = as.matrix(input_object[[4]]), chromosome_prefix = "chrM")
test_T_G <- get_consensus(alt_base = "G", ref_base = "T", input_matrix = as.matrix(input_object[[4]]), chromosome_prefix = "chrM")
test_N_A <- get_consensus(alt_base = "A", ref_base = "N", input_matrix = as.matrix(input_object[[5]]), chromosome_prefix = "chrM")
test_N_C <- get_consensus(alt_base = "C", ref_base = "N", input_matrix = as.matrix(input_object[[5]]), chromosome_prefix = "chrM")
test_N_G <- get_consensus(alt_base = "G", ref_base = "N", input_matrix = as.matrix(input_object[[5]]), chromosome_prefix = "chrM")
test_N_T <- get_consensus(alt_base = "T", ref_base = "N", input_matrix = as.matrix(input_object[[5]]), chromosome_prefix = "chrM")
# We generate the expected results.
expected_result_A_C <- Matrix::sparseMatrix(i = 1, j = 1, x = 1, dims = c(1,4), dimnames = list("chrM_2_A_C", paste0("Cell_", 1:4)))
expected_result_A_G <- Matrix::sparseMatrix(i = c(1,1), j = c(1,2), x = 1:2, dims = c(1,4), dimnames = list("chrM_2_A_G", paste0("Cell_", 1:4)))
expected_result_A_T <- Matrix::sparseMatrix(i = 1, j = 1, x = 1, dims = c(1,4), dimnames = list("chrM_2_A_T", paste0("Cell_", 1:4)))
expected_result_C_A <- Matrix::sparseMatrix(i = 1, j = 1, x = 1, dims = c(1,4), dimnames = list("chrM_4_C_A", paste0("Cell_", 1:4)))
expected_result_C_G <- Matrix::sparseMatrix(i = 1, j = 1, x = 1, dims = c(1,4), dimnames = list("chrM_4_C_G", paste0("Cell_", 1:4)))
expected_result_C_T <- Matrix::sparseMatrix(i = c(1,1,1), j = c(1,3,4), x = c(1,2,2), dims = c(1,4), dimnames = list("chrM_4_C_T", paste0("Cell_", 1:4)))
expected_result_G_A <- Matrix::sparseMatrix(i = c(1,1), j = c(1,4), x = c(1,2), dims = c(1,4), dimnames = list("chrM_1_G_A", paste0("Cell_", 1:4)))
expected_result_G_C <- Matrix::sparseMatrix(i = 1, j = 1, x = 1, dims = c(1,4), dimnames = list("chrM_1_G_C", paste0("Cell_", 1:4)))
expected_result_G_T <- Matrix::sparseMatrix(i = c(1,1), j = c(1,2), x = c(1,3), dims = c(1,4), dimnames = list("chrM_1_G_T", paste0("Cell_", 1:4)))
expected_result_T_A <- Matrix::sparseMatrix(i = 1, j = 1, x = 1, dims = c(1,4), dimnames = list("chrM_3_T_A", paste0("Cell_", 1:4)))
expected_result_T_C <- Matrix::sparseMatrix(i = 1, j = 1, x = 1, dims = c(1,4), dimnames = list("chrM_3_T_C", paste0("Cell_", 1:4)))
expected_result_T_G <- Matrix::sparseMatrix(i = 1, j = 1, x = 1, dims = c(1,4), dimnames = list("chrM_3_T_G", paste0("Cell_", 1:4)))
expected_result_N_A <- Matrix::sparseMatrix(i = 1, j = 1, x = 2, dims = c(1,4), dimnames = list("chrM_3107_N_A", paste0("Cell_", 1:4)))
expected_result_N_C <- Matrix::sparseMatrix(i = 1, j = 2, x = 2, dims = c(1,4), dimnames = list("chrM_3107_N_C", paste0("Cell_", 1:4)))
expected_result_N_G <- Matrix::sparseMatrix(i = 1, j = 3, x = 2, dims = c(1,4), dimnames = list("chrM_3107_N_G", paste0("Cell_", 1:4)))
expected_result_N_T <- Matrix::sparseMatrix(i = 1, j = 4, x = 2, dims = c(1,4), dimnames = list("chrM_3107_N_T", paste0("Cell_", 1:4)))
# We perform the tests.
expect_equal(test_A_C, expected_result_A_C, tolerance = 1e-6)
expect_equal(test_A_G, expected_result_A_G, tolerance = 1e-6)
expect_equal(test_A_T, expected_result_A_T, tolerance = 1e-6)
expect_equal(test_C_A, expected_result_C_A, tolerance = 1e-6)
expect_equal(test_C_G, expected_result_C_G, tolerance = 1e-6)
expect_equal(test_C_T, expected_result_C_T, tolerance = 1e-6)
expect_equal(test_G_A, expected_result_G_A, tolerance = 1e-6)
expect_equal(test_G_C, expected_result_G_C, tolerance = 1e-6)
expect_equal(test_G_T, expected_result_G_T, tolerance = 1e-6)
expect_equal(test_T_A, expected_result_T_A, tolerance = 1e-6)
expect_equal(test_T_C, expected_result_T_C, tolerance = 1e-6)
expect_equal(test_T_G, expected_result_T_G, tolerance = 1e-6)
expect_equal(test_N_A, expected_result_N_A, tolerance = 1e-6)
expect_equal(test_N_C, expected_result_N_C, tolerance = 1e-6)
expect_equal(test_N_G, expected_result_N_G, tolerance = 1e-6)
expect_equal(test_N_T, expected_result_N_T, tolerance = 1e-6)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.