Title: | An Alternative Visualization of VPA and HP in Canonical Analysis |
Version: | 1.0.0 |
Author: | Yao Liu |
Maintainer: | Yao Liu <lyao222lll@nwafu.edu.cn> |
Description: | Using matrix layout to visualize the unique, common, or individual contribution of each predictor (or matrix of predictors) towards explained variation on canonical analysis. These contributions were derived from variance partitioning analysis (VPA) and hierarchical partitioning (HP), applying the algorithm of Lai J., Zou Y., Zhang J., Peres-Neto P. (2022) Generalizing hierarchical and variation partitioning in multiple regression and canonical analyses using the rdacca.hp R package.Methods in Ecology and Evolution, 13: 782-788 <doi:10.1111/2041-210X.13800>. |
URL: | https://github.com/LiuXYh/UpSetVP |
BugReports: | https://github.com/LiuXYh/UpSetVP/issues |
Depends: | R (≥ 3.6.0) |
Imports: | rdacca.hp, ggplot2, patchwork, grDevices |
Suggests: | adespatial |
LazyData: | no |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Encoding: | UTF-8 |
RoxygenNote: | 7.1.1 |
Date: | 2022-04-30 |
NeedsCompilation: | no |
Packaged: | 2022-04-30 15:20:22 UTC; dell |
Repository: | CRAN |
Date/Publication: | 2022-05-03 10:20:05 UTC |
Visualization of Variation Partitioning and Hierarchical Partitioning
Description
UpSetVP using UpSet matrix layout to visualize the unique, common and individual contribution of each predictor (or matrix) towards explained variation on canonical analysis.
See Also
Useful links:
EcM Fungal Data with Environmental Variables
Description
Ectomycorrhizal (EcM) fungal community and environmental data were excerpted from Gong et al. (2022). Sampling was conducted along the elevation gradient (2,900 m to 4,500 m) in the eastern slope of Baima Snow Mountain during both dry (November 2017) and wet (August 2018) seasons after studying community compositions of the host plants of EcM fungi.
Usage
data(baima.fun)
data(baima.env)
Format
263 samples from the root tips were excerpted. There are two linked data sets: baima.fun
, a data frame containing 3,099 amplicon sequence variants (ASVs) of root associated EcM fungi; baima.env
, a data frame containing 14 environmental variables.
The fields in the environmental data are:
- environmental_medium
Sample type
- latitude
Latitude
- lontitude
Lontitude
- altitude
Elevation (m)
- season
Season, a factor with levels
dry
andwet
- em.GR
Richness of EcM plant at genus level
- em.abun
The number of individuals of each EcM genus
- sea.MT
Dry-season and wet-season mean temperature
- pH
Soil pH
- TP
Total phosphorus (g/kg)
- TK
Total potassium (g/kg)
- AN
Alkaline-hydrolysable nitrogen (mg/kg)
- AP
Available phosphorus (mg/kg)
- AK
Available potassium (mg/kg)
References
Gong S, Feng B, Jian S P, et al. Elevation Matters More than Season in Shaping the Heterogeneity of Soil and Root Associated Ectomycorrhizal Fungal Community. Microbiology spectrum, 2022, 10(1): e01950-21.
Examples
data(baima.fun)
data(baima.env)
Visualization of HP Using Column Diagram
Description
Visualization of individual effects in hierarchical partitioning (HP) using column diagram.
Usage
barplot_hp(
x,
order.var = TRUE,
decreasing.var = TRUE,
cutoff = -1,
col.fill = "valid",
col.color = NULL,
col.width = 0.6,
show.effect = TRUE,
effect.cex = 2.7,
title.cex = 10,
axis.cex = 8
)
Arguments
x |
A |
order.var |
The predictors in the matrix layout should be ordered by. Default is |
decreasing.var |
If |
cutoff |
Effect values below |
col.fill |
How the bars should be colored. Options include |
col.color |
Color of bars. |
col.width |
Width of bars, default is |
show.effect |
Show the effect values above bars, default is |
effect.cex |
Font size of the effect values, default is |
title.cex |
Font size of axis titles, default is |
axis.cex |
Font size of axis labels, default is |
Details
This function is used to visualize the object of rdacca.hp
(Lai et al. 2022), which calculates the individual effects of predictor variables or groups of predictor variables in canonical analysis based on HP.
Value
Returns a ggplot2.
References
Lai J, Zou Y, Zhang J, et al. Generalizing hierarchical and variation partitioning in multiple regression and canonical analyses using the rdacca.hp R package. Methods in Ecology and Evolution, 2022.
Examples
library(rdacca.hp)
## A simple example of partial dbRDA
data(baima.fun)
data(baima.env)
# Bray-Curtis index was used to calculate community composition dissimilarity
baima.fun.bray <- vegdist(baima.fun, method = "bray")
# Quantify the individual effects of soil properties on EcM fungal community composition
soil <- baima.env[c("pH", "TP", "TK", "AN", "AP", "AK")]
baima.soil.vp <- rdacca.hp(baima.fun.bray, soil, method = "dbRDA", type = "adjR2")
# Plot individual effects
barplot_hp(baima.soil.vp, col.fill = "var",
col.color = c("#8DD3C7", "#FFFFB3", "#BEBADA", "#FB8072", "#80B1D3", "#FDB462", "#B3DE69"))
Visualization of VPA and HP Using UpSetVP Diagram
Description
Visualization of variance partitioning analysis (VPA) and hierarchical partitioning (HP) with unlimited number of predictor variables (or matrices of predictors) using UpSet matrix layout.
Usage
upset_vp(
x,
plot.hp = TRUE,
order.part = "effect",
decreasing.part = TRUE,
order.var = TRUE,
decreasing.var = TRUE,
cutoff = -1,
nVar = 30,
col.width = 0.6,
pch.size = 3,
line.lwd = 0.5,
show.effect = TRUE,
effect.cex = 2.7,
title.cex = 10,
axis.cex = 8,
height.ratio = c(2, 1),
width.ratio = c(1, 3)
)
Arguments
x |
A |
plot.hp |
The default is |
order.part |
How the VPA components in matrix layout should be ordered. Options include |
decreasing.part |
How the intersections in |
order.var |
The predictors in the matrix layout should be ordered by. Default is |
decreasing.var |
If |
cutoff |
Effects below |
nVar |
Number of components in VPA to plot, default is |
col.width |
Width of bars in column diagram, default is |
pch.size |
Size of points in matrix diagram, default is |
line.lwd |
Width of lines in matrix diagram, default is |
show.effect |
Show the relative importance of predictors (unique, common, or individual effects) above bars, default is |
effect.cex |
Font size of the effects, default is |
title.cex |
Font size of axis titles, default is |
axis.cex |
Font size of axis labels, default is |
height.ratio |
Ratio between matrix and top column diagram, default is |
width.ratio |
Ratio between matrix and left column diagram, default is |
Details
UpSetVP diagram is an extension of UpSet technique (Conway et al. 2017; Lex et al. 2014) to canonical analysis and is used to visualize the object of rdacca.hp
(Lai et al. 2022). The matrix layout enables the effective representation of relative importance of predictors, such as the unique effects and common effects in VPA, as well as additional summary statistics or individual effects in HP. UpSetVP diagram could, in principle, allow visualization of any number of predictor variables or groups of predictor variables. But considering the interpretability of data, we would like to recommend that the number of predictors (or groups of predictors) no more than 7.
Value
Returns a ggplot2.
References
Conway J R, Lex A, Gehlenborg N. UpSetR: an R package for the visualization of intersecting sets and their properties. Bioinformatics, 2017, 33(18): 2938-2940.
Gong S, Feng B, Jian S P, et al. Elevation Matters More than Season in Shaping the Heterogeneity of Soil and Root Associated Ectomycorrhizal Fungal Community. Microbiology spectrum, 2022, 10(1): e01950-21.
Lai J, Zou Y, Zhang J, et al. Generalizing hierarchical and variation partitioning in multiple regression and canonical analyses using the rdacca.hp R package. Methods in Ecology and Evolution, 2022.
Lex A, Gehlenborg N, Strobelt H, et al. UpSet: visualization of intersecting sets. IEEE transactions on visualization and computer graphics, 2014, 20(12): 1983-1992.
Examples
library(rdacca.hp)
## A simple example of partial dbRDA
data(baima.fun)
data(baima.env)
# Bray-Curtis index was used to calculate community composition dissimilarity
baima.fun.bray <- vegdist(baima.fun, method = "bray")
# The relative importance of individual soil properties on EcM fungal community compositionon
soil <- baima.env[c("pH", "TP", "TK", "AN", "AP", "AK")]
baima.soil.vp <- rdacca.hp(baima.fun.bray, soil,
method = "dbRDA", var.part = TRUE, type = "adjR2")
# Plot unique, common, as well as individual effects
upset_vp(baima.soil.vp, plot.hp = TRUE)
## Example was referenced from Gong et al. (2022)
if(requireNamespace("adespatial", quietly = TRUE)) {
# Distance-based Moran's eigenvector maps (dbMEM) was used to extract spatial relationships
space.dbmem <- adespatial::dbmem(baima.env[c("latitude", "lontitude")])
# The relative importance of groups of environmental factors on EcM fungal community composition
env.list <- list(
elevation = baima.env["altitude"],
season = baima.env["season"],
space = data.frame(space.dbmem)[1:2],
host = baima.env[c("em.GR", "em.abun")],
climate = baima.env["sea.MT"],
soil = baima.env[c("pH", "TP", "TK", "AN", "AP", "AK")]
)
baima.env.vp <- rdacca.hp(baima.fun.bray, env.list,
method = "dbRDA", var.part = TRUE, type = "adjR2")
# Plot unique, common, as well as individual effects
upset_vp(baima.env.vp, plot.hp = TRUE, order.part = "degree")
}