Commit 93926ca2 authored by Georges Kunstler's avatar Georges Kunstler
Browse files

added evergreen and angio plus global standardization

parent f12d15b5
......@@ -27,7 +27,7 @@ $(D2)/TRY/data.TRY.std.rds:
BCI: $(D3)/BCI/Done.txt
$(D3)/BCI/Done.txt: R/process.data/process.fun.R $(D2)/BCI/traits.csv
Rscript -e "source('$<'); process_bigplot_dataset('BCI', Rlim=15); process_bigplot_dataset('BCI', Rlim=15,std.traits=FALSE);"
Rscript -e "source('$<'); process_bigplot_dataset('BCI', Rlim=15,std.traits='local'); process_bigplot_dataset('BCI', Rlim=15,std.traits='no'); process_bigplot_dataset('BCI', Rlim=15,std.traits='global');"
$(D2)/BCI/traits.csv: R/find.trait/BCI.R R/find.trait/trait.fun.R $(D2)/BCI/tree.csv $(D2)/TRY/data.TRY.std.rds
Rscript $<
......@@ -40,7 +40,7 @@ $(D2)/BCI/tree.csv: R/format.data/BCI.R $(shell find $(D1)/BCI -type f)
Japan: $(D3)/Japan/Done.txt
$(D3)/Japan/Done.txt: R/process.data/process.fun.R $(D2)/Japan/traits.csv
Rscript -e "source('$<'); process_bigplot_dataset('Japan', Rlim=15); process_bigplot_dataset('Japan', Rlim=15,std.traits=FALSE);"
Rscript -e "source('$<'); process_bigplot_dataset('Japan', Rlim=15,std.traits='local'); process_bigplot_dataset('Japan', Rlim=15,std.traits='no'); process_bigplot_dataset('Japan', Rlim=15,std.traits='global');"
$(D2)/Japan/traits.csv: R/find.trait/Japan.R R/find.trait/trait.fun.R $(D2)/Japan/tree.csv $(D2)/TRY/data.TRY.std.rds
Rscript $<
......@@ -52,7 +52,7 @@ $(D2)/Japan/tree.csv: R/format.data/Japan.R $(shell find $(D1)/Japan -type f)
Luquillo: $(D3)/Luquillo/Done.txt
$(D3)/Luquillo/Done.txt: R/process.data/process.fun.R $(D2)/Luquillo/traits.csv
Rscript -e "source('$<'); process_bigplot_dataset('Luquillo', Rlim=15); process_bigplot_dataset('Luquillo', Rlim=15,std.traits=FALSE);"
Rscript -e "source('$<'); process_bigplot_dataset('Luquillo', Rlim=15,std.traits='local'); process_bigplot_dataset('Luquillo', Rlim=15,std.traits='no');process_bigplot_dataset('Luquillo', Rlim=15,std.traits='global');"
$(D2)/Luquillo/traits.csv: R/find.trait/Luquillo.R R/find.trait/trait.fun.R $(D2)/Luquillo/tree.csv $(D2)/TRY/data.TRY.std.rds
Rscript $<
......@@ -65,7 +65,7 @@ $(D2)/Luquillo/tree.csv: R/format.data/Luquillo.R $(shell find $(D1)/Luquillo -t
Mbaiki: $(D3)/Mbaiki/Done.txt
$(D3)/Mbaiki/Done.txt: R/process.data/process.fun.R $(D2)/Mbaiki/traits.csv
Rscript -e "source('$<'); process_bigplot_dataset('Mbaiki', Rlim=15); process_bigplot_dataset('Mbaiki', Rlim=15,std.traits=FALSE);"
Rscript -e "source('$<'); process_bigplot_dataset('Mbaiki', Rlim=15,std.traits='local'); process_bigplot_dataset('Mbaiki', Rlim=15,std.traits='no'); process_bigplot_dataset('Mbaiki', Rlim=15,std.traits='global');"
$(D2)/Mbaiki/traits.csv: R/find.trait/Mbaiki.R R/find.trait/trait.fun.R $(D2)/Mbaiki/tree.csv $(D2)/TRY/data.TRY.std.rds
Rscript $<
......@@ -78,7 +78,7 @@ $(D2)/Mbaiki/tree.csv: R/format.data/Mbaiki.R $(shell find $(D1)/Mbaiki -type f)
Canada: $(D3)/Canada/Done.txt
$(D3)/Canada/Done.txt: R/process.data/process.fun.R $(D2)/Canada/traits.csv
Rscript -e "source('$<'); process_inventory_dataset('Canada'); process_inventory_dataset('Canada',std.traits=FALSE);"
Rscript -e "source('$<'); process_inventory_dataset('Canada',std.traits='local'); process_inventory_dataset('Canada',std.traits='no');process_inventory_dataset('Canada',std.traits='global');"
$(D2)/Canada/traits.csv: R/find.trait/Canada.R R/find.trait/trait.fun.R $(D2)/Canada/tree.csv $(D2)/TRY/data.TRY.std.rds
Rscript $<
......@@ -90,7 +90,7 @@ $(D2)/Canada/tree.csv: R/format.data/Canada.R $(shell find $(D1)/Canada -type f)
France: $(D3)/France/Done.txt
$(D3)/France/Done.txt: R/process.data/process.fun.R $(D2)/France/traits.csv
Rscript -e "source('$<'); process_inventory_dataset('France'); process_inventory_dataset('France',std.traits=FALSE);"
Rscript -e "source('$<'); process_inventory_dataset('France',std.traits='local'); process_inventory_dataset('France',std.traits='no');process_inventory_dataset('France',std.traits='global');"
$(D2)/France/traits.csv: R/find.trait/France.R R/find.trait/trait.fun.R $(D2)/France/tree.csv $(D2)/TRY/data.TRY.std.rds
Rscript $<
......@@ -103,7 +103,7 @@ $(D2)/France/tree.csv: R/format.data/France.R $(shell find $(D1)/France -type f)
Fushan: $(D3)/Fushan/Done.txt
$(D3)/Fushan/Done.txt: R/process.data/process.fun.R $(D2)/Fushan/traits.csv
Rscript -e "source('$<'); process_bigplot_dataset('Fushan', Rlim=15); process_bigplot_dataset('Fushan', Rlim=15,std.traits=FALSE);"
Rscript -e "source('$<'); process_bigplot_dataset('Fushan', Rlim=15,std.traits='local'); process_bigplot_dataset('Fushan', Rlim=15,std.traits='no');process_bigplot_dataset('Fushan', Rlim=15,std.traits='global');"
$(D2)/Fushan/traits.csv: R/find.trait/Fushan.R R/find.trait/trait.fun.R $(D2)/Fushan/tree.csv $(D2)/TRY/data.TRY.std.rds
......@@ -117,7 +117,7 @@ $(D2)/Fushan/tree.csv: R/format.data/Fushan.R $(shell find $(D1)/Fushan -type f)
NSW: $(D3)/NSW/Done.txt
$(D3)/NSW/Done.txt: R/process.data/process.fun.R $(D2)/NSW/traits.csv
Rscript -e "source('$<'); process_inventory_dataset('NSW'); process_inventory_dataset('NSW',std.traits=FALSE);"
Rscript -e "source('$<'); process_inventory_dataset('NSW',std.traits='local'); process_inventory_dataset('NSW',std.traits='no');process_inventory_dataset('NSW',std.traits='global');"
$(D2)/NSW/traits.csv: R/find.trait/NSW.R R/find.trait/trait.fun.R $(D2)/NSW/tree.csv $(D2)/TRY/data.TRY.std.rds
Rscript $<
......@@ -130,7 +130,7 @@ $(D2)/NSW/tree.csv: R/format.data/NSW.R $(shell find $(D1)/NSW -type f)
NVS: $(D3)/NVS/Done.txt
$(D3)/NVS/Done.txt: R/process.data/process.fun.R $(D2)/NVS/traits.csv
Rscript -e "source('$<'); process_inventory_dataset('NVS'); process_inventory_dataset('NVS',std.traits=FALSE);"
Rscript -e "source('$<'); process_inventory_dataset('NVS',std.traits='local'); process_inventory_dataset('NVS',std.traits='no'); process_inventory_dataset('NVS',std.traits='global');"
$(D2)/NVS/traits.csv: R/find.trait/NVS.R R/find.trait/trait.fun.R $(D2)/NVS/tree.csv $(D2)/TRY/data.TRY.std.rds
Rscript $<
......@@ -143,7 +143,7 @@ $(D2)/NVS/tree.csv: R/format.data/NVS.R $(shell find $(D1)/NVS -type f)
Paracou: $(D3)/Paracou/Done.txt
$(D3)/Paracou/Done.txt: R/process.data/process.fun.R $(D2)/Paracou/traits.csv
Rscript -e "source('$<'); process_bigplot_dataset('Paracou', Rlim=15); process_bigplot_dataset('Paracou', Rlim=15,std.traits=FALSE);"
Rscript -e "source('$<'); process_bigplot_dataset('Paracou', Rlim=15,std.traits='local'); process_bigplot_dataset('Paracou', Rlim=15,std.traits='no'); process_bigplot_dataset('Paracou', Rlim=15,std.traits='global');"
$(D2)/Paracou/traits.csv: R/find.trait/Paracou.R R/find.trait/trait.fun.R $(D2)/Paracou/tree.csv $(D2)/TRY/data.TRY.std.rds
Rscript $<
......@@ -156,7 +156,7 @@ $(D2)/Paracou/tree.csv: R/format.data/Paracou.R $(shell find $(D1)/Paracou -type
Spain: $(D3)/Spain/Done.txt
$(D3)/Spain/Done.txt: R/process.data/process.fun.R $(D2)/Spain/traits.csv
Rscript -e "source('$<'); process_inventory_dataset('Spain'); process_inventory_dataset('Spain',std.traits=FALSE);"
Rscript -e "source('$<'); process_inventory_dataset('Spain',std.traits='local'); process_inventory_dataset('Spain',std.traits='no'); process_inventory_dataset('Spain',std.traits='global');"
$(D2)/Spain/traits.csv: R/find.trait/Spain.R R/find.trait/trait.fun.R $(D2)/Spain/tree.csv $(D2)/TRY/data.TRY.std.rds
Rscript $<
......@@ -169,7 +169,7 @@ $(D2)/Spain/tree.csv: R/format.data/Spain.R $(shell find $(D1)/Spain -type f)
Sweden: $(D3)/Sweden/Done.txt
$(D3)/Sweden/Done.txt: R/process.data/process.fun.R $(D2)/Sweden/traits.csv
Rscript -e "source('$<'); process_inventory_dataset('Sweden'); process_inventory_dataset('Sweden',std.traits=FALSE);"
Rscript -e "source('$<'); process_inventory_dataset('Sweden',std.traits='local'); process_inventory_dataset('Sweden',std.traits='no'); process_inventory_dataset('Sweden',std.traits='global');"
$(D2)/Sweden/traits.csv: R/find.trait/Sweden.R R/find.trait/trait.fun.R $(D2)/Sweden/tree.csv $(D2)/TRY/data.TRY.std.rds
Rscript $<
......@@ -182,7 +182,7 @@ $(D2)/Sweden/tree.csv: R/format.data/Sweden.R $(shell find $(D1)/Sweden -type f)
Swiss: $(D3)/Swiss/Done.txt
$(D3)/Swiss/Done.txt: R/process.data/process.fun.R $(D2)/Swiss/traits.csv
Rscript -e "source('$<'); process_inventory_dataset('Swiss'); process_inventory_dataset('Swiss',std.traits=FALSE);"
Rscript -e "source('$<'); process_inventory_dataset('Swiss',std.traits='local'); process_inventory_dataset('Swiss',std.traits='no'); process_inventory_dataset('Swiss',std.traits='global');"
$(D2)/Swiss/traits.csv: R/find.trait/Swiss.R R/find.trait/trait.fun.R $(D2)/Swiss/tree.csv $(D2)/TRY/data.TRY.std.rds
Rscript $<
......@@ -195,7 +195,7 @@ $(D2)/Swiss/tree.csv: R/format.data/Swiss.R $(shell find $(D1)/Swiss -type f)
US: $(D3)/US/Done.txt
$(D3)/US/Done.txt: R/process.data/process.fun.R $(D2)/US/traits.csv
Rscript -e "source('$<'); process_inventory_dataset('US'); process_inventory_dataset('US',std.traits=FALSE);"
Rscript -e "source('$<'); process_inventory_dataset('US',std.traits='local'); process_inventory_dataset('US',std.traits='no');process_inventory_dataset('US',std.traits='global');"
$(D2)/US/traits.csv: R/find.trait/US.R R/find.trait/trait.fun.R $(D2)/US/tree.csv $(D2)/TRY/data.TRY.std.rds
Rscript $<
......
......@@ -13,7 +13,7 @@ for (set in sets){
ecoregions <- get.ecoregions.for.set(set)
for (ecoregion in ecoregions){
for (trait in traits){
for (model in c(model.files.lmer.Tf.1)){
for (model in c(model.files.lmer.Tf.1,model.files.lmer.Tf.2)){
source(model, local = TRUE)
model.obj <- load.model()
......
......@@ -396,9 +396,9 @@ fun.plot.panel.lmer.parameters.c <- function(models,traits,DF.results,var.x,list
mtext(var.x, side=1, line =4)
if(j==1)
mtext(paste('param',names(models)[i]), side=2, line =4,cex=1)
if(i==nrows & j==ncols)
legend('topright',legend=levels(DF.results$set),pch=16,
col=col.vec,bty='n',ncol=2)
## if(i==nrows & j==ncols)
## legend('topright',legend=levels(DF.results$set),pch=16,
## col=col.vec,bty='n',ncol=2)
}
}
......
......@@ -49,6 +49,8 @@ DF.results <- cbind(DF.results,DF.R2m.diff,DF.R2c.diff,DF.AIC.diff,DF.delta.AIC,
DF.best.and.all.AIC <- do.call('rbind',lapply(unique(DF.results$id2),FUN=fun.AIC,DF.results))
DF.best.and.all.AICc <- do.call('rbind',lapply(unique(DF.results$id2),FUN=fun.AICc,DF.results))
table(DF.best.and.all.AIC[DF.best.and.all.AIC$filling=='species',]$best.model)
table(DF.best.and.all.AIC[DF.best.and.all.AIC$filling=='species',]$best.model,
DF.best.and.all.AIC[DF.best.and.all.AIC$filling=='species',]$trait,
DF.best.and.all.AIC[DF.best.and.all.AIC$filling=='species',]$set)
......@@ -219,7 +221,8 @@ pdf('figs/parameters.MAP.ER.all.pdf',width=9,height=7)
fun.plot.panel.lmer.parameters.c(models=models,
traits = c('Wood.density','SLA','Leaf.N','Max.height'),
DF.results,var.x='MAP',
list.params=list.params,small.bar=0.02,ylim=c(-.15,.25),threshold.delta.AIC=10000)
list.params=list.params,small.bar=0.02,
threshold.delta.AIC=10000)
dev.off()
models <- c('lmer.LOGLIN.ER.Tf','lmer.LOGLIN.ER.Tf')
......
##### SCRIPT TO TEST BEFORE TO SEND ON CLUSTER
source("R/analysis/lmer.run.nolog.R")
run.models.for.set.all.traits('France',model.files.lmer.Tf.1, run.lmer,type.filling='species',std=TRUE)
run.models.for.set.all.traits('Spain',model.files.lmer.Tf.1, run.lmer,type.filling='species',std=TRUE)
run.models.for.set.all.traits('Sweden',model.files.lmer.Tf.1, run.lmer,type.filling='species',std=TRUE)
run.models.for.set.all.traits('Swiss',model.files.lmer.Tf.1, run.lmer,type.filling='species',std=TRUE)
run.models.for.set.all.traits('BCI',model.files.lmer.Tf.1, run.lmer,type.filling='species',std=TRUE)
run.models.for.set.all.traits('Fushan',model.files.lmer.Tf.1, run.lmer,type.filling='species',std=TRUE)
run.models.for.set.all.traits('Luquillo',model.files.lmer.Tf.1, run.lmer,type.filling='species',std=TRUE)
run.models.for.set.all.traits('NVS',model.files.lmer.Tf.1, run.lmer,type.filling='species',std=TRUE)
run.models.for.set.all.traits('Japan',model.files.lmer.Tf.1, run.lmer,type.filling='species',std=TRUE)
run.models.for.set.all.traits('Canada',model.files.lmer.Tf.1, run.lmer,type.filling='species',std=TRUE)
run.models.for.set.all.traits('Paracou',model.files.lmer.Tf.1, run.lmer,type.filling='species',std=TRUE)
run.models.for.set.all.traits('Mbaiki',model.files.lmer.Tf.1, run.lmer,type.filling='species',std=TRUE)
run.models.for.set.all.traits('US',model.files.lmer.Tf.1, run.lmer,type.filling='species',std=TRUE)
sets <- c('France','Spain','Sweden','Swiss','BCI','Fushan','Luquillo','NVS','Japan','Canada','Paracou','Mbaiki','US')
library(doParallel)
......
......@@ -64,6 +64,26 @@ data.traits <- fun.extract.format.sp.traits.NOT.TRY(sp=species.clean$Latin_name,
## change sp
data.traits$sp <- species.clean$sp
#### GET THE ANGIO/CONIF AND EVERGREEN/DECIDUOUS
# read try categrocial data
try.cat <- read.csv("data/raw/TRY/TRY_Categorical_Traits_Lookup_Table_2012_03_17_TestRelease.csv",
stringsAsFactors=FALSE,na.strings = "")
Pheno.Zanne <- read.csv("data/raw/ZanneNature/GlobalLeafPhenologyDatabase.csv",
stringsAsFactors=FALSE)
# extract
data.cat.extract <- do.call("rbind",lapply(data.traits$sp ,fun.get.cat.var.from.try,
data.traits,try.cat,Pheno.Zanne))
# change category
data.cat.extract <- fun.change.factor.pheno.try(data.cat.extract)
data.cat.extract <- fun.change.factor.angio.try(data.cat.extract)
data.cat.extract <- fun.fill.pheno.try.with.zanne(data.cat.extract)
data.traits <- merge(data.traits,data.cat.extract[,c("sp","Phylo.group","Pheno.T")],by="sp")
###
write.csv(data.traits,file="output/formatted/BCI/traits.csv",row.names = FALSE)
......
......@@ -36,6 +36,28 @@ data.traits[is.na(data.traits[["Max.height.mean"]]),
c("Max.height.mean","Max.height.sd","Max.height.genus")] <- height.genus.DF[
is.na(data.traits[["Max.height.mean"]]),]
#### GET THE ANGIO/CONIF AND EVERGREEN/DECIDUOUS
# read try categrocial data
try.cat <- read.csv("data/raw/TRY/TRY_Categorical_Traits_Lookup_Table_2012_03_17_TestRelease.csv",
stringsAsFactors=FALSE,na.strings = "")
Pheno.Zanne <- read.csv("data/raw/ZanneNature/GlobalLeafPhenologyDatabase.csv",
stringsAsFactors=FALSE)
# extract
data.cat.extract <- do.call("rbind",lapply(data.traits$sp ,fun.get.cat.var.from.try,
data.traits,try.cat,Pheno.Zanne))
# change category
data.cat.extract <- fun.change.factor.pheno.try(data.cat.extract)
data.cat.extract <- fun.change.factor.angio.try(data.cat.extract)
data.cat.extract <- fun.fill.pheno.try.with.zanne(data.cat.extract)
## fix pheno for species with issue
data.cat.extract[data.cat.extract$Latin_name %in% c('Betula spp.','Crataegus spp.','Fraxinus spp.'
,'Malus spp.','Amelanchier spp.','Alnus spp.',
'Tilia spp.','Ulmus spp.'),'Pheno.T'] <- 'D'
data.traits <- merge(data.traits,data.cat.extract[,c("sp","Phylo.group","Pheno.T")],by="sp")
###
write.csv(data.traits,file="output/formatted/Canada/traits.csv",row.names = FALSE)
......@@ -37,30 +37,34 @@ data.traits[is.na(data.traits[["Max.height.mean"]]),
height.genus.DF[is.na(data.traits[["Max.height.mean"]]),]
#### TODO GET THE ANGIO/CONIF AND EVERGREEN/DECIDUOUS
#### GET THE ANGIO/CONIF AND EVERGREEN/DECIDUOUS
# read try categrocial data
try.cat <- read.csv("data/raw/TRY/TRY_Categorical_Traits_Lookup_Table_2012_03_17_TestRelease.csv",
stringsAsFactors=FALSE,na.strings = "")
Pheno.Zanne <- read.csv("data/raw/ZanneNature/GlobalLeafPhenologyDatabase.csv",
stringsAsFactors=FALSE)
# extract
data.cat.extract <- do.call("rbind",lapply(data.traits$sp ,fun.get.cat.var.from.try,
data.traits,try.cat,Pheno.Zanne))
# change category
data.cat.extract <- fun.change.factor.pheno.try(data.cat.extract)
data.cat.extract <- fun.change.factor.angio.try(data.cat.extract)
data.cat.extract <- fun.fill.pheno.try.with.zanne(data.cat.extract)
## fix pheno for species with issue
data.cat.extract[data.cat.extract$Latin_name %in% c('Populus sp','Tilia europaea',
'Prunus sp','Prunus dulcis',
'Sorbus latifolia','Pyrus spinosa',
'Sorbus semiincisa','Alnus alnobetula',
'Crataegus azarolus','Frangula dodonei',
'Tamarix africana'),'Pheno.T'] <- 'D'
data.cat.extract[data.cat.extract$Pheno.T=='deciduous'
& !is.na(data.cat.extract$Pheno.T),'Pheno.T'] <- 'D'
data.cat.extract[data.cat.extract$Pheno.T=='evergreen'
& !is.na(data.cat.extract$Pheno.T),'Pheno.T'] <- 'EV'
data.cat.extract[data.cat.extract$Pheno.T=='deciduous/evergreen'
& !is.na(data.cat.extract$Pheno.T),'Pheno.T'] <- 'D_EV'
data.cat.extract[data.cat.extract$Latin_name %in% c('Pinus nigra spp. salzmannii')
,'Pheno.T']<- 'EV'
data.traits <- merge(data.traits,data.cat.extract,by="sp")
## check if leaf Phenology agree with Zanne
sum(Pheno.Zanne$Binomial %in% try.cat$AccSpeciesName)
merge.pheno <- merge(Pheno.Zanne,try.cat,by.x="Binomial",by.y="AccSpeciesName",all=FALSE)
table(merge.pheno$LeafPhenology,merge.pheno$Phenology)
data.traits <- merge(data.traits,data.cat.extract[,c("sp","Phylo.group","Pheno.T")],by="sp")
###
write.csv(data.traits,file="output/formatted/France/traits.csv",row.names = FALSE)
......
......@@ -36,7 +36,28 @@ rm(data.trait)
## extract
data.traits <- fun.extract.format.sp.traits.NOT.TRY(sp=species.clean$sp, Latin_name=species.clean$sp, data=data.TRAITS.std,name.match.traits="sp")
## Check heights here; we DO NOT want to take logs of max height!
#### GET THE ANGIO/CONIF AND EVERGREEN/DECIDUOUS
# TODO ASK SPECIES NAME OR EVERGREEN DECIDUOUS BECAUSE NO SPECIES NAME AVAILABLE
#### GET THE ANGIO/CONIF AND EVERGREEN/DECIDUOUS
# read try categrocial data
try.cat <- read.csv("data/raw/TRY/TRY_Categorical_Traits_Lookup_Table_2012_03_17_TestRelease.csv",
stringsAsFactors=FALSE,na.strings = "")
Pheno.Zanne <- read.csv("data/raw/ZanneNature/GlobalLeafPhenologyDatabase.csv",
stringsAsFactors=FALSE)
# extract
data.cat.extract <- do.call("rbind",lapply(data.traits$sp ,fun.get.cat.var.from.try,
data.traits,try.cat,Pheno.Zanne))
# change category
data.cat.extract <- fun.change.factor.pheno.try(data.cat.extract)
data.cat.extract <- fun.change.factor.angio.try(data.cat.extract)
data.cat.extract <- fun.fill.pheno.try.with.zanne(data.cat.extract)
data.traits <- merge(data.traits,data.cat.extract[,c("sp","Phylo.group","Pheno.T")],by="sp")
###
write.csv(data.traits,file="output/formatted/Fushan/traits.csv",row.names = FALSE)
......
......@@ -42,6 +42,24 @@ data.trait$Max.height.sd <- NA
## read traits from TRY
data.traits <- fun.extract.format.sp.traits.NOT.TRY(sp=species.clean$sp, Latin_name=species.clean$Latin_name, data=data.trait, name.match.traits="Latin_name")
#### GET THE ANGIO/CONIF AND EVERGREEN/DECIDUOUS
# read try categrocial data
try.cat <- read.csv("data/raw/TRY/TRY_Categorical_Traits_Lookup_Table_2012_03_17_TestRelease.csv",
stringsAsFactors=FALSE,na.strings = "")
Pheno.Zanne <- read.csv("data/raw/ZanneNature/GlobalLeafPhenologyDatabase.csv",
stringsAsFactors=FALSE)
# extract
data.cat.extract <- do.call("rbind",lapply(data.traits$sp ,fun.get.cat.var.from.try,
data.traits,try.cat,Pheno.Zanne))
# change category
data.cat.extract <- fun.change.factor.pheno.try(data.cat.extract)
data.cat.extract <- fun.change.factor.angio.try(data.cat.extract)
data.cat.extract <- fun.fill.pheno.try.with.zanne(data.cat.extract)
data.traits <- merge(data.traits,data.cat.extract[,c("sp","Phylo.group","Pheno.T")],by="sp")
### TODO ADD GENUS MEAN FOR HEIGHT IF SPECIES IS MISSING
write.csv(data.traits,file="output/formatted/Japan/traits.csv",row.names = FALSE)
......
......@@ -71,6 +71,34 @@ data.traits <- fun.extract.format.sp.traits.NOT.TRY(sp=species.clean$Latin_name,
## change sp
data.traits$sp <- species.clean$sp
#### GET THE ANGIO/CONIF AND EVERGREEN/DECIDUOUS
# read try categrocial data
try.cat <- read.csv("data/raw/TRY/TRY_Categorical_Traits_Lookup_Table_2012_03_17_TestRelease.csv",
stringsAsFactors=FALSE,na.strings = "")
Pheno.Zanne <- read.csv("data/raw/ZanneNature/GlobalLeafPhenologyDatabase.csv",
stringsAsFactors=FALSE)
# extract
data.cat.extract <- do.call("rbind",lapply(data.traits$sp ,fun.get.cat.var.from.try,
data.traits,try.cat,Pheno.Zanne))
# change category
data.cat.extract <- fun.change.factor.pheno.try(data.cat.extract)
data.cat.extract <- fun.change.factor.angio.try(data.cat.extract)
data.cat.extract <- fun.fill.pheno.try.with.zanne(data.cat.extract)
## fix pheno for species with issue
data.cat.extract[data.cat.extract$Latin_name %in% c('Prestoea acuminata',
'Matayba domingensis'),'Pheno.T'] <- 'D'
data.cat.extract[data.cat.extract$Latin_name %in% c('Cecropia schreberiana',
'Talipariti tiliaceum',
'Eugenia domingensis',
'Ficus crassinervia') ,'Pheno.T']<- 'EV'
data.cat.extract[data.cat.extract$Latin_name %in% c('Chione venosa') ,'Pheno.T']<- 'D_EV'
data.traits <- merge(data.traits,data.cat.extract[,c("sp","Phylo.group","Pheno.T")],by="sp")
###
write.csv(data.traits,file="output/formatted/Luquillo/traits.csv",row.names = FALSE)
......
......@@ -157,6 +157,23 @@ data.traits <- fun.extract.format.sp.traits.NOT.TRY(sp=species.clean$Latin_name,
## change sp
data.traits$sp <- species.clean$sp
#### GET THE ANGIO/CONIF AND EVERGREEN/DECIDUOUS
# read try categrocial data
try.cat <- read.csv("data/raw/TRY/TRY_Categorical_Traits_Lookup_Table_2012_03_17_TestRelease.csv",
stringsAsFactors=FALSE,na.strings = "")
Pheno.Zanne <- read.csv("data/raw/ZanneNature/GlobalLeafPhenologyDatabase.csv",
stringsAsFactors=FALSE)
# extract
data.cat.extract <- do.call("rbind",lapply(data.traits$sp ,fun.get.cat.var.from.try,
data.traits,try.cat,Pheno.Zanne))
# change category
data.cat.extract <- fun.change.factor.pheno.try(data.cat.extract)
data.cat.extract <- fun.change.factor.angio.try(data.cat.extract)
data.cat.extract <- fun.fill.pheno.try.with.zanne(data.cat.extract)
data.traits <- merge(data.traits,data.cat.extract[,c("sp","Phylo.group","Pheno.T")],by="sp")
### Export
write.csv(data.traits,file="output/formatted/Mbaiki/traits.csv",row.names = FALSE)
......
......@@ -33,6 +33,25 @@ rm(data.trait)
## extract
data.traits <- fun.extract.format.sp.traits.NOT.TRY(sp=species.clean$sp, Latin_name=species.clean$Latin_name, data=data.TRAITS.std,name.match.traits="sp")
#### GET THE ANGIO/CONIF AND EVERGREEN/DECIDUOUS
# read try categrocial data
try.cat <- read.csv("data/raw/TRY/TRY_Categorical_Traits_Lookup_Table_2012_03_17_TestRelease.csv",
stringsAsFactors=FALSE,na.strings = "")
Pheno.Zanne <- read.csv("data/raw/ZanneNature/GlobalLeafPhenologyDatabase.csv",
stringsAsFactors=FALSE)
# extract
data.cat.extract <- do.call("rbind",lapply(data.traits$sp ,fun.get.cat.var.from.try,
data.traits,try.cat,Pheno.Zanne))
# change category
data.cat.extract <- fun.change.factor.pheno.try(data.cat.extract)
data.cat.extract <- fun.change.factor.angio.try(data.cat.extract)
data.cat.extract <- fun.fill.pheno.try.with.zanne(data.cat.extract)
data.traits <- merge(data.traits,data.cat.extract[,c("sp","Phylo.group","Pheno.T")],by="sp")
### TODO ADD GENUS MEAN FOR HEIGHT IF SPECIES IS MISSING
write.csv(data.traits,file="output/formatted/NSW/traits.csv",row.names = FALSE)
......
......@@ -31,8 +31,48 @@ data.trait$Wood.density.sd <- NA
data.trait$Max.height.mean <- data.trait$height.m; data.trait$height.m <- NULL
data.trait$Max.height.sd <- NA
## read traits from TRY
## read traits from data
data.traits <- fun.extract.format.sp.traits.NOT.TRY(sp=species.clean$sp, Latin_name=species.clean$Latin_name, data=data.trait,name.match.traits="Latin_name")
## TODO GET ANGIO CONIF DECIDUOUS EVERGREEN BUT NEED SPECIES LATIN NAME
NVS.SPECIES.name <- read.csv("data/raw/NVS/CurrentNVSNames.csv",sep=';', stringsAsFactors = FALSE)
species.clean$Latin_name <- NVS.SPECIES.name$Species.Name[match(species.clean$Latin_name_syn,
NVS.SPECIES.name$NVS.Code)]
data.traits$Latin_name <- species.clean$Latin_name
#### GET THE ANGIO/CONIF AND EVERGREEN/DECIDUOUS
## FOR NEW ZEALADN BETTER TO FOLLOW McGlone et al. 2004. Winter leaf loss in the New Zealand woody flora. New Zealand Journal of Botany, 2004, Vol. 42: 1-19. which report 11 species asdeciduous adn 11 species as semi-deciduous
# read try categrocial data
try.cat <- read.csv("data/raw/TRY/TRY_Categorical_Traits_Lookup_Table_2012_03_17_TestRelease.csv",
stringsAsFactors=FALSE,na.strings = "")
Pheno.Zanne <- read.csv("data/raw/ZanneNature/GlobalLeafPhenologyDatabase.csv",
stringsAsFactors=FALSE)
# extract
data.cat.extract <- do.call("rbind",lapply(data.traits$sp ,fun.get.cat.var.from.try,
data.traits,try.cat,Pheno.Zanne))
# change category
data.cat.extract <- fun.change.factor.pheno.try(data.cat.extract)
data.cat.extract <- fun.change.factor.angio.try(data.cat.extract)
data.cat.extract <- fun.fill.pheno.try.with.zanne(data.cat.extract)
## FOR NEW ZEALAND BETTER TO FOLLOW McGlone et al. 2004. Winter leaf loss in the New Zealand woody flora. New Zealand Journal of Botany, 2004, Vol. 42: 1-19. which report 11 species asdeciduous adn 11 species as semi-deciduous
## according to McGlone et al. 2004. Winter leaf loss in the New Zealand woody flora. New Zealand Journal of Botany, 2004, Vol. 42: 1-19. all other species are evergreen
data.cat.extract[,'Pheno.T'] <- 'EV'
data.cat.extract[data.cat.extract$Latin_name %in% c('Discaria toumatou',
'Fuchsia excorticata','Hoheria glabrata','Hoheria lyallii',
'Muehlenbeckia astonii','Olearia fragantissima','Olearia gardneri','Olearia hectori',
'Olearia odorata','Plagianthus divaricatus','Plagianthus regius'),'Pheno.T'] <- 'D'
data.cat.extract[data.cat.extract$Latin_name %in% c('Aristotelia serrata',
'Carmichaelia odorata','Carmichaelia arborea',
'Coprosma virescens','Coriaria arborea var. arborea','Fuchsia perscandens',
'Fuchsia procumbens','Muehlenbeckia australis','Muehlenbeckia complexa',
'Olearia fimbriata','Urtica ferox'),'Pheno.T'] <- 'D_EV'
data.traits <- merge(data.traits,data.cat.extract[,c("sp","Phylo.group","Pheno.T")],by="sp")
### TODO ADD GENUS MEAN FOR HEIGHT IF SPECIES IS MISSING
write.csv(data.traits,file="output/formatted/NVS/traits.csv",row.names = FALSE)
......@@ -314,6 +314,24 @@ species.clean2 <- data.frame(sp=data.tree[!duplicated(data.tree[["sp"]]),"sp"],
data.traits <- fun.extract.format.sp.traits.NOT.TRY(sp=species.clean2$sp, Latin_name=species.clean2$Latin_name, data=data.species,name.match.traits="Latin_name")
#### GET THE ANGIO/CONIF AND EVERGREEN/DECIDUOUS
# read try categrocial data
try.cat <- read.csv("data/raw/TRY/TRY_Categorical_Traits_Lookup_Table_2012_03_17_TestRelease.csv",
stringsAsFactors=FALSE,na.strings = "")
Pheno.Zanne <- read.csv("data/raw/ZanneNature/GlobalLeafPhenologyDatabase.csv",
stringsAsFactors=FALSE)
# extract
data.cat.extract <- do.call("rbind",lapply(data.traits$sp ,fun.get.cat.var.from.try,
data.traits,try.cat,Pheno.Zanne))
# change category
data.cat.extract <- fun.change.factor.pheno.try(data.cat.extract)
data.cat.extract <- fun.change.factor.angio.try(data.cat.extract)
data.cat.extract <- fun.fill.pheno.try.with.zanne(data.cat.extract)
data.traits <- merge(data.traits,data.cat.extract[,c("sp","Phylo.group","Pheno.T")],by="sp")
# write.table(data.genus,file="data.genus.txt",sep="\t",row.names=FALSE)
write.csv(data.traits,file="./output/formatted/Paracou/traits.csv",row.names=FALSE)
......@@ -22,14 +22,48 @@ max.height <- read.csv(file="output/formatted/Spain/max.height.csv", stringsAsFa
max.height$sp <- paste("sp",max.height$sp,sep=".")
## extract traits and height
data.traits <- fun.extract.format.sp.traits.TRY(sp=species.clean[["sp"]],sp.syno.table=species.clean,data=data.TRY.std)
data.traits <- merge(data.traits,subset(max.height,select=c("sp","Max.height.mean","Max.height.sd")),by="sp",all.x=TRUE,all.y=FALSE)
data.traits <- fun.extract.format.sp.traits.TRY(sp=species.clean[["sp"]],
sp.syno.table=species.clean,
data=data.TRY.std)
data.traits <- merge(data.traits,subset(max.height,select=c("sp","Max.height.mean","Max.height.sd")),
by="sp",all.x=TRUE,all.y=FALSE)
data.traits$Max.height.genus <- FALSE
# genus mean for height
height.genus.DF <- do.call("rbind",lapply(data.traits$Latin_name,fun.compute.mean.genus,data.traits,"Max.height.mean"))
height.genus.DF <- do.call("rbind",lapply(data.traits$Latin_name,
fun.compute.mean.genus,data.traits,"Max.height.mean"))
data.traits[is.na(data.traits[["Max.height.mean"]]),
c("Max.height.mean","Max.height.sd","Max.height.genus")] <- height.genus.DF[is.na(data.traits[["Max.height.mean"]]),]
c("Max.height.mean","Max.height.sd","Max.height.genus")] <-
height.genus.DF[is.na(data.traits[["Max.height.mean"]]),]
### TODO ADD GENUS MEAN FOR HEIGHT IF SPECIES IS MISSING
#### GET THE ANGIO/CONIF AND EVERGREEN/DECIDUOUS
# read try categrocial data
try.cat <- read.csv("data/raw/TRY/TRY_Categorical_Traits_Lookup_Table_2012_03_17_TestRelease.csv",
stringsAsFactors=FALSE,na.strings = "")
Pheno.Zanne <- read.csv("data/raw/ZanneNature/GlobalLeafPhenologyDatabase.csv",
stringsAsFactors=FALSE)
# extract
data.cat.extract <- do.call("rbind",lapply(data.traits$sp ,fun.get.cat.var.from.try,
data.traits,try.cat,Pheno.Zanne))
# change category
data.cat.extract <- fun.change.factor.pheno.try(data.cat.extract)
data.cat.extract <- fun.change.factor.angio.try(data.cat.extract)
data.cat.extract <- fun.fill.pheno.try.with.zanne(data.cat.extract)
## fix pheno for species with issue
data.cat.extract[data.cat.extract$Latin_name %in% c('Crataegus spp.','Crataegus laciniata',
'Pyrus spp.','Morus spp.','Salix spp.',
'Betula spp.','Salix elaegnos',
'Tilia spp.','Sorbus spp.',
'Prunus spp.','Larix spp.'),'Pheno.T'] <- 'D'
data.cat.extract[data.cat.extract$Latin_name %in% c('Juniperus turbinata',
'Otros pinos'),'Pheno.T']<- 'EV'
data.traits <- merge(data.traits,data.cat.extract[,c("sp","Phylo.group","Pheno.T")],by="sp")
# write
write.csv(data.traits,file="output/formatted/Spain/traits.csv",row.names = FALSE)
......@@ -80,7 +80,31 @@ data.traits$SLA.genus[data.traits$sp=="sp.51"] <- FALSE
data.traits$Wood.density.genus[data.traits$sp=="sp.51"] <- FALSE
data.traits$Max.height.genus[data.traits$sp=="sp.51"] <- FALSE
### TODO ADD GENUS MEAN FOR HEIGHT IF SPECIES IS MISSING
#### GET THE ANGIO/CONIF AND EVERGREEN/DECIDUOUS
# read try categrocial data
try.cat <- read.csv("data/raw/TRY/TRY_Categorical_Traits_Lookup_Table_2012_03_17_TestRelease.csv",
stringsAsFactors=FALSE,na.strings = "")
Pheno.Zanne <- read.csv("data/raw/ZanneNature/GlobalLeafPhenologyDatabase.csv",
stringsAsFactors=FALSE)
# extract
data.cat.extract <- do.call("rbind",lapply(data.traits$sp ,fun.get.cat.var.from.try,
data.traits,try.cat,Pheno.Zanne))
# change category
data.cat.extract <- fun.change.factor.pheno.try(data.cat.extract)
data.cat.extract <- fun.change.factor.angio.try(data.cat.extract)
data.cat.extract <- fun.fill.pheno.try.with.zanne(data.cat.extract)
## fix pheno for species with issue
data.cat.extract[data.cat.extract$Latin_name %in% c('Betula ssp','Quercus robur_petraea',
'Ulmus ssp'),'Pheno.T'] <- 'D'
data.cat.extract[data.cat.extract$Latin_name %in% c('Abies ssp',
'Picea ssp other than P.abies') ,'Pheno.T']<- 'EV'
data.traits <- merge(data.traits,data.cat.extract[,c("sp","Phylo.group","Pheno.T")],by="sp")
### writing
write.csv(data.traits,file="output/formatted/Sweden/traits.csv",row.names = FALSE)
......