humboldt.plot.overlap | R Documentation |
Plot niche overlap of 2 species in environmental space
humboldt.plot.overlap(
in.g2e = zz,
pdfname = "OverLapPlot.pdf",
pdf.out = T,
swap = F,
pcx = 1,
pcy = 2
)
in.g2e |
A dataset output from the humboldt.g2e function. |
pdfname |
a string for the output pdf of the results |
pdf.out |
if pdf.out=T a pdf will be output of plot named as parameter 'pdfname' |
swap |
if swap=T, colors will be switched in plots and the order (from top to bottom) will be reversed. The default value is FALSE. |
pcx |
An integer that identifies one (of two) principal components to be visualized. Default=1. Both defaults result in the 1st and 2nd PCs being compared. |
pcy |
An integer that identifies the second (of two) principal components to be visualized. Default=2. Both defaults result in the 1st and 2nd PCs being compared. |
Plots the overlap of two species' environmental space based on PCs. This code is a derivative work based on a function 'NiceOverPlot' by Javi Fernández-López and Irene Villa.
This tool uses the scores of principal components (or 2 environmental variables. Only two dimensions can be used. If performing a PCA, I strongly encourage you to run a species distribution model using lots of environmental data on the focal species and then load only the top contributing environmental variables to be included in the PCA. This way all included variables are known to be relevant in both species distributions. This can be done inside Humboldt (via humboldt.top.env) by importing many environmental variables and letting program select only those important. Alternatively, this can also be done using another method (MaxEnt) outside of R and then use only variables deemed important in the species' distributions
humboldt.g2e, 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 environment variables for all sites of the study area 1 (env1). Column names should be x,y,X1,X2,...,Xn)
##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)
##merge environment files
env12<-rbind(env1,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 g-space to e-space
full=humboldt.g2e(env1=env1, env2=env2, sp1=occ.sp1, sp2=occ.sp2, reduce.env = 2, reductype = "PCA", non.analogous.environments = "NO", env.trim= T, env.trim.type= "MCP", 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)
humboldt.plot.overlap(in.g2e=full, pdfname="FullEspaceOverlapSp1and2")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.