R/get_focal_and_conditioning_factors.R
get_focal_and_conditioning_factors.Rdget_focal_and_conditioning_factors derives the focal constraining variables(s) and (if present) the
conditioning variables(s) from a rda
or cca ordination specified via a formula for use in a PRC
(with doPRC or PRC_scores)
get_focal_and_conditioning_factors(object, factors_only = TRUE)a result of rda, cca specified via a formula (S3 method for class 'formula'),
or a result of doPRC or PRC_scores.
logical to exclude numeric variables from the focal factor(s). Default TRUE.
A list with element `focal factor` and condition
ter Braak C.J.F. & Šmilauer P. (2018): Canoco reference manual and user's guide: software for ordination, version 5.1x. Microcomputer Power, Ithaca, USA, 536 pp. (http::www.canoco5.com)
data(pyrifos, package = "vegan") #transformed species data from package vegan
#the chlorpyrifos experiment from van den Brink & ter Braak 1999
Design <- data.frame(
week=gl(11, 12, labels=c(-4, -1, 0.1, 1, 2, 4, 8, 12, 15, 19, 24)),
dose=factor(rep(c(0.1, 0, 0, 0.9, 0, 44, 6, 0.1, 44, 0.9, 0, 6), 11)))
library(vegan)
mod_rda <- rda( pyrifos ~ dose:week + Condition(week), data = Design)
#>
#> Some constraints or conditions were aliased because they were redundant. This
#> can happen if terms are constant or linearly dependent (collinear):
#> 'dose44:week-4', 'dose44:week-1', 'dose44:week0.1', 'dose44:week1',
#> 'dose44:week2', 'dose44:week4', 'dose44:week8', 'dose44:week12',
#> 'dose44:week15', 'dose44:week19', 'dose44:week24'
species_scores= scores(mod_rda,choices =1:2, display="sp",scaling = 1)
library(PRC)
head(rdacca_taxon_stats(mod_rda)) # stats per species
#> Var FitCE FitE Cfit1 Fratio1
#> Simve 2.6532363 0.7445540 0.5301872 0.37998997 112.411089
#> Daplo 1.9284326 0.6716078 0.3173191 0.15519258 37.966156
#> Cerpu 1.3570910 0.7312918 0.3269379 0.03028521 6.428153
#> Alogu 0.6614163 0.6542465 0.2391233 0.01654335 3.493023
#> Aloco 0.1899789 0.5043404 0.3404953 0.02301403 3.396316
#> Alore 0.7694871 0.7428779 0.3126996 0.01799620 3.913455
get_focal_and_conditioning_factors(mod_rda) # factors from the model
#> $`focal factor`
#> [1] "dose"
#>
#> $condition
#> [1] "week"
#>
#> attr(,"interaction")
#> [1] TRUE
species_scores= vegan::scores(mod_rda,choices =1:2, display="sp",scaling = 2)
# 1-d vertical plot of species scores (a cut of RDA1-scores at 0.5)
plot_species_scores_bk(species_scores)
#> 15 species with names out of 178 species
# a cut of RDA1-scores at 1.0 (as scoresname is unset)
plot_species_scores_bk(species_scores, threshold = 14)
#> 3 species with names out of 178 species
plot_species_scores_2d(species_scores)
#> 12 species with names out of 178 species
plot_species_scores_2d(species_scores, label.repel = TRUE)
#> 12 species with names out of 178 species
plot_species_scores_2d(species_scores, max.overlaps = 30, label.repel = TRUE)
#> 12 species with names out of 178 species