Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: iSEEtree
Version: 1.3.1
Version: 1.3.2
Authors@R:
c(person(given = "Giulio", family = "Benedetti", role = c("aut", "cre"),
email = "giulio.benedetti@utu.fi",
Expand Down
52 changes: 52 additions & 0 deletions tests/testthat/test-ColumnGraphPlot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
test_that("ColumnGraphPlot", {

output <- new.env()
pObjects <- new.env()
rObjects <- new.env()
select_info <- list(single = list(feature = "---", sample = "---"),
multi = list(row = "---", column = "---"))

data("GlobalPatterns", package = "mia")
tse <- GlobalPatterns

data("col_graph", package = "miaViz")
metadata(tse)$graph <- col_graph

panel <- ColumnGraphPlot()

panel[["layout"]] <- "kk"

expect_identical(.getEncodedName(panel), "ColumnGraphPlotNA")
expect_identical(.fullName(panel), "Column graph plot")
expect_identical(.panelColor(panel), "purple")

expect_s3_class(.defineInterface(panel, tse, select_info)[[1]][[1]], "shiny.tag.list")
expect_length(.defineDataInterface(panel, tse, select_info), 3)

expect_s3_class(.defineOutput(panel), "shiny.tag.list")
expect_match(.generateOutput(panel, tse)[["commands"]][["fun"]],
'p <- miaViz::plotColGraph(se, name=\"graph\", assay.type=\"counts\",\n show.label=FALSE, layout=\"kk\", edge.type=\"fan\", add.legend=TRUE)',
fixed = TRUE)

expect_true(.hideInterface(panel, "ColumnSelectionSource"))
expect_false(.multiSelectionResponsive(panel, "row"))
expect_true(.multiSelectionResponsive(panel, "column"))

expect_contains(slotNames(panel), c("name", "assay.type", "layout",
"show.label", "add.legend", "edge.colour.by", "edge.size.by",
"node.colour.by", "node.shape.by", "node.size.by"))

expect_contains(.definePanelTour(panel)[[1]],
c("#ColumnGraphPlotNA_DataBoxOpen", "#ColumnGraphPlotNA_VisualBoxOpen",
"#ColumnGraphPlotNA", "#ColumnGraphPlotNA_SelectionBoxOpen"))

expect_s3_class(.create_visual_box_for_graph(panel, tse), "shiny.tag.list")

expect_null(.renderOutput(panel, tse, output = output, pObjects = pObjects, rObjects = rObjects))
expect_s3_class(output$ColumnGraphPlotNA, "shiny.render.function")
expect_s3_class(output$ColumnGraphPlotNA_INTERNAL_PanelMultiSelectInfo, "shiny.render.function")
expect_s3_class(output$ColumnGraphPlotNA_INTERNAL_PanelSelectLinkInfo, "shiny.render.function")

expect_identical(.exportOutput(panel, tse), "ColumnGraphPlotNA.pdf")

})
48 changes: 48 additions & 0 deletions tests/testthat/test-PrevalencePlot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
test_that("PrevalencePlot", {

output <- new.env()
pObjects <- new.env()
rObjects <- new.env()
select_info <- list(single = list(feature = "---", sample = "---"),
multi = list(row = "---", column = "---"))

data("Tengeler2020", package = "mia")
tse <- Tengeler2020

panel <- PrevalencePlot()

panel[["include.lowest"]] <- TRUE

expect_identical(.getEncodedName(panel), "PrevalencePlotNA")
expect_identical(.fullName(panel), "Prevalence plot")
expect_identical(.panelColor(panel), "grey")

expect_s3_class(.defineInterface(panel, tse, select_info)[[1]][[1]], "shiny.tag.list")
expect_length(.defineDataInterface(panel, tse, select_info), 6)

expect_s3_class(.defineOutput(panel), "shiny.tag.list")
# expect_match(.generateOutput(panel, tse)[["commands"]][["fun"]],
# 'p <- miaViz::plotRowGraph(se, name=\"graph\", assay.type=\"counts\",\n show.label=FALSE, layout=\"kk\", edge.type=\"fan\", add.legend=TRUE)',
# fixed = TRUE)

expect_true(.hideInterface(panel, "ColumnSelectionSource"))
expect_false(.multiSelectionResponsive(panel, "column"))
expect_true(.multiSelectionResponsive(panel, "row"))

expect_contains(slotNames(panel), c("detection", "prevalence", "assay.type",
"rank", "include.lowest", "show.rank"))

expect_contains(.definePanelTour(panel)[[1]],
c("#PrevalencePlotNA_DataBoxOpen", "#PrevalencePlotNA",
"#PrevalencePlotNA_SelectionBoxOpen"))

expect_s3_class(.create_visual_box_for_prev_plot(panel, tse), "shiny.tag.list")

expect_null(.renderOutput(panel, tse, output = output, pObjects = pObjects, rObjects = rObjects))
expect_s3_class(output$PrevalencePlotNA, "shiny.render.function")
expect_s3_class(output$PrevalencePlotNA_INTERNAL_PanelMultiSelectInfo, "shiny.render.function")
expect_s3_class(output$PrevalencePlotNA_INTERNAL_PanelSelectLinkInfo, "shiny.render.function")

# expect_identical(.exportOutput(panel, tse), "PrevalencePlotNA.pdf")

})
54 changes: 54 additions & 0 deletions tests/testthat/test-RowGraphPlot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
test_that("RowGraphPlot", {

output <- new.env()
pObjects <- new.env()
rObjects <- new.env()
select_info <- list(single = list(feature = "---", sample = "---"),
multi = list(row = "---", column = "---"))

data("GlobalPatterns", package = "mia")
tse <- GlobalPatterns

data("row_graph_order", package = "miaViz")

tse <- mia::agglomerateByRank(tse, rank = "Order", na.rm = TRUE)
metadata(tse)$graph <- row_graph_order

panel <- RowGraphPlot()

panel[["layout"]] <- "kk"

expect_identical(.getEncodedName(panel), "RowGraphPlotNA")
expect_identical(.fullName(panel), "Row graph plot")
expect_identical(.panelColor(panel), "orange")

expect_s3_class(.defineInterface(panel, tse, select_info)[[1]][[1]], "shiny.tag.list")
expect_length(.defineDataInterface(panel, tse, select_info), 3)

expect_s3_class(.defineOutput(panel), "shiny.tag.list")
expect_match(.generateOutput(panel, tse)[["commands"]][["fun"]],
'p <- miaViz::plotRowGraph(se, name=\"graph\", assay.type=\"counts\",\n show.label=FALSE, layout=\"kk\", edge.type=\"fan\", add.legend=TRUE)',
fixed = TRUE)

expect_true(.hideInterface(panel, "ColumnSelectionSource"))
expect_false(.multiSelectionResponsive(panel, "column"))
expect_true(.multiSelectionResponsive(panel, "row"))

expect_contains(slotNames(panel), c("name", "assay.type", "layout",
"show.label", "add.legend", "edge.colour.by", "edge.size.by",
"node.colour.by", "node.shape.by", "node.size.by"))

expect_contains(.definePanelTour(panel)[[1]],
c("#RowGraphPlotNA_DataBoxOpen", "#RowGraphPlotNA_VisualBoxOpen",
"#RowGraphPlotNA", "#RowGraphPlotNA_SelectionBoxOpen"))

expect_s3_class(.create_visual_box_for_graph(panel, tse), "shiny.tag.list")

expect_null(.renderOutput(panel, tse, output = output, pObjects = pObjects, rObjects = rObjects))
expect_s3_class(output$RowGraphPlotNA, "shiny.render.function")
expect_s3_class(output$RowGraphPlotNA_INTERNAL_PanelMultiSelectInfo, "shiny.render.function")
expect_s3_class(output$RowGraphPlotNA_INTERNAL_PanelSelectLinkInfo, "shiny.render.function")

expect_identical(.exportOutput(panel, tse), "RowGraphPlotNA.pdf")

})
50 changes: 50 additions & 0 deletions tests/testthat/test-ScreePlot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
test_that("ScreePlot", {

output <- new.env()
pObjects <- new.env()
rObjects <- new.env()
select_info <- list(single = list(feature = "---", sample = "---"),
multi = list(row = "---", column = "---"))

data("Tengeler2020", package = "mia")
tse <- Tengeler2020
panel <- ScreePlot()

panel[["show.barplot"]] <- FALSE
panel[["show.line"]] <- FALSE

tse <- scater::runPCA(tse, assay.type = "counts", ncomponents = 5)

expect_identical(.getEncodedName(panel), "ScreePlotNA")
expect_identical(.fullName(panel), "Scree plot")
expect_identical(.panelColor(panel), "#0066CC")

expect_s3_class(.defineInterface(panel, tse, select_info)[[1]][[1]], "shiny.tag.list")
expect_length(.defineDataInterface(panel, tse, select_info), 5)

expect_s3_class(.defineOutput(panel), "shiny.tag.list")
expect_match(.generateOutput(panel, tse)[["commands"]][["fun"]],
"p <- miaViz::plotScree(se, dimred=\"PCA\", show.barplot=FALSE, show.points=TRUE,\n show.line=FALSE, add.proportion=TRUE, add.cumulative=FALSE,\n show.names=FALSE, show.labels=FALSE, n=5)",
fixed = TRUE)

# expect_true(.hideInterface(panel, "ColumnSelectionSource"))
# expect_false(.multiSelectionResponsive(panel, "column"))
# expect_true(.multiSelectionResponsive(panel, "row"))

expect_contains(slotNames(panel), c("dimred", "show.barplot", "show.points",
"show.line", "show.labels", "add.proportion", "add.cumulative", "n",
"show.names", "eig.name"))

expect_contains(.definePanelTour(panel)[[1]],
c("#ScreePlotNA_DataBoxOpen"))

expect_s3_class(.create_visual_box_for_scree_plot(panel, tse), "shiny.tag.list")

expect_null(.renderOutput(panel, tse, output = output, pObjects = pObjects, rObjects = rObjects))
expect_s3_class(output$ScreePlotNA, "shiny.render.function")
# expect_s3_class(output$ScreePlotNA_INTERNAL_PanelMultiSelectInfo, "shiny.render.function")
# expect_s3_class(output$ScreePlotNA_INTERNAL_PanelSelectLinkInfo, "shiny.render.function")

expect_identical(.exportOutput(panel, tse), "ScreePlotNA.pdf")

})
Loading