tests/testthat/test-mito_df.R

context("Creating mitochondrial dataframe")

test_that("mito_df returns the correct dataframe", {
    df <- mito_df()
    expect_is(df, "data.frame")
    expect_equal(nrow(df), 39)
    expect_equal(ncol(df), 9)
    expect_equal(colnames(df), c("locus", "lengths", "type", "id",
                                        "ymax", "ymin", "hjust", "vjust", "angle"))
})

test_that("mito_df contains the correct data", {
    df <- mito_df()
    expect_equal(df$locus, c("DLOOP", "TF", "RNR1", "TV", "RNR2", "TL1",
                             "ND1", "TI", "TQ", "TM", "ND2", "TW", "TA", "TN",
                             "TC", "TY", "CO1", "TS1", "TD", "CO2", "TK", "ATP8",
                             "ATP6", "CO3", "TG", "ND3", "TR", "ND4L", "ND4", "TH",
                             "TS2", "TL2", "ND5", "ND6", "TE", "CYTB", "TT", "TP",
                             ""))
    expect_equal(df$lengths, c(576, 71, 954, 69, 1559, 75,
                               956, 69, 72, 68, 1042, 68, 69, 73,
                               66, 66, 1542, 72, 68, 684, 70, 207,
                               681, 784, 68, 346, 65, 297, 1378, 69,
                               59, 71, 1812, 525, 69, 1141, 66, 69,
                               546))
    expect_equal(df$type, c("reg", "trna", "rrna", "trna", "rrna", "trna",
                            "cds", "trna", "trna", "trna", "cds", "trna", "trna", "trna",
                            "trna", "trna", "cds", "trna", "trna", "cds", "trna", "cds",
                            "cds", "cds", "trna", "cds", "trna", "cds", "cds", "trna",
                            "trna", "trna", "cds", "cds", "trna", "cds", "trna", "trna",
                            "reg"))
    expect_equal(df$id, seq(39, 1))
    expect_equal(df$ymax, c(576, 647, 1601, 1670, 3229, 3304,
                            4262, 4331, 4400, 4469, 5511, 5579, 5655, 5729,
                            5826, 5891, 7445, 7514, 7585, 8269, 8364, 8572,
                            9207, 9990, 10058, 10404, 10469, 10766, 12137, 12206,
                            12265, 12336, 14148, 14673, 14742, 15887, 15953, 16023,
                            16569))
    expect_equal(df$ymin, c(0, 576, 647, 1601, 1670, 3229,
                            3304, 4262, 4331, 4400, 4469, 5511, 5579, 5655,
                            5729, 5826, 5891, 7445, 7514, 7585, 8269, 8364,
                            8572, 9207, 9990, 10058, 10404, 10469, 10766, 12137,
                            12206, 12265, 12336, 14148, 14673, 14742, 15887, 15953,
                            16023))
    expect_equal(df$hjust, c(1.2, 1.2, 1.2, 1.2, 1.8, 1.2,
                             1.8, 1.6, 1.2, 1.4, 1.7, 1.2, 1.6, 1.2,
                             1.6, 1.2, 1.6, 1.2, 1.2, -0.2, -0.2, -0.1,
                             -0.2, -0.3, -0.2, -0.2, -0.2, -0.2, -0.6, -0.2,
                             -0.2, -0.2, -0.7, -0.4, -0.2, -0.5, -0.2, -0.2,
                             -0.2))
    expect_equal(df$vjust, c(-5.880, 0.355, -4.770, 0.345, -7.795, 0.375,
                             -4.790, 0.145, 0.345, 0.545, -5.210, 0.040, 0.180, 0.270,
                             0.255, 0.325, -7.770, 0.145, 0.455, 4.020, 1.075, 1.740,
                             3.875, 4.515, 0.940, 2.330, 0.925, 2.285, 7.955, 1.245,
                             0.895, 0.655, 9.660, 3.225, 0.945, 6.325, 1.130, 0.650,
                             2.730))
    expect_equal(df$angle, c(-88.38, -76.15, -66.92, -57.69, -44.46, -28.23,
                             -20.00, -12.77, -2.54, 12.31, 12.92, 16.15, 25.38, 34.61,
                             33.85, 53.08, 55.31, 70.54, 75.77, -95.00, -85.77, -83.54,
                             -72.31, -63.08, -53.86, -48.61, -44.38, -40.15, -20.92, -10.30,
                             1.54, 12.77, 20.00, 39.23, 48.46, 57.69, 66.92, 76.15,
                             85.38))
})
robertopreste/mitovizR documentation built on May 22, 2019, 2:46 p.m.