tests/testthat/test_plot.R

context("Plots")

test_that("plotGseaTable works", {
    data(examplePathways)
    data(exampleRanks)
    fgseaRes <- fgsea(examplePathways, exampleRanks,
                      minSize=15, maxSize=100, eps=0.0)
    tf <- tempfile("plot", fileext = ".png")
    topPathways <- fgseaRes[head(order(pval), n=15)][order(NES), pathway]
    png(filename = tf, width=2000, height=1600, res = 300)
    plotGseaTable(examplePathways[topPathways], exampleRanks, fgseaRes, gseaParam=0.5)
    dev.off()
    expect_true(TRUE) # check that didn't fail before
})

test_that("plotEnrichment works", {
    data(examplePathways)
    data(exampleRanks)
    g <- plotEnrichment(examplePathways[["5991130_Programmed_Cell_Death"]],
                        exampleRanks)
    tf <- tempfile("plot", fileext = ".png")
    ggsave(tf, plot=g)
    expect_true(TRUE) # check that didn't fail before
})

test_that("plotGseaTable ignores empty pathways", {
    data(examplePathways)
    data(exampleRanks)
    fgseaRes <- fgsea(examplePathways, exampleRanks,
                      minSize=15, maxSize=100, eps=0.0)

    expect_equal(length(intersect(examplePathways[477], names(exampleRanks))), 0)
    p <- plotGseaTable(examplePathways[477], exampleRanks, fgseaRes, gseaParam=0.5,
                       render = FALSE)
    expect_true(is(p, "gtable"))
})

Try the fgsea package in your browser

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

fgsea documentation built on Nov. 8, 2020, 5:22 p.m.