tests/testthat/test-ggs_graph.R

context("Testing ggs_graph and related functionality")

test_that("Graph is generated", {
  g <- ggs_graph(res_enrich = res_enrich_IFNg_vs_naive,
                 res_de = res_macrophage_IFNg_vs_naive,
                 annotation_obj = anno_df,
                 n_gs = 20)
  expect_is(g, "igraph")
  g2 <- ggs_graph(res_enrich = res_enrich_IFNg_vs_naive,
                  res_de = res_macrophage_IFNg_vs_naive,
                  annotation_obj = anno_df,
                  n_gs = 30,
                  prettify = FALSE)
  expect_is(g2, "igraph")


  alt_pal <- scales::alpha(
    colorRampPalette(RColorBrewer::brewer.pal(name = "RdYlBu", 11))(50), 0.4)
  g3 <- ggs_graph(res_enrich = res_enrich_IFNg_vs_naive,
                  res_de = res_macrophage_IFNg_vs_naive,
                  annotation_obj = anno_df,
                  n_gs = 10,
                  genes_graph_colpal = alt_pal)
  expect_is(g3, "igraph")

  expect_error(
    ggs_graph(res_enrich = res_enrich_IFNg_vs_naive,
              res_de = res_macrophage_IFNg_vs_naive,
              annotation_obj = anno_df,
              genes_graph_colpal = list("blue", "red"),
              n_gs = 20)
  )

  expect_error(
    ggs_graph(res_enrich = res_enrich_IFNg_vs_naive,
              res_de = res_macrophage_IFNg_vs_naive,
              annotation_obj = anno_df,
              genes_graph_colpal = c("blue", "whitesss", "red"),
              n_gs = 20)
  )
})

Try the GeneTonic package in your browser

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

GeneTonic documentation built on Nov. 8, 2020, 5:27 p.m.