tests/testthat/testEstimateGeneAge.R

context("test estimation of gene ages")

test_that("test estimation of gene ages", {
    data("fullProcessedProfile", package="PhyloProfile")
    rankName <- "class"
    refTaxon <- "Mammalia"
    var1Cutoff <- c(0,1)
    var2Cutoff <- c(0,1)
    percentCutoff <- c(0,1)
    taxonIDs <- levels(as.factor(fullProcessedProfile$ncbiID))
    sortedInputTaxa <- sortInputTaxa(
        taxonIDs, rankName, refTaxon, NULL
    )
    taxaCount <- plyr::count(sortedInputTaxa, "supertaxon")
    geneAge <- estimateGeneAge(
        fullProcessedProfile, taxaCount,
        rankName, refTaxon,
        var1Cutoff, var2Cutoff, percentCutoff
    )
    expect_true(
        geneAge$age[geneAge$geneID == "103479at6656"] == "08_Eukaryota"
    )
})

test_that("test plotting gene age plot", {
    geneAgeDf <- data.frame(
        geneID = c("OG_1017", "OG_1019"),
        cat = c("0000001", "0000001"),
        age = c("07_LUCA", "07_LUCA"),
        stringsAsFactors = FALSE
    )
    plotDf <- geneAgePlotDf(geneAgeDf)
    geneAgeText <- 1
    p <- createGeneAgePlot(plotDf, geneAgeText)
    expect_true(nrow(p$data) == 1)
})

Try the PhyloProfile package in your browser

Any scripts or data that you put into this service are public.

PhyloProfile documentation built on March 27, 2021, 6:01 p.m.