plot.CWMSNCr | R Documentation |
plot.CWMSNCr
plots the results of CWMSNC_regressions
for the single quantitative trait
and the single quantitative environmental variable,
specified by the arguments trait
and env
.
Both main effects (site totals vs E and species totals vs T) and the associations (CWM vs E and SNC vs T) are plotted.
## S3 method for class 'CWMSNCr' plot(x, ..., title = NA, trait = 1, env = 1)
x |
an object of class CWMSNCr, created by |
... |
other optional arguments |
title |
character text for the main title of the association graph (optional) |
trait |
trait name or level of a nominal tait to be plotted. |
env |
environmental variable name or level of a nominal environmental variable to be plotted |
In the one E vector - one T vector case, you can choose your own labels for trait
and env
.
In the E or T matrix or data frame case, names shoud refer to names of variables or labels of factors.
If in error, a list of names is returned.
The arguments trait
and env
can be numbers referring to the
columns numbers in x$E and x$T;
these numbers do not reflect the orginal E and T if any variable in them is a factor (nominal).
The code uses the libraries ggplot2 and dplyr.
A list of two printable and modifiable objects of class ggplot2. The first plots the main effects, the second the association. The y-coordinate of the points in the first plot is the logarithm of the site total (left) and the species total (right). The y-coordinate of the points in the second plot is weighted trait mean (CWM, left) and weighted environmental mean (SNC, right). The long-dash line is at the weighted mean of the y-coordinate of the points in plots. The dotted line is at the unweighted mean of the trait (left) and of the environmental variable (right). If, in the second-left plot, the dashed line is above the dotted line, the trait main effect is positive (check in first plot, right diagram). If, in the second-right plot, the dashed line is above the dotted line, the environmental main effect is positive (check in first plot, left diagram). In this sense, the second plot shows not only the assocation (interaction) but also the sign of the main effects, shown more explicitly in the first plot.
ter Braak (2019) New robust weighted averaging- and model-based methods for assessing trait-environment relationships. Methods in Ecology and Evolution (https://doi.org/10.1111/2041-210X.13278)
CWMSNC_regressions
.
# get Aravo data set ---------------------------------------------------------- data("aravo", package = "ade4") Y <- aravo$spe SLA <- aravo$traits$SLA Snow <- aravo$env$Snow nrepet <- 19 # change to e.g. 499 or 999 result <- CWMSNC_regressions(Snow, Y, SLA, weighing = "N2", nrepet = nrepet) names(result) result$p_values summary(result) plot(result) Snow <- aravo$env$Snow Spread <- log(aravo$traits$Spread) result <- CWMSNC_regressions(Snow, Y, Spread, weighing = "N2", nrepet = nrepet) result$p_values summary(result) # in the one E vector - one T vector case, you can choose your own labels plot(result, trait = "log Spread", env = "Snow") # untransformed analysis of all pairs. See TutorialWA_Aravo_Multi.r # for transformations that appear useful # data frames E,L,T result <- CWMSNC_regressions(aravo$env, aravo$spe, aravo$traits, weighing = "N2", nrepet = nrepet) #result$p_values # contains all pairwise p-values # for site-based, species-based and max-based permutations #result$wFC # contains all pairwise weighted fourth-corner correlations # (site-based, species-based, and signed min-based) summary(result, type = "max", p_value_adjust_method = "fdr", significance_level = 0.05) # in the E or T matrix or data frame case, # names shoud refer to names of variables or labels of factors # The next statement generates the available valid names. (nam.list <- plot(result, trait = "", env = "" )) plot(result, trait = "Spread", env = "Snow" ) ## All plots # for (trait in nam.list$trait.names){ # for (env in nam.list$env.names){ # print(plot(result, trait = trait, env = env )) # } # }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.