Skip to content

Commit d02617f

Browse files
committed
Update tests
1 parent 4f754ff commit d02617f

File tree

1 file changed

+56
-5
lines changed

1 file changed

+56
-5
lines changed

tests/testthat/test-functions.R

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,66 @@ test_that("orthologs multiple matches", {
2323
expect_equal(nrow(bglap), 3)
2424
})
2525

26-
test_that("orthologs all mouse genes", {
27-
mgi_human_genes <- babelgene:::mgi_orthologs_df$human_symbol
26+
test_that("orthologs all MGI mouse genes (human to mouse)", {
27+
mgi_human_genes <- unique(babelgene:::mgi_orthologs_df$human_symbol)
2828
mgi_human <- orthologs(genes = mgi_human_genes, species = "mouse", human = TRUE)
2929
expect_s3_class(mgi_human, "data.frame")
30-
expect_gt(nrow(mgi_human), 18000)
31-
mgi_mouse_genes <- babelgene:::mgi_orthologs_df$mouse_symbol
30+
# all input genes should be in the output table
31+
expect_lt(length(unique(mgi_human$human_symbol)), length(mgi_human_genes))
32+
expect_gt(length(unique(mgi_human$human_symbol)), length(mgi_human_genes) * 0.9)
33+
# there should be almost as many mouse genes as human inputs
34+
expect_gt(length(unique(mgi_human$symbol)), length(mgi_human_genes) * 0.9)
35+
})
36+
37+
test_that("orthologs all MGI mouse genes (mouse to human)", {
38+
mgi_mouse_genes <- unique(babelgene:::mgi_orthologs_df$mouse_symbol)
3239
mgi_mouse <- orthologs(genes = mgi_mouse_genes, species = "mouse", human = FALSE)
3340
expect_s3_class(mgi_mouse, "data.frame")
34-
expect_gt(nrow(mgi_mouse), 18000)
41+
# most input genes should be in the output table
42+
expect_lt(length(unique(mgi_mouse$symbol)), length(mgi_mouse_genes))
43+
expect_gt(length(unique(mgi_mouse$symbol)), length(mgi_mouse_genes) * 0.9)
44+
# there should be almost as many human genes as mouse inputs
45+
expect_gt(length(unique(mgi_mouse$human_symbol)), length(mgi_mouse_genes) * 0.8)
46+
})
47+
48+
test_that("orthologs all AGR genes", {
49+
agr_df <- babelgene:::agr_orthologs_df
50+
# Mus musculus
51+
agr_mm <- agr_df[agr_df$species_name == "Mus musculus", ]
52+
set.seed(99)
53+
agr_hs_mm <- sample(unique(agr_mm$human_symbol), 1000)
54+
agr_hs_mm <- orthologs(genes = agr_hs_mm, species = "mouse", human = TRUE, min_support = 2)
55+
expect_s3_class(agr_hs_mm, "data.frame")
56+
expect_gt(length(unique(agr_hs_mm$human_symbol)), 950)
57+
expect_gt(length(unique(agr_hs_mm$symbol)), 950)
58+
expect_lt(length(unique(agr_hs_mm$symbol)), 1050)
59+
# Drosophila melanogaster (14k coding genes)
60+
agr_dm <- agr_df[agr_df$species_name == "Drosophila melanogaster", ]
61+
set.seed(99)
62+
agr_hs_dm <- sample(unique(agr_dm$human_symbol), 1000)
63+
agr_hs_dm <- orthologs(genes = agr_hs_dm, species = "Drosophila melanogaster", human = TRUE, min_support = 2)
64+
expect_s3_class(agr_hs_dm, "data.frame")
65+
expect_gt(length(unique(agr_hs_dm$human_symbol)), 900)
66+
expect_gt(length(unique(agr_hs_dm$symbol)), 1000)
67+
expect_lt(length(unique(agr_hs_dm$symbol)), 1100)
68+
# Caenorhabditis elegans (20k coding genes)
69+
agr_ce <- agr_df[agr_df$species_name == "Caenorhabditis elegans", ]
70+
set.seed(99)
71+
agr_hs_ce <- sample(unique(agr_ce$human_symbol), 1000)
72+
agr_hs_ce <- orthologs(genes = agr_hs_ce, species = "Caenorhabditis elegans", human = TRUE, min_support = 2)
73+
expect_s3_class(agr_hs_ce, "data.frame")
74+
expect_gt(length(unique(agr_hs_ce$human_symbol)), 850)
75+
expect_gt(length(unique(agr_hs_ce$symbol)), 1000)
76+
expect_lt(length(unique(agr_hs_ce$symbol)), 1100)
77+
# Saccharomyces cerevisiae (6k coding genes)
78+
agr_sc <- agr_df[agr_df$species_name == "Saccharomyces cerevisiae", ]
79+
set.seed(99)
80+
agr_hs_sc <- sample(unique(agr_sc$human_symbol), 1000)
81+
agr_hs_sc <- orthologs(genes = agr_hs_sc, species = "Saccharomyces cerevisiae", human = TRUE, min_support = 2)
82+
expect_s3_class(agr_hs_sc, "data.frame")
83+
expect_gt(length(unique(agr_hs_sc$human_symbol)), 700)
84+
expect_gt(length(unique(agr_hs_sc$symbol)), 700)
85+
expect_lt(length(unique(agr_hs_sc$symbol)), 800)
3586
})
3687

3788
test_that("orthologs identifier types", {

0 commit comments

Comments
 (0)