# Set verbosity to 0
set_verbosity(0)
#Create matrix containing 3 signatures
m <- create_4_rnd_clust()
test_that("Checking output matrix generated by find_gene_clusters...", {
## A rather stringent version
res <- select_genes(data=m,
distance_method="pearson",
k=75,
row_sum=-Inf,
noise_level=0.3,
fdr = 1e-8)
#=======================================================
# Test matrix in res@data
expect_equal(round(sum(res@data), 3), 2188.346)
expect_equal(round(mean(res@data), 6), 0.296524)
expect_equal(round(median(res@data), 6), 0.083721)
expect_equal(round(sd(res@data), 6), 2.123212)
expect_equal(round(sum(quantile(res@data)["0%"]), 6), -5.806817)
expect_equal(round(sum(quantile(res@data)["25%"]), 6), -1.013447)
expect_equal(round(sum(quantile(res@data)["50%"]), 6), 0.083721)
expect_equal(round(sum(quantile(res@data)["75%"]), 6), 1.34164)
expect_equal(round(sum(quantile(res@data)["100%"]), 6), 7.073935)
expect_equal(round(sum(colMeans(res@data)),5), 5.93048)
expect_equal(round(sum(rowMeans(res@data)),4), 109.4173)
expect_equal(round(max(res@data),6), 7.073935)
expect_equal(ncol(res@data), 20)
expect_equal(colnames(res@data), paste0("sample", seq(1,20)))
expect_equal(nrow(res@data), 369)
expect_equal(nrow(res@data), length(get_genes(res)))
expect_equal(rownames(res@data), get_genes(res))
expect_equal(rownames(res@data), unlist(res@gene_clusters, use.names = F))
expect_equal(nrow(res@data), length(get_genes(res)))
expect_equal(nrow(res@data), length(unlist(res@gene_clusters, use.names = F)))
expect_equal(round(sum(res@data^2), 2), 33913.65)
expect_equal(length(res@data), 7380)
#=======================================================
# Test observed distances in res@dbf_output$dknn
expect_equal(round(sum(res@dbf_output$dknn), 3), 2070.863)
expect_equal(round(mean(res@dbf_output$dknn), 7), 0.5177157)
expect_equal(round(median(res@dbf_output$dknn), 7), 0.5333734)
expect_equal(round(sd(res@dbf_output$dknn), 6), 0.058557)
expect_equal(round(sum(quantile(res@dbf_output$dknn)["0%"]), 6), 0.151747)
expect_equal(round(sum(quantile(res@dbf_output$dknn)["25%"]), 6), 0.52163)
expect_equal(round(sum(quantile(res@dbf_output$dknn)["50%"]), 6), 0.533373)
expect_equal(round(sum(quantile(res@dbf_output$dknn)["75%"]), 6), 0.541248)
expect_equal(round(sum(quantile(res@dbf_output$dknn)["100%"]), 6), 0.569402)
expect_equal(length(res@dbf_output$dknn), 4000)
expect_equal(round(sum(res@dbf_output$dknn^2), 2), 1085.83)
#=======================================================
# Test simulated distances in res@dbf_output$simulated_dknn
expect_equal(round(sum(res@dbf_output$simulated_dknn), 3), 2153.312)
expect_equal(round(mean(res@dbf_output$simulated_dknn), 7), 0.538328)
expect_equal(round(median(res@dbf_output$simulated_dknn), 7), 0.538304)
expect_equal(round(sd(res@dbf_output$simulated_dknn), 6), 0.009098)
expect_equal(round(sum(quantile(res@dbf_output$simulated_dknn)["0%"]), 6), 0.504041)
expect_equal(round(sum(quantile(res@dbf_output$simulated_dknn)["25%"]), 6), 0.532663)
expect_equal(round(sum(quantile(res@dbf_output$simulated_dknn)["50%"]), 6), 0.538304)
expect_equal(round(sum(quantile(res@dbf_output$simulated_dknn)["75%"]), 6), 0.544447)
expect_equal(round(sum(quantile(res@dbf_output$simulated_dknn)["100%"]), 6), 0.572353)
expect_equal(length(res@dbf_output$simulated_dknn), 4000)
expect_equal(round(sum(res@dbf_output$simulated_dknn^2), 2), 1159.52)
#=======================================================
# Test critical distance in res@critical_distance
expect_equal(round(res@dbf_output$critical_distance, 7), 0.4772475)
expect_equal(length(res@dbf_output$critical_distance), 1)
#=======================================================
# Test gene clusters in res@gene_clusters
expect_equal(names(res@gene_clusters), "1")
expect_equal(length(res@gene_clusters$`1`), 369)
expect_equal(res@gene_clusters$`1`, get_genes(res))
expect_equal(res@gene_clusters$`1`, get_genes(res, cluster = 1))
expect_equal(res@gene_clusters$`1`, rownames(res@data))
#=======================================================
# Test size of gene clusters in res@gene_clusters_metadata$size
expect_equal(res@gene_clusters_metadata$size, 369)
expect_equal(length(res@gene_clusters_metadata$size), 1)
expect_equal(res@gene_clusters_metadata$size[1],
length(res@gene_clusters$`1`))
expect_equal(res@gene_clusters_metadata$size[1],
length(get_genes(res, cluster = 1)))
#=======================================================
# Test parameters in res@parameters
expect_equal(length(res@parameters), 7)
expect_equal(names(res@parameters), c("distance_method",
"k",
"noise_level",
"fdr",
"row_sum",
"no_dknn_filter",
"seed"))
expect_equal(res@parameters$distance_method, "pearson")
expect_equal(length(res@parameters$distance_method), 1)
expect_equal(res@parameters$k, 75)
expect_equal(length(res@parameters$k), 1)
expect_equal(res@parameters$noise_level, 0.3)
expect_equal(length(res@parameters$noise_level), 1)
expect_equal(res@parameters$fdr, 1e-08)
expect_equal(length(res@parameters$fdr), 1)
expect_equal(res@parameters$row_sum, -Inf)
expect_equal(length(res@parameters$row_sum), 1)
expect_equal(res@parameters$no_dknn_filter, FALSE)
expect_equal(length(res@parameters$no_dknn_filter), 1)
expect_equal(res@parameters$seed, 123)
expect_equal(length(res@parameters$seed), 1)
})
test_that("Checking DBF is working with Sparse Matrices...", {
# Create a sparseMatrix
m <- as(create_3_rnd_clust(), "sparseMatrix")
expect_equal(inherits(m, "dgCMatrix"), TRUE)
expect_equal(ncol(m), 20)
expect_equal(nrow(m), 4000)
#Run DBF with a Sparse Matrix
res_1 <- select_genes(data = m,
distance_method = "pearson",
k = 50,
fdr = 10,
seed = 123)
# Create a normal matrix
m <- create_3_rnd_clust()
expect_equal(ncol(m), 20)
expect_equal(nrow(m), 4000)
#Run DBF with a Sparse Matrix
res_2 <- select_genes(data = m,
distance_method = "pearson",
k = 50,
fdr = 10,
seed = 123)
expect_true(all(unlist(res_1@gene_clusters) == unlist(res_2@gene_clusters)))
})
# ==============================================================================
# Test data argument
# ==============================================================================
test_that("Checking stop if data argument is NULL", {
#Create matrix containing 3 signatures
m <- create_4_rnd_clust()
expect_error(select_genes(data=NULL,
distance_method="pearson",
k=75,
row_sum=-Inf,
noise_level=0.3,
fdr = 1e-8))
})
# ==============================================================================
# Test highest argument
# ==============================================================================
test_that("Checking stop if noise_level argument > 1 or <0", {
#Create matrix containing 3 signatures
m <- create_4_rnd_clust()
expect_error(select_genes(data=m,
distance_method="pearson",
k=75,
row_sum=-Inf,
noise_level=-0.1,
fdr = 1e-8))
expect_error(select_genes(data=m,
distance_method="pearson",
k=75,
row_sum=-Inf,
noise_level=101,
fdr = 1e-8))
})
test_that("Checking dbf() when noise_level argumenet is set to 0", {
#Create matrix containing 3 signatures
m <- create_4_rnd_clust()
res <- select_genes(data=m,
distance_method="pearson",
k=75,
row_sum=-Inf,
noise_level=0,
fdr = 1e-8)
expect_equal(res@gene_clusters_metadata$cluster_id, 1)
expect_equal(res@gene_clusters_metadata$number, "1")
expect_equal(res@gene_clusters_metadata$size, 296)
expect_equal(unlist(res@gene_clusters, use.names = F), c(
"gene146", "gene189", "gene150", "gene117", "gene190", "gene135",
"gene165", "gene186", "gene180", "gene155", "gene144", "gene132",
"gene106", "gene192", "gene111", "gene153", "gene108", "gene159",
"gene133", "gene166", "gene112", "gene143", "gene126", "gene145",
"gene184", "gene122", "gene161", "gene176", "gene193", "gene137",
"gene168", "gene160", "gene147", "gene107", "gene129", "gene188",
"gene101", "gene104", "gene109", "gene114", "gene127", "gene157",
"gene173", "gene197", "gene191", "gene177", "gene103", "gene105",
"gene194", "gene163", "gene121", "gene116", "gene162", "gene158",
"gene178", "gene175", "gene124", "gene141", "gene171", "gene128",
"gene142", "gene198", "gene140", "gene119", "gene183", "gene167",
"gene200", "gene199", "gene148", "gene174", "gene113", "gene151",
"gene136", "gene179", "gene138", "gene181", "gene154", "gene130",
"gene118", "gene115", "gene182", "gene134", "gene195", "gene164",
"gene185", "gene120", "gene152", "gene149", "gene172", "gene131",
"gene196", "gene110", "gene170", "gene125", "gene156", "gene123",
"gene169", "gene102", "gene139", "gene187", "gene285", "gene273",
"gene245", "gene272", "gene249", "gene230", "gene256", "gene225",
"gene289", "gene286", "gene278", "gene282", "gene275", "gene214",
"gene248", "gene277", "gene241", "gene206", "gene251", "gene298",
"gene236", "gene267", "gene222", "gene290", "gene299", "gene223",
"gene266", "gene217", "gene293", "gene229", "gene283", "gene300",
"gene263", "gene235", "gene250", "gene212", "gene259", "gene219",
"gene287", "gene233", "gene262", "gene239", "gene255", "gene258",
"gene393", "gene203", "gene207", "gene240", "gene216", "gene232",
"gene215", "gene253", "gene269", "gene237", "gene294", "gene390",
"gene284", "gene247", "gene242", "gene312", "gene244", "gene297",
"gene281", "gene226", "gene314", "gene1616", "gene76", "gene279",
"gene316", "gene254", "gene246", "gene386", "gene364", "gene270",
"gene369", "gene292", "gene318", "gene268", "gene288", "gene315",
"gene398", "gene238", "gene387", "gene257", "gene363", "gene27",
"gene37", "gene227", "gene220", "gene32", "gene234", "gene334",
"gene838", "gene70", "gene202", "gene330", "gene55", "gene291",
"gene208", "gene67", "gene320", "gene80", "gene3528", "gene382",
"gene59", "gene326", "gene379", "gene16", "gene12", "gene84",
"gene322", "gene205", "gene221", "gene329", "gene45", "gene295",
"gene88", "gene271", "gene260", "gene224", "gene19", "gene201",
"gene296", "gene324", "gene61", "gene211", "gene243", "gene349",
"gene313", "gene306", "gene331", "gene280", "gene261", "gene368",
"gene213", "gene209", "gene350", "gene78", "gene327", "gene3485",
"gene73", "gene389", "gene319", "gene353", "gene36", "gene29",
"gene397", "gene3991", "gene366", "gene39", "gene362", "gene1503",
"gene7", "gene335", "gene2", "gene365", "gene57", "gene228",
"gene86", "gene218", "gene9", "gene52", "gene210", "gene265",
"gene51", "gene66", "gene340", "gene378", "gene64", "gene336",
"gene358", "gene264", "gene1501", "gene13", "gene274", "gene252",
"gene1267", "gene4", "gene1", "gene56", "gene394", "gene74",
"gene34", "gene311", "gene2184", "gene79", "gene332", "gene93",
"gene303", "gene2725", "gene341", "gene301", "gene385", "gene351",
"gene1931", "gene42"
))
})
# ==============================================================================
# Test row_sum argument
# ==============================================================================
test_that("Checking dbf() when row_sum argument is set to 5", {
#Create matrix containing 3 signatures
m <- create_4_rnd_clust()
res <- select_genes(data=m,
distance_method="pearson",
k=75,
row_sum=5,
noise_level=0.3,
fdr = 1e-8)
expect_equal(res@gene_clusters_metadata$cluster_id, 1)
expect_equal(res@gene_clusters_metadata$number, "1")
expect_equal(res@gene_clusters_metadata$size, 214)
expect_equal(unlist(res@gene_clusters, use.names = F), c(
"gene146", "gene189", "gene150", "gene117", "gene190", "gene135",
"gene165", "gene186", "gene180", "gene155", "gene144", "gene132",
"gene106", "gene192", "gene111", "gene153", "gene108", "gene159",
"gene133", "gene166", "gene112", "gene143", "gene126", "gene145",
"gene184", "gene122", "gene161", "gene176", "gene193", "gene137",
"gene168", "gene160", "gene147", "gene107", "gene129", "gene188",
"gene101", "gene104", "gene109", "gene114", "gene127", "gene157",
"gene173", "gene197", "gene191", "gene177", "gene103", "gene105",
"gene194", "gene163", "gene121", "gene116", "gene162", "gene158",
"gene178", "gene175", "gene124", "gene141", "gene171", "gene128",
"gene142", "gene198", "gene140", "gene119", "gene183", "gene167",
"gene199", "gene148", "gene174", "gene113", "gene200", "gene151",
"gene136", "gene179", "gene138", "gene181", "gene154", "gene130",
"gene118", "gene115", "gene182", "gene134", "gene195", "gene164",
"gene185", "gene120", "gene152", "gene149", "gene172", "gene131",
"gene196", "gene110", "gene170", "gene125", "gene156", "gene123",
"gene102", "gene169", "gene139", "gene187", "gene76", "gene12",
"gene55", "gene59", "gene16", "gene37", "gene32", "gene84",
"gene27", "gene78", "gene80", "gene61", "gene88", "gene45",
"gene36", "gene67", "gene7", "gene29", "gene1", "gene2",
"gene39", "gene70", "gene57", "gene51", "gene19", "gene13",
"gene86", "gene73", "gene9", "gene56", "gene64", "gene71",
"gene94", "gene58", "gene34", "gene79", "gene1456", "gene74",
"gene25", "gene31", "gene93", "gene3779", "gene66", "gene11",
"gene6", "gene83", "gene4", "gene42", "gene52", "gene10",
"gene35", "gene96", "gene87", "gene82", "gene3924", "gene69",
"gene90", "gene63", "gene28", "gene17", "gene46", "gene14",
"gene98", "gene1154", "gene1360", "gene20", "gene85", "gene22",
"gene95", "gene1721", "gene44", "gene3", "gene3403", "gene99",
"gene89", "gene2987", "gene43", "gene1925", "gene23", "gene1922",
"gene3316", "gene33", "gene21", "gene97", "gene48", "gene54",
"gene75", "gene81", "gene100", "gene26", "gene2561", "gene24",
"gene68", "gene3043", "gene1450", "gene41", "gene658", "gene38",
"gene77", "gene47", "gene60", "gene91", "gene2232", "gene50",
"gene2322", "gene725", "gene3959", "gene3425", "gene652", "gene877",
"gene5", "gene412", "gene1486", "gene30"
))
})
# ==============================================================================
# Test fdr argument
# ==============================================================================
test_that("Checking dbf() when fdr argument is set to 1e-20", {
#Create matrix containing 3 signatures
m <- create_4_rnd_clust()
res <- select_genes(data=m,
distance_method="pearson",
k=75,
row_sum=-Inf,
noise_level=0.3,
fdr = 1e-20)
expect_equal(res@gene_clusters_metadata$cluster_id, 1)
expect_equal(res@gene_clusters_metadata$number, "1")
expect_equal(res@gene_clusters_metadata$size, 258)
expect_equal(unlist(res@gene_clusters, use.names = F), c(
"gene146", "gene189", "gene150", "gene117", "gene190", "gene135",
"gene165", "gene186", "gene180", "gene155", "gene144", "gene132",
"gene106", "gene192", "gene111", "gene153", "gene108", "gene159",
"gene133", "gene166", "gene112", "gene143", "gene126", "gene145",
"gene184", "gene122", "gene161", "gene176", "gene193", "gene137",
"gene168", "gene160", "gene147", "gene107", "gene129", "gene188",
"gene101", "gene104", "gene109", "gene114", "gene127", "gene157",
"gene173", "gene197", "gene191", "gene177", "gene103", "gene105",
"gene194", "gene163", "gene121", "gene116", "gene162", "gene158",
"gene178", "gene175", "gene124", "gene141", "gene171", "gene128",
"gene142", "gene198", "gene140", "gene119", "gene183", "gene167",
"gene200", "gene199", "gene148", "gene174", "gene113", "gene151",
"gene136", "gene179", "gene138", "gene181", "gene154", "gene130",
"gene118", "gene115", "gene182", "gene134", "gene195", "gene164",
"gene185", "gene120", "gene152", "gene149", "gene172", "gene131",
"gene196", "gene110", "gene170", "gene125", "gene156", "gene123",
"gene169", "gene102", "gene139", "gene187", "gene285", "gene273",
"gene245", "gene272", "gene249", "gene230", "gene256", "gene225",
"gene289", "gene286", "gene278", "gene282", "gene275", "gene214",
"gene248", "gene277", "gene241", "gene206", "gene251", "gene298",
"gene236", "gene267", "gene222", "gene290", "gene299", "gene223",
"gene266", "gene217", "gene293", "gene229", "gene283", "gene300",
"gene263", "gene235", "gene250", "gene212", "gene259", "gene219",
"gene287", "gene233", "gene262", "gene239", "gene255", "gene258",
"gene393", "gene203", "gene207", "gene240", "gene216", "gene232",
"gene215", "gene253", "gene269", "gene237", "gene294", "gene390",
"gene284", "gene247", "gene242", "gene312", "gene244", "gene297",
"gene281", "gene226", "gene314", "gene1616", "gene76", "gene279",
"gene316", "gene254", "gene246", "gene386", "gene364", "gene270",
"gene369", "gene292", "gene318", "gene268", "gene288", "gene315",
"gene398", "gene238", "gene387", "gene257", "gene363", "gene27",
"gene37", "gene227", "gene220", "gene32", "gene234", "gene334",
"gene838", "gene70", "gene202", "gene330", "gene55", "gene291",
"gene208", "gene67", "gene320", "gene80", "gene3528", "gene382",
"gene59", "gene326", "gene379", "gene16", "gene12", "gene84",
"gene322", "gene205", "gene221", "gene329", "gene45", "gene295",
"gene88", "gene271", "gene260", "gene224", "gene19", "gene201",
"gene296", "gene324", "gene61", "gene211", "gene243", "gene349",
"gene313", "gene306", "gene331", "gene280", "gene261", "gene368",
"gene213", "gene209", "gene350", "gene78", "gene327", "gene3485",
"gene73", "gene389", "gene319", "gene353", "gene36", "gene29",
"gene397", "gene3991", "gene366", "gene39", "gene362", "gene1503",
"gene7", "gene335", "gene2", "gene365", "gene57", "gene228"
))
})
# ==============================================================================
# Test no_dknn_filter argument
# ==============================================================================
test_that("Checking dbf() when no_dknn_filter argument is set to TRUE", {
#Create matrix containing 3 signatures
m <- create_4_rnd_clust()
res <- select_genes(data=m,
distance_method="pearson",
k=75,
row_sum=-Inf,
noise_level=0.3,
fdr = 1e-8,
no_dknn_filter = TRUE)
expect_equal(res@gene_clusters_metadata$cluster_id, 1)
expect_equal(res@gene_clusters_metadata$number, "1")
expect_equal(res@gene_clusters_metadata$size, 4000)
})
test_that("Checking that cosine-based distance is working...", {
res <- select_genes(data = m,
distance_method = "cosine",
k = 75,
row_sum = -Inf,
noise_level = 0.3,
fdr = 1e-8)
expect_equal(ncol(m), ncol(res))
expect_equal(ncol(m), ncol(res))
expect_equal(colnames(res@data), paste0("sample", seq(1, 20)))
expect_equal(unlist(res@gene_clusters[[1]]), c(
"gene189", "gene150", "gene190", "gene165", "gene146", "gene155",
"gene186", "gene192", "gene132", "gene166", "gene180", "gene153",
"gene159", "gene111", "gene144", "gene160", "gene147", "gene112",
"gene143", "gene122", "gene176", "gene117", "gene184", "gene161",
"gene114", "gene197", "gene108", "gene135", "gene107", "gene137",
"gene106", "gene129", "gene133", "gene193", "gene191", "gene157",
"gene124", "gene162", "gene177", "gene171", "gene158", "gene173",
"gene119", "gene140", "gene105", "gene178", "gene183", "gene104",
"gene101", "gene198", "gene121", "gene148", "gene194", "gene141",
"gene188", "gene127", "gene200", "gene142", "gene145", "gene126",
"gene138", "gene182", "gene168", "gene103", "gene154", "gene151",
"gene175", "gene136", "gene179", "gene115", "gene134", "gene109",
"gene174", "gene167", "gene199", "gene130", "gene181", "gene185",
"gene128", "gene164", "gene163", "gene120", "gene152", "gene170",
"gene118", "gene131", "gene116", "gene123", "gene125", "gene149",
"gene113", "gene156", "gene195", "gene102", "gene139", "gene187",
"gene172", "gene169", "gene110", "gene196", "gene316", "gene393",
"gene76", "gene230", "gene398", "gene330", "gene285", "gene67",
"gene368", "gene256", "gene382", "gene298", "gene386", "gene286",
"gene379", "gene249", "gene88", "gene16", "gene55", "gene245",
"gene59", "gene364", "gene289", "gene390", "gene282", "gene389",
"gene315", "gene312", "gene223", "gene293", "gene212", "gene32",
"gene349", "gene73", "gene222", "gene334", "gene318", "gene329",
"gene339", "gene358", "gene267", "gene241", "gene314", "gene353",
"gene324", "gene259", "gene214", "gene80", "gene275", "gene283",
"gene332", "gene272", "gene206", "gene250", "gene12", "gene397",
"gene362", "gene299", "gene233", "gene263", "gene251", "gene365",
"gene367", "gene327", "gene253", "gene400", "gene9", "gene225",
"gene320", "gene366", "gene322", "gene301", "gene216", "gene303",
"gene39", "gene394", "gene383", "gene236", "gene359", "gene66",
"gene239", "gene290", "gene248", "gene203", "gene219", "gene217",
"gene35", "gene45", "gene273", "gene235", "gene391", "gene300",
"gene29", "gene2", "gene345", "gene36", "gene279", "gene331",
"gene351", "gene363", "gene370", "gene56", "gene6", "gene287",
"gene311", "gene385", "gene355", "gene262", "gene19", "gene266",
"gene396", "gene74", "gene399", "gene372", "gene244", "gene323",
"gene215", "gene229", "gene207", "gene86", "gene258", "gene326",
"gene268", "gene350", "gene340", "gene84", "gene240", "gene319",
"gene71", "gene297", "gene78", "gene313", "gene94", "gene82",
"gene3924", "gene344", "gene37", "gene11", "gene261", "gene255",
"gene291", "gene336", "gene278", "gene57", "gene242", "gene306",
"gene342", "gene284", "gene1", "gene277", "gene89", "gene25",
"gene58", "gene395", "gene341", "gene232", "gene380", "gene247",
"gene227", "gene99", "gene392", "gene346", "gene234", "gene79",
"gene54", "gene270", "gene352", "gene93", "gene96", "gene269",
"gene373", "gene254", "gene44", "gene335", "gene46", "gene70",
"gene226", "gene333", "gene294", "gene7", "gene375", "gene218",
"gene288", "gene85", "gene237", "gene369", "gene377", "gene87",
"gene42", "gene308", "gene356", "gene31", "gene325", "gene28",
"gene13", "gene317", "gene10", "gene238", "gene280", "gene213",
"gene292", "gene220", "gene296", "gene34", "gene304", "gene302",
"gene27", "gene14", "gene64", "gene75", "gene208", "gene246",
"gene48", "gene33", "gene281", "gene252", "gene295", "gene211",
"gene371", "gene23", "gene210", "gene257", "gene20", "gene95",
"gene21", "gene381", "gene260", "gene205", "gene201", "gene387",
"gene15", "gene100", "gene5", "gene357", "gene412", "gene97",
"gene38", "gene224", "gene81", "gene17", "gene83", "gene305",
"gene3101", "gene22", "gene388", "gene271", "gene65", "gene361",
"gene384", "gene265", "gene310", "gene52", "gene61", "gene264",
"gene378", "gene228", "gene40", "gene51", "gene4", "gene69",
"gene221", "gene338", "gene3", "gene347", "gene337", "gene274",
"gene68", "gene26", "gene47", "gene98", "gene1267", "gene24",
"gene307", "gene49", "gene354", "gene50", "gene231", "gene243",
"gene376", "gene348", "gene309", "gene91", "gene2725", "gene276",
"gene77", "gene328", "gene41", "gene1456", "gene90", "gene18",
"gene63", "gene321", "gene60", "gene1360", "gene209", "gene360",
"gene8", "gene3779", "gene343", "gene202", "gene3043", "gene2184",
"gene2430", "gene1616", "gene2761", "gene3425", "gene2920", "gene658",
"gene3183", "gene204", "gene1915", "gene1322", "gene1266", "gene53",
"gene2421", "gene604", "gene30", "gene3403", "gene1721", "gene3601",
"gene2387", "gene2482", "gene43", "gene1912", "gene2987", "gene3574",
"gene1901", "gene374", "gene652", "gene1922", "gene877", "gene92",
"gene1081", "gene1224", "gene725", "gene3303", "gene2679", "gene3991",
"gene1197", "gene3488", "gene3746", "gene1350", "gene3797", "gene2117",
"gene2810", "gene2911", "gene2666", "gene2153", "gene3285", "gene3906",
"gene1524", "gene2108", "gene3316", "gene1931", "gene736", "gene924",
"gene2672", "gene3809", "gene1745", "gene1154", "gene1013", "gene650",
"gene1925", "gene542", "gene72", "gene2881", "gene515", "gene1426",
"gene1077", "gene1444", "gene1049", "gene1100", "gene2229", "gene3916",
"gene3959", "gene2322", "gene1057", "gene3843", "gene2004", "gene2142",
"gene2020", "gene1885", "gene1509", "gene2704", "gene2553"
))
expect_equal(length(res@gene_clusters), 1)
expect_equal(round(sum(res@data), 3), 2525.443)
})
test_that("Checking that euclidean-based distance is working...", {
res <- select_genes(data = m,
distance_method = "euclidean",
k = 5,
row_sum = -Inf,
noise_level = 0.3,
fdr = 1e-8)
expect_equal(ncol(m), ncol(res))
expect_equal(ncol(m), ncol(res))
expect_equal(colnames(res@data), paste0("sample", seq(1, 20)))
expect_equal(unlist(res@gene_clusters[[1]]), c(
"gene568", "gene3169", "gene824", "gene1015", "gene3462", "gene464",
"gene1938", "gene1521", "gene1076", "gene2800", "gene717", "gene2647",
"gene1873", "gene3122", "gene1206", "gene3224", "gene3343", "gene2589",
"gene796", "gene2690", "gene1225", "gene2616", "gene2433", "gene2044",
"gene1941", "gene3478", "gene793", "gene2042", "gene3251", "gene490",
"gene1372", "gene3209", "gene1430", "gene3365", "gene2866", "gene660",
"gene1178", "gene2437", "gene1778", "gene2037", "gene3505", "gene899",
"gene1381", "gene744", "gene2568", "gene2106", "gene3716", "gene3660",
"gene3826", "gene1036", "gene2041", "gene1626", "gene2598", "gene757",
"gene1446", "gene664", "gene1147", "gene2259", "gene3634", "gene3635",
"gene2629", "gene805", "gene541", "gene1459", "gene2239", "gene3195",
"gene864", "gene2005", "gene642", "gene1069", "gene3060", "gene1400",
"gene3418", "gene1333", "gene3772", "gene3174", "gene2508", "gene1581",
"gene3240", "gene2325", "gene1710", "gene1083", "gene779", "gene1523",
"gene2418", "gene2591", "gene3196", "gene2799", "gene3238", "gene3841",
"gene2289", "gene1540", "gene3305", "gene1334", "gene627", "gene2092",
"gene3560", "gene506", "gene1241", "gene3618", "gene540", "gene1098",
"gene860", "gene3423", "gene3931", "gene2200", "gene2341", "gene1568",
"gene1519", "gene3376", "gene2897", "gene3707", "gene3784", "gene2498",
"gene1332", "gene3171", "gene2886", "gene2764", "gene1840", "gene999",
"gene1374", "gene3739", "gene3123", "gene1072"
))
expect_equal(length(res@gene_clusters), 1)
expect_equal(round(sum(res@data), 3), -22.454)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.