Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve vignettes #34

Merged
merged 2 commits into from
Jul 19, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ inst/doc
vignettes/*.html
vignettes/*.R
iSEEtree.BiocCheck/
tests/testthat/*.pdf
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: iSEEtree
Version: 0.99.3
Version: 0.99.4
Authors@R:
c(person(given = "Giulio", family = "Benedetti", role = c("aut", "cre"),
email = "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion R/class-RowTreePlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ RowTreePlot <- function(...) {
#' @importFrom methods slot
setMethod(".defineDataInterface", "RowTreePlot", function(x, se, select_info) {
panel_name <- .getEncodedName(x)

print(select_info)
list(.checkboxInput.iSEE(x, field="order_tree", label="Order tree",
value=slot(x, "order_tree")))
})
Expand Down
92 changes: 75 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,26 @@
[![codecov](https://codecov.io/gh/microbiome/iSEEtree/branch/devel/graph/badge.svg)](https://app.codecov.io/gh/microbiome/iSEEtree?branch=devel)
[![codefactor](https://www.codefactor.io/repository/github/microbiome/iseetree/badge)](https://www.codefactor.io/repository/github/microbiome/iseetree)

The goal of iSEEtree is to provide panels related to TreeSummarizedExperiment
objects which facilitate the interactive visualisation of microbiome data in
[_iSEE_](https://isee.github.io/).
## Introduction

iSEEtree is a Bioconductor package for the interactive visualisation of
microbiome data stored in a TreeSummarizedExperiment (TreeSE) container. On the
one side, it leverages and extends the graphics of the iSEE package, which is
designed for the generic SummarizedExperiment class. On the other side, it
employs the statistical and visual tools for microbiome data science provided by
the mia family of packages. Thus, iSEE and mia represent the two building blocks
of iSEEtree. Detailed introductory material on these two frameworks is available
in the [iSEE-verse website](https://isee.github.io/) and the
[OMA Bioconductor book](https://microbiome.github.io/OMA/docs/devel/),
respectively.

iSEEtree is meant for new and experienced users alike, who desire to create and
interact with several graphics for microbiome data, without an in-depth
knowledge of the underlying mia functionality. Current microbiome-specific
panels include phylogenetic trees, ordination plots and compositional plots,
which can be further explored below in this article. Other more generic panels
are also reused from the iSEE package and can be experimented in
[this article](https://isee.github.io/iSEE/articles/basic.html).

## Installation instructions
The release version of iSEEtree can be installed from Bioconductor as follows:
Expand All @@ -30,7 +47,7 @@ if (!requireNamespace("BiocManager", quietly = TRUE))
# The following initializes usage of Bioc devel
BiocManager::install(version='devel')

BiocManager::install("mia")
BiocManager::install("iSEEtree")
```

## Example
Expand All @@ -57,13 +74,65 @@ if (interactive()) {
}
```

## Panels

iSEEtree derives its microbiome-related visualisation methods from the
[miaViz](https://microbiome.github.io/miaViz/) package, which is code-based and
requires basic knowledge of R programming and microbiome data structures. The
following panels represent an easy-to-use interactive version of the miaViz
plotting functions:

- [AbundanceDensityPlot](https://microbiome.github.io/iSEEtree/reference/AbundanceDensityPlot.html):
a density plot of the top features, where every line is a feature and the x
axis shows its abundance for different samples. Its interpretation is
explained in the OMA chapter on
[Exploration](https://microbiome.github.io/OMA/docs/devel/pages/12_quality_control.html).
- [AbundancePlot](https://microbiome.github.io/iSEEtree/reference/AbundancePlot.html):
a compositional barplot of the samples, where every bar is a sample composed
by different features in different colours. Its interpretation is explained
in the OMA chapter on
[Community Composition](https://microbiome.github.io/OMA/docs/devel/pages/21_microbiome_community.html).
- [RDAPlot](https://microbiome.github.io/iSEEtree/reference/RDAPlot.html): an
supervised ordination plot of the samples, where every dot is a sample on a
reduced dimensional space and every arrow reflects the contribution of a
sample variable. Its interpretation is explained in the OMA chapter on
[Community Similarity](https://microbiome.github.io/OMA/docs/devel/pages/20_beta_diversity.html).
- [RowTreePlot](https://microbiome.github.io/iSEEtree/reference/RowTreePlot.html):
a phylogenetic tree of the features, where every tip is a feature and two
neighbouring tips are more closely related than two far apart from each other.

By default, the iSEEtree layout also includes the following panels inherited by
iSEE:

- [RowDataTable](https://isee.github.io/iSEE/articles/basic.html#row-data-tables)
- [ColumnDataTable](https://isee.github.io/iSEE/articles/basic.html#column-data-tables)
- [ReducedDimensionPlot](https://isee.github.io/iSEE/articles/basic.html#reduced-dimension-plots)
- [ComplexHeatmapPlot](https://isee.github.io/iSEE/articles/basic.html#heat-maps)

The [ColumnDataPlot](https://isee.github.io/iSEE/articles/basic.html#coldataplot)
could also prove useful for the visualisation of column variables such as
alpha diversity indices. Its interpretation is explained in the OMA chapter on
[Community Diversity](https://microbiome.github.io/OMA/docs/devel/pages/14_alpha_diversity.html).

## Code of Conduct
Please note that the iSEEtree project is released with a
[Contributor Code of Conduct](https://bioconductor.org/about/code-of-conduct/).
By contributing to this project, you agree to abide by its terms. Contributions
are welcome in the form of feedback, issues and pull requests. You can find the
contributor guidelines of the miaverse
[here](https://github.com/microbiome/mia/blob/devel/CONTRIBUTING.md).

## Acknowledgements
Please note that iSEEtree was only made possible thanks to many other R and
bioinformatics software authors, which are cited either in the vignettes and/or
the paper(s) describing this package. In particular, iSEEtree implements the [_miaViz_](https://microbiome.github.io/miaViz/) package for microbiome data
visualisation to create panels that are specific for TreeSummarizedExperiment
objects. Not surprisingly, it also depends on the generic panels from iSEE.

## Development tools
This package was developed using the following resources:

- [_usethis_](https://cran.r-project.org/web/packages/usethis/) to generate an
initial template.
- Continuous code testing is performed on
[GitHub actions](https://github.com/features/actions) and include R CMD check,
[_BiocCheck_](https://bioconductor.org/packages/3.16/bioc/html/BiocCheck.html)
Expand All @@ -76,15 +145,4 @@ objects. Not surprisingly, it also depends on the generic panels from iSEE.
[_devtools_](https://cran.r-project.org/web/packages/devtools/) and
[_roxygen2_](https://cran.r-project.org/web/packages/roxygen2/).
- All the actions above are made reproducible by
[_rworkflows_](https://neurogenomics.github.io/rworkflows/)

This package was developed using
[_usethis_](https://cran.r-project.org/web/packages/usethis/).

## Code of Conduct
Please note that the iSEEtree project is released with a
[Contributor Code of Conduct](https://bioconductor.org/about/code-of-conduct/).
By contributing to this project, you agree to abide by its terms. Contributions
are welcome in the form of feedback, issues and pull requests. You can find the
contributor guidelines of the miaverse
[here](https://github.com/microbiome/mia/blob/devel/CONTRIBUTING.md).
[_rworkflows_](https://neurogenomics.github.io/rworkflows/)
14 changes: 10 additions & 4 deletions tests/testthat/test-AbundanceDensityPlot.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
test_that("AbundanceDensityPlot", {

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 <- AbundanceDensityPlot()
Expand All @@ -8,6 +14,9 @@ test_that("AbundanceDensityPlot", {
expect_identical(.fullName(panel), "Abundance density plot")
expect_identical(.panelColor(panel), "#8B5A2B")

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::plotAbundanceDensity(se, layout="jitter", add_legend=TRUE,\n',
Expand All @@ -27,16 +36,13 @@ test_that("AbundanceDensityPlot", {

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

output <- new.env()
pObjects <- new.env()
rObjects <- new.env()

expect_null(.renderOutput(panel, tse, output = output, pObjects = pObjects, rObjects = rObjects))
expect_s3_class(output$AbundanceDensityPlotNA, "shiny.render.function")
expect_s3_class(output$AbundanceDensityPlotNA_INTERNAL_PanelMultiSelectInfo, "shiny.render.function")
expect_s3_class(output$AbundanceDensityPlotNA_INTERNAL_PanelSelectLinkInfo, "shiny.render.function")

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

})

Expand Down
15 changes: 11 additions & 4 deletions tests/testthat/test-AbundancePlot.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
test_that("AbundancePlot", {

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 <- AbundancePlot()
Expand All @@ -10,6 +16,9 @@ test_that("AbundancePlot", {
expect_identical(.fullName(panel), "Abundance plot")
expect_identical(.panelColor(panel), "#00E5EE")

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

expect_s3_class(.defineOutput(panel), "shiny.tag.list")
expect_match(.generateOutput(panel, tse)[["commands"]][["fun"]],
'p <- miaViz::plotAbundance(se, rank="Kingdom", add_legend=TRUE,
Expand All @@ -28,13 +37,11 @@ test_that("AbundancePlot", {
expect_s3_class(.create_visual_box_for_abund_plot(panel, tse),
"shiny.tag.list")

output <- new.env()
pObjects <- new.env()
rObjects <- new.env()

expect_null(.renderOutput(panel, tse, output = output, pObjects = pObjects, rObjects = rObjects))
expect_s3_class(output$AbundancePlotNA, "shiny.render.function")
expect_s3_class(output$AbundancePlotNA_INTERNAL_PanelMultiSelectInfo, "shiny.render.function")
expect_s3_class(output$AbundancePlotNA_INTERNAL_PanelSelectLinkInfo, "shiny.render.function")

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

})
15 changes: 10 additions & 5 deletions tests/testthat/test-RDAPlot.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
test_that("RDAPlot", {

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

data("enterotype", package = "mia")
tse <- enterotype
panel <- RDAPlot()
Expand All @@ -14,6 +20,9 @@ test_that("RDAPlot", {
expect_identical(.fullName(panel), "RDA plot")
expect_identical(.panelColor(panel), "#CD5B45")

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

expect_s3_class(.defineOutput(panel), "shiny.tag.list")
expect_match(.generateOutput(panel, tse)[["commands"]][["fun"]],
'p <- miaViz::plotRDA(se, dimred="RDA", colour_by="ClinicalStatus",\n ',
Expand All @@ -35,13 +44,9 @@ test_that("RDAPlot", {

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

output <- new.env()
pObjects <- new.env()
rObjects <- new.env()

expect_null(.renderOutput(panel, tse, output = output, pObjects = pObjects, rObjects = rObjects))
expect_s3_class(output$RDAPlotNA, "shiny.render.function")
expect_s3_class(output$RDAPlotNA_INTERNAL_PanelMultiSelectInfo, "shiny.render.function")
expect_s3_class(output$RDAPlotNA_INTERNAL_PanelSelectLinkInfo, "shiny.render.function")

})
15 changes: 11 additions & 4 deletions tests/testthat/test-RowTreePlot.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
test_that("RowTreePlot", {

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 <- RowTreePlot()
Expand All @@ -10,6 +16,9 @@ test_that("RowTreePlot", {
expect_identical(.fullName(panel), "Row tree plot")
expect_identical(.panelColor(panel), "#4EEE94")

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

expect_s3_class(.defineOutput(panel), "shiny.tag.list")
expect_match(.generateOutput(panel, tse)[["commands"]][["fun"]],
'p <- miaViz::plotRowTree(se, layout="rectangular", add_legend=TRUE,
Expand All @@ -32,13 +41,11 @@ test_that("RowTreePlot", {

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

output <- new.env()
pObjects <- new.env()
rObjects <- new.env()

expect_null(.renderOutput(panel, tse, output = output, pObjects = pObjects, rObjects = rObjects))
expect_s3_class(output$RowTreePlotNA, "shiny.render.function")
expect_s3_class(output$RowTreePlotNA_INTERNAL_PanelMultiSelectInfo, "shiny.render.function")
expect_s3_class(output$RowTreePlotNA_INTERNAL_PanelSelectLinkInfo, "shiny.render.function")

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

})
7 changes: 5 additions & 2 deletions tests/testthat/test-iSEEtree.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ test_that("iSEEtree", {
AbundancePlot(), AbundanceDensityPlot(),
ReducedDimensionPlot(), ComplexHeatmapPlot())

expect_length(.check_panel(tse, panels, "ReducedDimensionPlot", reducedDims), 6)
expect_warning(
panels <- .check_panel(tse, panels, "ReducedDimensionPlot", reducedDims),
"no valid reducedDims fields for ReducedDimensionPlot"
)

expect_no_error(iSEE(tse))
expect_no_error(iSEE(tse, initial = panels))

})
35 changes: 9 additions & 26 deletions vignettes/iSEEtree.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ knitr::opts_chunk$set(
```

```{r vignetteSetup, echo=FALSE, message=FALSE, warning=FALSE}
## Track time spent on making the vignette
startTime <- Sys.time()

## Bib setup
library(RefManageR)

Expand All @@ -51,15 +48,16 @@ bib <- c(

## Install iSEEtree
R is an open-source statistical environment which can be easily modified to
enhance its functionality via packages. iSEEtree is an R package currently
available on GitHub. In the future, it may be submitted to the
[Bioconductor](https://bioconductor.org/) repository for packages. R can be
installed on any operating system from [CRAN](https://cran.r-project.org/)
after which you can install iSEEtree by using the following commands in your R
session:
enhance its functionality via packages. iSEEtree is an R package available on
[Bioconductor](https://bioconductor.org/). R can be installed on any operating
system from [CRAN](https://cran.r-project.org/) after which you can install
iSEEtree by using the following commands in your R session:

```{r install, eval=FALSE}
remotes::install_github("RiboRings/iSEEtree")
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")

BiocManager::install("iSEEtree")
```

## Required knowledge
Expand Down Expand Up @@ -147,28 +145,13 @@ Code for creating the vignette.
```{r createVignette, eval=FALSE}
## Create the vignette
library(rmarkdown)
system.time(render("iSEEtree.Rmd", "BiocStyle::html_document"))
render("iSEEtree.Rmd", "BiocStyle::html_document")

## Extract the R code
library(knitr)
knit("iSEEtree.Rmd", tangle = TRUE)
```

Date the vignette was generated.

```{r reproduce1, echo=FALSE}
## Date the vignette was generated
Sys.time()
```

Wallclock time spent generating the vignette.

```{r reproduce2, echo=FALSE}
## Processing time in seconds
totalTime <- diff(c(startTime, Sys.time()))
round(totalTime, digits = 3)
```

R session information.

```{r reproduce3, echo=FALSE}
Expand Down
Loading