humboldt.plot.overlap: Plot niche overlap of 2 species in environmental space

View source: R/humboldt70.R

humboldt.plot.overlapR Documentation

Plot niche overlap of 2 species in environmental space

Description

Plot niche overlap of 2 species in environmental space

Usage

humboldt.plot.overlap(
  in.g2e = zz,
  pdfname = "OverLapPlot.pdf",
  pdf.out = T,
  swap = F,
  pcx = 1,
  pcy = 2
)

Arguments

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.

Value

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

See Also

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

Examples

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") 

jasonleebrown/humboldt documentation built on Jan. 4, 2024, 7:46 a.m.