Title: | An Alternative Visualization of VPA and HP in Canonical Analysis |
---|---|
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>. |
Authors: | Yao Liu |
Maintainer: | Yao Liu <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0.0 |
Built: | 2025-02-21 04:31:08 UTC |
Source: | https://github.com/liuxyh/upsetvp |
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.
data(baima.fun) data(baima.env)
data(baima.fun) data(baima.env)
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:
Sample type
Latitude
Lontitude
Elevation (m)
Season, a factor with levels dry
and wet
Richness of EcM plant at genus level
The number of individuals of each EcM genus
Dry-season and wet-season mean temperature
Soil pH
Total phosphorus (g/kg)
Total potassium (g/kg)
Alkaline-hydrolysable nitrogen (mg/kg)
Available phosphorus (mg/kg)
Available potassium (mg/kg)
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.
data(baima.fun) data(baima.env)
data(baima.fun) data(baima.env)
Visualization of individual effects in hierarchical partitioning (HP) using column diagram.
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 )
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 )
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 |
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.
Returns a ggplot2.
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.
## 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 <- vegan::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::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"))
## 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 <- vegan::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::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 variance partitioning analysis (VPA) and hierarchical partitioning (HP) with unlimited number of predictor variables (or matrices of predictors) using UpSet matrix layout.
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) )
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) )
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 |
UpSetVP diagram is an extension of UpSet technique to canonical analysis and is used to visualize the object of rdacca.hp
(Lai et al. 2022; Liu et al. 2023). 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.
Returns a ggplot2.
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.
Liu Y., Yu X., Yu Y., et al. (2023) Application of "rdacca. hp" R package in ecological data analysis: case and progress. Chinese Journal of Plant Ecology, 27:134-144.
## 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 <- vegan::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::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") }
## 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 <- vegan::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::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") }