humboldt.plot.espace.diff | R Documentation |
Plot differences in espace between environments and species' distributions
humboldt.plot.espace.diff(
espace.diff,
correct.env = F,
type = "species",
pcx = 1,
pcy = 2
)
espace.diff |
output from humboldt.espace.correction |
correct.env |
if correct.env=T, this function displays the espace differences between occurrence densities of both species or differences between both environments, which are corrected by the prevalence of the corresponding environments in their range. If correct.env=F, this function displays the espace differences between occurrence densities of both species or differences between both environments without correcting the prevalence of the corresponding environments in their range. |
type |
if type="species", plots will show differences in espace between the two input species. if type="environments", plots will show differences in espace among environments. |
pcx |
An integer that identifies one (of two) principal components used to perform niche quantification and quantitative tests on. This paramater must be the same input into humbdoldt.g2e for all downstream analyses. Default=1. Both defaults result in the 1st and 2nd PCs being compared. |
pcy |
An integer that identifies the second (of two) principal components used to perform niche quantification and quantitative tests on. This paramater must be the same input into humbdoldt.g2e for all downstream analyses. Default=2. Both defaults result in the 1st and 2nd PCs being compared. |
Function plots differences observed in species or environmental espace. Used to determine if users should correct occurrence densities of each species by the prevalence of the environments in their range for equivalence, background and overlap analyses (correct.env=T). Often datasets have high overlap among the differences between input environments and the differences between species distributions in environmental space. If ignored, equivalence statistics are prone to type I errors and you may observed statistical differences that are entirely due to differences in the availability of environments vs. actual differences in occupied environmental space. When highly correlated, it is strongly encouraged to use 'correct.env=T' to correct espace observations by abundance of environments"
humboldt.g2e, humboldt.grid.espace, humboldt.equivalence.stat, humboldt.background.stat, humboldt.niche.similarity, humboldt.plot.niche,humboldt.doitall
which use or depend on outputs of this function
library(humboldt)
##load environmental variables for all sites of the study area 1 (env1). Column names should be x,y,X1,X2,...,Xn)
env1<-read.delim("env1.txt",h=T,sep="\t")
## load environmental variables for all sites of the study area 2 (env2). Column names should be x,y,X1,X2,...,Xn)
env2<-read.delim("env2.txt",h=T,sep="\t")
## remove NAs and make sure all variables are imported as numbers
env1<-humboldt.scrub.env(env1)
env2<-humboldt.scrub.env(env2)
##load occurrence sites for the species at study area 1 (env1). Column names should be 'sp', 'x','y'
occ.sp1<-na.exclude(read.delim("sp1.txt",h=T,sep="\t"))
##load occurrence sites for the species at study area 2 (env2). Column names should be 'sp', 'x','y'.
occ.sp2<-na.exclude(read.delim("sp2.txt",h=T,sep="\t"))
##convert geographic space to espace
zz<-humboldt.g2e(env1=env1, env2=env2, sp1=occ.sp1, sp2=occ.sp2, reduce.env = 2, reductype = "PCA", non.analogous.environments = "NO", env.trim= T, e.var=c(3:21), col.env = e.var, trim.buffer.sp1 = 200, trim.buffer.sp2 = 200, rarefy.dist = 50, rarefy.units="km", env.reso=0.41666669, kern.smooth = 1, R = 100, run.silent = F)
##store espace socres for sp1 and environments 1,2 and both environments combined output from humboldt.g2e
scores.env1<-zz$scores.env1[1:2]
scores.env2<-zz$scores.env2[1:2]
scores.env12<- rbind(zz$scores.env1[1:2],zz$scores.env2[1:2])
scores.sp1<-zz$scores.sp1[1:2]
scores.sp2<-zz$scores.sp2[1:2]
## run create a grid of Environmental Space Function
z.sp1<- humboldt.grid.espace(scores.env12,scores.env1,scores.sp1,kern.smooth=1,R=100)
z.sp2<- humboldt.grid.espace(scores.env12,scores.env2,scores.sp2,kern.smooth=1,R=100)
z.env1<- humboldt.grid.espace(scores.env12,scores.env1,scores.env1,kern.smooth=1,R=100)
z.env2<- humboldt.grid.espace(scores.env12,scores.env2,scores.env2,kern.smooth=1,R=100)
ee<- humboldt.espace.correction(Z.env1=z1,Z.env2=z2,Z.sp1=z3,Z.sp2=z4)
## plot differences between species' espaces
humboldt.plot.espace.diff<-espace.diff=ee, correct.env=F, type="species")
##plot contour lines of environment 1 if env1 and env2 are not identical
if(ee$s.uncor.sum!=0){
contour(z.env1$x,(sort((z.env1$y))),z.env1$Z,add=T,levels=quantile(z.env1$Z[z.env1$Z>0],c(0.1,0.5,0.75)),drawlabels=F,lty=c(1,2,3), lwd=c(1,1,1), col="grey")}
## plot differences between environments' espaces
humboldt.plot.espace.diff<-espace.diff=ee, correct.env=F, type="environments")
##plot contour lines of environmental 1 if env1 and env2 are not identical
if(ee$e.uncor.sum!=0){
contour(z.env1$x,(sort((z.env1$y))),z.env1$Z,add=T,levels=quantile(z.env1$Z[z.env1$Z>0],c(0.1,0.5,0.75)),drawlabels=F,lty=c(1,2,3), lwd=c(1,1,1), col="grey")}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.