species_list
status_list
species_list
append(species_list,'Bla bla')
append(as.character(species_list),'Bla bla')
species_cat_df = cbind(append(as.character(species_list),'Bla bla'),status_list)
write.table(species_cat_df,file=paste0(outdir,'/current_status_missing_species2.txt'),quote=FALSE,sep = '\t',col.names = FALSE,row.names=FALSE)
outdir
if (!'remotes' %in% installed.packages()) {
install.packages('remotes')
}
library(remotes)
# install latest outsider
install_github("antonellilab/outsider.base")
## Code
library(outsider)
#> ----------------
#> outsider v 0.1.0
#> ----------------
#> - Security notice: be sure of which modules you install
repo <- "dombennett/om..hello.world"
module_install(repo = repo, force = TRUE)
hello_world <- module_import(fname = "hello_world", repo = repo)
hello_world()
install_github("antonellilab/outsider")
## Code
library(outsider)
repo <- "dombennett/om..hello.world"
module_install(repo = repo, force = TRUE)
hello_world <- module_import(fname = "hello_world", repo = repo)
hello_world()
A=c(1,2,3,5,NA)
mean(A)
mean(A,na.rm=TRUE)
mean(A,na.rm=TR)
read.table('/Users/tobias/Desktop/Trait_data.csv')
A = read.CSV('/Users/tobias/Desktop/Trait_data.csv')
A = read.csv('/Users/tobias/Desktop/Trait_data.csv')
A
A$ Binomial.1.2
A $ Binomial.1.2
A $        Binomial.1.2
A $
Binomial.1.2
mean(A,na.rm=TR)
# birds
data = readRDS('/Users/tobias/GitHub/iucn_predictions/data/raw/generation_length/birds/df_birds_toby.rds')
randint = sample(1:25, 1)
sampled_imputation = data[[randint]]
data
species = data$binomial
species
gl_values_days = (10^data$GL)*365
bm_values = 10^data$body_mass_median
final_data = cbind(species,gl_values_days,bm_values)
data = readRDS("/Users/tobias/GitHub/mammal_extinction/data/raw/other_data/mammal_generation_times/robs_data.rds")
randint = sample(1:25, 1)
sampled_imputation = data[[randint]]
species = sampled_imputation$binomial
gl_values_days = (10^sampled_imputation$GL)*365
bm_values = 10^sampled_imputation$body_mass_median
final_data = cbind(species,gl_values_days,bm_values)
write.table(final_data,file="/Users/tobias/GitHub/iucn_predictions/data/raw/generation_length/mammals/mammals_bm_gl.txt",quote=F,sep="\t",row.names = F,col.names = T)
# birds
data = readRDS('/Users/tobias/GitHub/iucn_predictions/data/raw/generation_length/birds/df_birds_toby.rds')
species = data$binomial
gl_values_days = (10^data$GL)*365
bm_values = 10^data$body_mass_median
final_data = cbind(species,gl_values_days,bm_values)
write.table(final_data,file="/Users/tobias/GitHub/iucn_predictions/data/raw/generation_length/birds/birds_bm_gl.txt",quote=F,sep="\t",row.names = F,col.names = T)
# birds
data = readRDS('/Users/tobias/GitHub/iucn_predictions/data/raw/generation_length/birds/df_birds_toby.rds')
species = data$binomial
gl_values_days = (data$GL)*365
bm_values = data$body_mass_median
gl_values_days
bm_values
gl_values_days
install.packages("https://cran.r-project.org/src/contrib/Archive/mvtnorm/mvtnorm_1.0-8.tar.gz", repos=NULL)
install.packages('/Users/spacemule/bin/r_packages/Rphylopars_0.2.9.tar.gz', repos = NULL, type="source")
#install.packages("https://cran.r-project.org/src/contrib/Archive/mvtnorm/mvtnorm_1.0-8.tar.gz", repos=NULL)
#install.packages('/Users/spacemule/bin/r_packages/Rphylopars_0.2.9.tar.gz', repos = NULL, type="source")
install.packages("https://cran.r-project.org/src/contrib/Archive/mvtnorm/mvtnorm_1.0-6.tar.gz", repos=NULL)
#install.packages("https://cran.r-project.org/src/contrib/Archive/mvtnorm/mvtnorm_1.0-8.tar.gz", repos=NULL)
#install.packages('/Users/spacemule/bin/r_packages/Rphylopars_0.2.9.tar.gz', repos = NULL, type="source")
#install.packages("https://cran.r-project.org/src/contrib/Archive/mvtnorm/mvtnorm_1.0-6.tar.gz", repos=NULL)
install_github("ericgoolsby/Rphylopars",dependencies = TRUE)
#install.packages("https://cran.r-project.org/src/contrib/Archive/mvtnorm/mvtnorm_1.0-8.tar.gz", repos=NULL)
#install.packages('/Users/spacemule/bin/r_packages/Rphylopars_0.2.9.tar.gz', repos = NULL, type="source")
#install.packages("https://cran.r-project.org/src/contrib/Archive/mvtnorm/mvtnorm_1.0-6.tar.gz", repos=NULL)
#install_github("ericgoolsby/Rphylopars",dependencies = TRUE)
install.packages('Rphylopars',dependencies = T)
#install.packages("https://cran.r-project.org/src/contrib/Archive/mvtnorm/mvtnorm_1.0-8.tar.gz", repos=NULL)
#install.packages('/Users/spacemule/bin/r_packages/Rphylopars_0.2.9.tar.gz', repos = NULL, type="source")
#install.packages("https://cran.r-project.org/src/contrib/Archive/mvtnorm/mvtnorm_1.0-6.tar.gz", repos=NULL)
#install_github("ericgoolsby/Rphylopars",dependencies = TRUE)
install.packages('Rphylopars',dependencies = T)
require(Rphylopars)
#install.packages("https://cran.r-project.org/src/contrib/Archive/mvtnorm/mvtnorm_1.0-8.tar.gz", repos=NULL)
#install.packages('/Users/spacemule/bin/r_packages/Rphylopars_0.2.9.tar.gz', repos = NULL, type="source")
#install.packages("https://cran.r-project.org/src/contrib/Archive/mvtnorm/mvtnorm_1.0-6.tar.gz", repos=NULL)
#install_github("ericgoolsby/Rphylopars",dependencies = TRUE)
#install.packages('Rphylopars',dependencies = T)
require(Rphylopars)
library(raster)
library(maptools)
library(maps)
library(rgeos)
library(speciesgeocodeR)
library(geosphere)
library(sf)
# define function that reads a bunch of raster files based on a list provided as csv file
get_spatial_data_from_csv <- function(csv_path,world_polygon_file) {
content = read.csv(file=csv_path,header=TRUE,sep="\t")
indeces = content$ISLANDS
spatial_unit = world_polygon_file[indeces[1],]
for (index in indeces[2:length(indeces)]){
island_raster = world_polygon_file[index,]
spatial_unit = island_raster + spatial_unit
}
return(spatial_unit)
}
setwd('/Users/tobias/GitHub/mammal_extinction/data/')
# read in the shape file
level3 = readShapePoly('./raw/spatial_data/botanic_continents/level3/level3')
level2 = readShapePoly('./raw/spatial_data/botanic_continents/level2/level2')
# project the shape_file --> not necessary
#P4S.latlon <- CRS("+proj=longlat +datum=WGS84")
#level3_projected = readShapePoly('./raw/spatial_data/botanic_continents/level3/level3',verbose=TRUE, proj4string=P4S.latlon)
#indo_malaya_projected = level3_projected[which(level3_projected$LEVEL1_COD %in% c(4)),]
#plot(indo_malaya_projected)
# define areas based on level1 categorization
europe_elements = which(level3$LEVEL1_COD %in% c(1))
europe = level3[europe_elements,]
#plot(europe)
africa_elements = which(level3$LEVEL1_COD %in% c(2))
africa = level3[africa_elements,]
#plot(africa)
siberia_elements = which(level2$LEVEL2_NAM %in% c('Siberia','Russian Far East'))
siberia = level2[siberia_elements,]
#plot(siberia)
main_asia_elements = which(level3$LEVEL1_COD %in% c(3))
main_asia = level3[main_asia_elements,]
#plot(main_asia)
indo_malaya_elements = which(level3$LEVEL1_COD %in% c(4))
indo_malaya = level3[indo_malaya_elements,]
#plot(indo_malaya)
australia_elements = which(level3$LEVEL1_COD %in% c(5))
australia = level3[australia_elements,]
#plot(australia)
oceania_elements = which(level3$LEVEL1_COD %in% c(6))
oceania = level3[oceania_elements,]
#plot(oceania)
north_america_elements = which(level3$LEVEL1_COD %in% c(7))
north_america = level3[north_america_elements,]
#plot(north_america)
south_america_elements = which(level3$LEVEL1_COD %in% c(8))
south_america = level3[south_america_elements,]
#plot(south_america)
antarctica_elements = which(level3$LEVEL1_COD %in% c(9))
antarctica = level3[antarctica_elements,]
#plot(antarctica)
eurasia_elements = c(indo_malaya_elements,main_asia_elements,europe_elements)
eurasia_all = level3[eurasia_elements,]
#plot(eurasia_all)
japan_elements = which(level3$LEVEL3_NAM %in% c('Japan'))
japan = level3[japan_elements,]
#plot(japan)
sulawesi_elements = which(level3$LEVEL3_NAM %in% c('Sulawesi'))
sulawesi = level3[sulawesi_elements,]
#plot(sulawesi)
greenland_elements = which(level3$LEVEL3_NAM %in% c('Greenland'))
greenland = level3[greenland_elements,]
#plot(greenland)
iceland_elements = which(level3$LEVEL3_NAM %in% c('Iceland'))
iceland = level3[iceland_elements,]
#plot(iceland)
new_zealand_elements = which(level3$LEVEL3_NAM %in% c('New Zealand North','New Zealand South'))
new_zealand = level3[new_zealand_elements,]
#plot(new_zealand)
beringia_elements = which(level3$LEVEL3_NAM %in% c('Alaska'))
beringia = level3[beringia_elements,]
#plot(beringia)
sardinia_elements = which(level3$LEVEL3_NAM %in% c('Sardegna'))
sardinia = level3[sardinia_elements,]
#plot(sardinia)
philipines_elements = which(level3$LEVEL3_NAM %in% c('Philippines'))
philipines = level3[philipines_elements,]
#plot(philipines)
# remove oceanic islands from defined regions
# 1. define the mainland eurasia, including land-bridge islands
world = readShapePoly('./raw/spatial_data/Shore_Lat_long/GSHHS_i_L1')
eurasia1=world[1,]
eurasia2=world[2,]
eurasia3=get_spatial_data_from_csv("./raw/spatial_data/island_shape_indeces/asia_islands.csv",world)
eurasia4=get_spatial_data_from_csv("./raw/spatial_data/island_shape_indeces/europe_islands.csv",world)
eurasia = eurasia1 + eurasia2 + eurasia3 + eurasia4
africa2=world[3,]
north_america2=world[4,]
south_america2=world[5,]
north_america_islands = get_spatial_data_from_csv("./raw/spatial_data/island_shape_indeces/north_america_islands.csv",world)
south_america_islands = get_spatial_data_from_csv("./raw/spatial_data/island_shape_indeces/south_america_islands.csv",world)
americas = north_america2+south_america2+north_america_islands+south_america_islands
australia_main = world[8,]
australia_islands = get_spatial_data_from_csv("./raw/spatial_data/island_shape_indeces/australia_islands.csv",world)
australia2 = australia_main+australia_islands
madagascar=world[12,]
carribean = get_spatial_data_from_csv("./raw/spatial_data/island_shape_indeces/carribean_islands.csv",world)
oceanic = get_spatial_data_from_csv("./raw/spatial_data/island_shape_indeces/oceanic_islands.csv",world)
# 2. only keep the overlap between the deifned bioregions and the eurasia mainland definition
indo_malaysia_final = intersect(indo_malaya, eurasia)
europe_final = intersect(europe, eurasia)
# we have to manually take care of the northern japanese island hokaido, which is assigned to central asia, but should be siberia
hokaido = intersect(japan,eurasia)
siberia_final = intersect(main_asia, siberia)+hokaido
main_asia_final = intersect(main_asia, eurasia)
central_asia = main_asia-siberia-japan
central_asia_final = intersect(central_asia,eurasia)
north_america_temp = intersect(north_america,americas)
north_america_final = north_america_temp-beringia
north_america_complete = north_america_final+beringia
south_america_final = intersect(south_america,americas)
africa_final = intersect(africa2,africa)
japan_main = japan-hokaido
# unionize the intricate polygons to remove the inner boundaries
eurasia_full = st_union(eurasia)
africa_full = st_union(africa_final)
madagascar_full = st_union(madagascar)
australia_full = st_union(australia2)
north_america_full = st_union(north_america_complete)
south_america_full = st_union(south_america_final)
caribbean_full = st_union(carribean)
eurasia
plot(eurasia$area)
plot(eurasia$id)
plot(eurasia$source)
plot(eurasia$parent_id)
plot(eurasia$sibling_id)
plot(eurasia[1])
# unionize the intricate polygons to remove the inner boundaries
lux_spatial = as(eurasia_full, 'Spatial')
# unionize the intricate polygons to remove the inner boundaries
lux_spatial = as(eurasia, 'Spatial')
# unionize the intricate polygons to remove the inner boundaries
eurasia_spatial = as(eurasia, 'Spatial')
eurasia_full = aggregate(eurasia_spatial, by='NAME_1')
eurasia_spatial
eurasia_full = aggregate(eurasia_spatial)
str(eurasia_spatial)
eurasia_full = st_union(eurasia_spatial)
st_union(eurasia_spatial)
plot(eurasia_spatial)
plot(eurasia_spatial)
plot(world,lwd=.2)
eurasia_spatial[1]
eurasia_spatial[1,]
eurasia_spatial[,1]
eurasia_spatial
eurasia_full = aggregate(eurasia_spatial, by=1)
slotNames(eurasia_spatial)
eurasia_full = aggregate(eurasia_spatial, by='bbox')
eurasia_full
eurasia_spatial
eurasia_spatial$bbox
bbox(eurasia_spatial)
eurasia_full
europe_final
plot(world,lwd=.2)
plot(eurasia,add=T,col='purple',lwd=.2)
africa_final
africa_final$LEVEL3_NAM
# unionize the intricate polygons to remove the inner boundaries
eurasia_spatial = as(africa_final, 'Spatial')
eurasia_spatial
eurasia_full = aggregate(eurasia_spatial, by='bbox')
slotNames(eurasia_spatial)
eurasia_full = aggregate(africa_final, by='LEVEL3_NAM')
plot(eurasia_full)
st_union(eurasia_full)
st_union(africa_final)
africa_final$LEVEL1_COD
eurasia_full = aggregate(africa_final, by='LEVEL1_COD')
plot(eurasia_full)
plot(africa_final)
eurasia
# unionize the intricate polygons to remove the inner boundaries
eurasia_full = aggregate(eurasia, by='LEVEL1_COD')
africa_final
africa_full = aggregate(africa_final,by='LEVEL1_COD')
madagascar
australia_full
australia2
north_america_complete
north_america_complete$LEVEL1_COD.1
north_america_complete$LEVEL1_COD.2
north_america_complete$LEVEL1_COD.1
north_america_full = aggregate(north_america_complete$LEVEL1_COD.1)
north_america_full = aggregate(north_america_complete, by='LEVEL1_COD')
north_america_full = aggregate(north_america_complete, by='LEVEL1_COD.1')
south_america_full = st_union(south_america_final, by='LEVEL1_COD')
carribean
north_america_full = aggregate(north_america_complete, by='LEVEL1_COD.1')
south_america_full = aggregate(south_america_final, by='LEVEL1_COD')
caribbean_full = carribean
plot(world,lwd=.2)
plot(eurasia_full,add=T,col='purple',lwd=.2)
plot(africa_full,add=T,col='brown',lwd=.2)
plot(world,lwd=.2)
plot(eurasia_full,add=T,col='purple',lwd=.2)
plot(africa_full,add=T,col='brown',lwd=.2)
plot(madagascar_full,add=T,col='orange',lwd=.2)
plot(australia_full,add=T,col='blue',lwd=.2)
plot(north_america_full,add=T,col='lightblue',lwd=.2)
plot(south_america_full,add=T,col='darkgreen',lwd=.2)
plot(caribbean_full,add=T,col='darkmagenta',lwd=.2)
eurasia_full = eurasia
africa_full = aggregate(africa_final,by='LEVEL1_COD')
madagascar_full = madagascar
australia_full = australia2
north_america_full = aggregate(north_america_complete, by='LEVEL1_COD.1')
south_america_full = aggregate(south_america_final, by='LEVEL1_COD')
caribbean_full = carribean
library(raster)
library(maptools)
library(maps)
setwd('/Users/tobias/GitHub/mammal_extinction/data/raw/spatial_data/ISLAND_RASTERS')
# ________________world map_______________
#world = readShapePoly('/Users/tobias/GitHub/mammal_extinction_old/data/raw/spatial_data/SHORE/Shore_BEHR.shp')[1:10,]
#plot(world)
# _____________________________________________
# _________________functions___________________
# define function that reads a bunch of raster files based on a list provided as csv file
get_spatial_data_from_csv <- function(csv_path) {
content = read.csv(file=csv_path,header=TRUE,sep="\t")
indeces = content$ISLANDS
spatial_unit = raster(paste0("RAST_", indeces[1], ".tif"))
for (index in indeces[2:length(indeces)]){
island_raster = raster(paste0("RAST_", index, ".tif"))
spatial_unit = island_raster + spatial_unit
}
return(spatial_unit)
}
# define function that returns '1' if a species is present in a given list of cells
pres_abs_vector <- function(cells_species,cells_area,pa_vector) {
if (length(cells_species[cells_species%in%cells_area])>0){
pa_vector = c(pa_vector,1)
}
else{
pa_vector = c(pa_vector,0)
}
return(pa_vector)
}
# same as function above but gives absolute values
cell_count_vector <- function(cells_species,cells_area,cc_vector) {
count = length(cells_species[cells_species%in%cells_area])
cc_vector = c(cc_vector,count)
return(cc_vector)
}
# same as function above but with option to exclude ambiguous cells
cell_count_vector_ambiguous <- function(cells_species,cells_area,ambiguous_cells,cc_vector) {
cells_match = cells_species[cells_species%in%cells_area]
# if all matching cells are ambiguous, don't return any (we apply this function only to the big landmasses, not to small islands)
if (all(cells_match%in%ambiguous_cells)){
cells_match = c()
}
count = length(cells_match)
cc_vector = c(cc_vector,count)
return(cc_vector)
}
# _____________________________________________
# ________________define regions_______________
island_rasters = list.files()
# *****Eurasia*****
eurasia1=raster(paste0("RAST_", 1, ".tif"))
eurasia2=raster(paste0("RAST_", 2, ".tif"))
eurasia3=get_spatial_data_from_csv("../island_shape_indeces/asia_islands.csv")
eurasia4=get_spatial_data_from_csv("../island_shape_indeces/europe_islands.csv")
eurasia = eurasia1 + eurasia2 + eurasia3 + eurasia4
eurasia[eurasia>1]=1
cells_eurasia=which(eurasia[1:length(eurasia)]==1)
# *****Africa*****
africa=raster(paste0("RAST_", 3, ".tif"))
cells_africa=which(africa[1:length(africa)]==1)
# *****Americas*****
north_america_main=raster(paste0("RAST_", 4, ".tif"))
south_america_main=raster(paste0("RAST_", 5, ".tif"))
north_america_islands = get_spatial_data_from_csv("../island_shape_indeces/north_america_islands.csv")
south_america_islands = get_spatial_data_from_csv("../island_shape_indeces/south_america_islands.csv")
north_america = north_america_main+north_america_islands
south_america = south_america_main+south_america_islands
north_america[north_america>1]=1
south_america[south_america>1]=1
cells_north_america=which(north_america[1:length(north_america)]==1)
cells_south_america=which(south_america[1:length(south_america)]==1)
#americas = north_america_main+south_america_main+north_america_islands+south_america_islands
#americas[americas>1]=1
#cells_americas=which(americas[1:length(americas)]==1)
# *****Australia*****
australia_main = raster(paste0("RAST_", 8, ".tif"))
australia_islands = get_spatial_data_from_csv("../island_shape_indeces/australia_islands.csv")
australia = australia_main+australia_islands
australia[australia>1]=1
cells_australia=which(australia[1:length(australia)]==1)
# *****Madagascar*****
madagascar=raster(paste0("RAST_", 12, ".tif"))
madagascar[madagascar>1]=1
cells_madagascar=which(madagascar[1:length(madagascar)]==1)
# *****Carribean*****
pdf(file = '../Carribean_definition.pdf')
map("world")
rect(-84.960853, 11.975659, -59.407503, 27.272153,col='red',density = c(0),lwd=1)
dev.off()
# provide csv file with island indeces and calling out user-defined function
carribean = get_spatial_data_from_csv("../island_shape_indeces/carribean_islands.csv")
carribean[carribean>1]=1
# decided that dutch antilles are carribean, so never mind the following: remove the dutch antilles, since their faunal composition is not carribean
#carribean_not1 = raster(paste0("RAST_", 528, ".tif"))
#carribean_not2 = raster(paste0("RAST_", 742, ".tif"))
#carribean_not3 = raster(paste0("RAST_", 951, ".tif"))
#true_carribean = carribean-carribean_not1-carribean_not2-carribean_not3
#true_carribean[true_carribean<0]=0
cells_carribean=which(carribean[1:length(carribean)]==1)
# *****Oceanic islands*****
oceanic_main = get_spatial_data_from_csv("../island_shape_indeces/oceanic_islands.csv")
# decided that dutch antilles are carribean, so never mind the following: add the three islands that we removed from the carribean (dutch antilles)
#oceanic_1 = raster(paste0("RAST_", 528, ".tif"))
#oceanic_2 = raster(paste0("RAST_", 742, ".tif"))
#oceanic_3 = raster(paste0("RAST_", 951, ".tif"))
#oceanic = oceanic_main+oceanic_1+oceanic_2+oceanic_3
oceanic_main[oceanic_main>1]=1
cells_oceanic=which(oceanic_main[1:length(oceanic_main)]==1)
# *****Everything*****
all_combined = africa+north_america+south_america+australia+eurasia+madagascar+carribean+oceanic_main
#all_combined[all_combined>1]=1
cells_everything=which(all_combined[1:length(all_combined)]>0)
# get all cells that are present in several defined regions (overlap)
cells_ambiguous=which(all_combined[1:length(all_combined)]>1)
plot(all_combined)
modified_all_combined = all_combined
modified_all_combined[modified_all_combined>1]=4
png(file = '/Users/tobias/GitHub/mammal_extinction/plots/suppl_fig_s8/areas_with_ambiguous_cells.png',height = 2000,width = 4000)
plot(modified_all_combined,axes=F,box=FALSE,legend=FALSE)
dev.off()
all_combined_edited = all_combined
all_combined_edited[all_combined_edited>1]=1
png(file = '/Users/tobias/GitHub/mammal_extinction/plots/suppl_fig_s8/oceanic_islands.png',height = 2000,width = 4000)
plot(all_combined_edited+oceanic_main*3,axes=F,box=FALSE,legend=FALSE)
dev.off()
plot(madagascar)
plot(madagascar)
plot(world,add=T)
north_america
eurasia
plot(world,lwd=.2)
plot(eurasia_full,add=T,col='purple',lwd=.2)
plot(africa_full,add=T,col='brown',lwd=.2)
plot(madagascar_full,add=T,col='orange',lwd=.2)
plot(australia_full,add=T,col='blue',lwd=.2)
plot(north_america_full,add=T,col='lightblue',lwd=.2)
plot(south_america_full,add=T,col='darkgreen',lwd=.2)
plot(caribbean_full,add=T,col='darkmagenta',lwd=.2)
colors = ["#b65738",
"#646cd1",
"#ad9e3e",
"#9751a2",
"#56ae6a",
"#bc496f",
"#6689d0"]
colors = c("#b65738",
"#646cd1",
"#ad9e3e",
"#9751a2",
"#56ae6a",
"#bc496f",
"#6689d0")
plot(eurasia_full,add=T,col=colors[1],lwd=.2)
plot(world,lwd=.2)
plot(eurasia_full,add=T,col=colors[1],lwd=.2)
plot(africa_full,add=T,col=colors[2],lwd=.2)
plot(madagascar_full,add=T,col=colors[3],lwd=.2)
plot(australia_full,add=T,col=colors[4],lwd=.2)
plot(north_america_full,add=T,col=colors[5],lwd=.2)
plot(south_america_full,add=T,col=colors[6],lwd=.2)
plot(caribbean_full,add=T,col=colors[7],lwd=.05)
plot(eurasia_full,add=T,col=colors[1],lwd=.2)
plot(africa_full,add=T,col=colors[7],lwd=.2)
plot(madagascar_full,add=T,col=colors[3],lwd=.2)
plot(australia_full,add=T,col=colors[4],lwd=.2)
plot(north_america_full,add=T,col=colors[5],lwd=.2)
plot(south_america_full,add=T,col=colors[6],lwd=.2)
plot(caribbean_full,add=T,col=colors[2],lwd=.05)
pdf('../plots/suppl_fig_s8/endemism_regions.pdf')
plot(world,lwd=.2)
plot(eurasia_full,add=T,col=colors[1],lwd=.2)
plot(africa_full,add=T,col=colors[7],lwd=.2)
plot(madagascar_full,add=T,col=colors[3],lwd=.2)
plot(australia_full,add=T,col=colors[4],lwd=.2)
plot(north_america_full,add=T,col=colors[5],lwd=.2)
plot(south_america_full,add=T,col=colors[6],lwd=.2)
plot(caribbean_full,add=T,col=colors[2],lwd=.05)
dev.off()
setwd('/Users/tobias/GitHub/mammal_extinction/data/')
pdf('../plots/suppl_fig_s8/endemism_regions.pdf')
plot(world,lwd=.2)
plot(eurasia_full,add=T,col=colors[1],lwd=.2)
plot(africa_full,add=T,col=colors[7],lwd=.2)
plot(madagascar_full,add=T,col=colors[3],lwd=.2)
plot(australia_full,add=T,col=colors[4],lwd=.2)
plot(north_america_full,add=T,col=colors[5],lwd=.2)
plot(south_america_full,add=T,col=colors[6],lwd=.2)
plot(caribbean_full,add=T,col=colors[2],lwd=.05)
dev.off()
