diff --git a/plot_SpeciesComposition.R b/plot_SpeciesComposition.R index 9eb0043..a298c93 100644 --- a/plot_SpeciesComposition.R +++ b/plot_SpeciesComposition.R @@ -113,105 +113,6 @@ chordDiagram(spSimilarity_1, grid.col =col,symmetric = TRUE, dev.off() -# Plot with species with traits ------------------------------------------- -trait_BIEN<-read.csv("./data/processed/BIEN_trait_GrowthForm.csv") -trait_BIEN$scrubbed_species_binomial<-gsub(" ","_",trait_BIEN$scrubbed_species_binomial) - -spPresence_sub<-spPresence[spPresence$Species%in%trait_BIEN$scrubbed_species_binomial,] -spPresence_sub<-na.omit(spPresence_sub) - - -# Species list -biome_richness_sub<-foreach(i=1:length(biome_poly)) %do% { - - cells_tmp<-unlist(cellFromPolygon(r_Total_Rich,biome_poly[[i]])) - sp_list_tmp<-unique(spPresence_sub$Species[spPresence_sub$cells%in%cells_tmp]) - -} -names(biome_richness_sub)<-names(biome_poly) - - -## Create similarity matrix -## Create a loop to calculate the similarity (number of species shared among biomes) -spSimilarity_sub<-foreach(i=1:length(biome_richness_sub), .combine='cbind') %:% - foreach(j=1:length(biome_richness_sub), .combine='c') %do% { - length(intersect(biome_richness_sub[[i]],biome_richness_sub[[j]])) - } - -colnames(spSimilarity_sub)<-names(biome_richness_sub) -rownames(spSimilarity_sub)<-names(biome_richness_sub) - - -col=c(wes_palette("Darjeeling",6,type="continuous"), - wes_palette("Cavalcanti",6,type="continuous")) - -spSimilarity_sub1<-spSimilarity_sub -diag(spSimilarity_sub1)<-0 - -colnames(spSimilarity_sub1)<-c("moist","tropical.mixed", - "savanna","grasslands", - "dry","xeric","MED", - "TEMP","CONI","PRA","TA","TU") - -rownames(spSimilarity_sub1)<-colnames(spSimilarity_sub1) - - -pdf("./figs/OnlyTrait_similarity_biomes.pdf") -chordDiagram(spSimilarity_sub1, grid.col =col,symmetric = TRUE,link.sort = TRUE, - column.col = col) -dev.off() - - - -# Plot species with growth form ------------------------------------------- -Growth_form<-read.table("data/base/GrowthForm_Final.txt", header = TRUE) -Growth_form$SPECIES_STD<-gsub(" ","_",Growth_form$SPECIES_STD) - -spPresence_sub<-spPresence[spPresence$Species%in%Growth_form$SPECIES_STD,] -spPresence_sub<-na.omit(spPresence_sub) - - -# Species list -biome_richness_sub<-foreach(i=1:length(biome_poly)) %do% { - - cells_tmp<-unlist(cellFromPolygon(r_Total_Rich,biome_poly[[i]])) - sp_list_tmp<-unique(spPresence_sub$Species[spPresence_sub$cells%in%cells_tmp]) - -} -names(biome_richness_sub)<-names(biome_poly) - - -## Create similarity matrix -## Create a loop to calculate the similarity (number of species shared among biomes) -spSimilarity_sub<-foreach(i=1:length(biome_richness_sub), .combine='cbind') %:% - foreach(j=1:length(biome_richness_sub), .combine='c') %do% { - length(intersect(biome_richness_sub[[i]],biome_richness_sub[[j]])) - } - -colnames(spSimilarity_sub)<-names(biome_richness_sub) -rownames(spSimilarity_sub)<-names(biome_richness_sub) - - -col=c(wes_palette("Darjeeling",6,type="continuous"), - wes_palette("Cavalcanti",6,type="continuous")) - -spSimilarity_sub1<-spSimilarity_sub -diag(spSimilarity_sub1)<-0 - -colnames(spSimilarity_sub1)<-c("moist","tropical.mixed", - "savanna","grasslands", - "dry","xeric","MED", - "TEMP","CONI","PRA","TA","TU") - -rownames(spSimilarity_sub1)<-colnames(spSimilarity_sub1) - - -pdf("./figs/OnlyGrowth_similarity_biomes.pdf") -chordDiagram(spSimilarity_sub1, grid.col =col,symmetric = TRUE,link.sort = TRUE, - column.col = col) -dev.off() - -