humboldt.plot.niche: Plot niche

View source: R/humboldt70.R

humboldt.plot.nicheR Documentation

Plot niche

Description

Plot niche

Usage

humboldt.plot.niche(
  z,
  title = "",
  name.axis1 = "PC1",
  name.axis2 = "PC2",
  correct.env = F,
  color.ramp = 1
)

Arguments

z

plots a grid of the density of a species occurrence in environmental space output from humboldt.grid.espace

title

title of graph

name.axis1

name of axis 1

name.axis2

name of axis 2

correct.env

If correct.env=T, the analysis corrects occurrence densities of each species by the prevalence of the environments in their range. If correct.env=T, the overlap measure does not correct occurrence densities of each species by the prevalence of the environments in their range.

color.ramp

An integer from 1-6 depict Humbodlt's six coloramps: 1= rgb 2= plasma, 3=viridis, 4=sunset, 5= rainbow, 6= greyscale. for visual depiction, see: https://github.com/jasonleebrown/humboldt/blob/master/HumboldtInputExp.pdf

Value

Plots the density of a species occurrence in environmental space output from humboldt.grid.espace. Graph attributes include a string value for: title,name.axis1 and name.axis2 to be included in the plot.

See Also

humboldt.sample.spp,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 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 scores 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
z1<- humboldt.grid.espace(scores.env12,scores.env1,scores.sp1,kern.smooth=1,R=100)
z2<- humboldt.grid.espace(scores.env12,scores.env2,scores.sp2,kern.smooth=1,R=100)
#'
## plot niche in espace
humboldt.plot.niche(z1,"Species 1","PC1","PC2")
humboldt.plot.niche(z2,"Species 2","PC1","PC2")

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