Commit 87e61f43 authored by Georges Kunstler's avatar Georges Kunstler
Browse files

new makefile

parent 2454c63b
......@@ -13,6 +13,7 @@ figs
*.Rdata
*.rds
*.R~
*.Rout
docs/metadata/sites
.Rproj.user
GROWTH.MODEL.*
......
......@@ -4,7 +4,7 @@ D3 := output/processed
D4 := figs/test.format.tree
D5 := figs/test.traits
D6 := figs/test.CWM
sites:= Fushan Paracou BCI Mbaiki Luquillo Japan Spain Sweden Canada France Swiss NSW NVS
sites:= Fushan Paracou BCI Mbaiki Luquillo Japan Spain Sweden Canada France Swiss NSW NVS US
D3Done := $(addsuffix /Done.txt,$(addprefix $(D3)/, $(sites) ))
D2traits := $(addsuffix /traits.csv,$(addprefix $(D2)/, $(sites) ))
D2tree := $(addsuffix /tree.csv,$(addprefix $(D2)/, $(sites) ))
......@@ -14,6 +14,23 @@ all: TRY sites
sites: $(sites)
#-------------------------------------------------------
include mk/process_BCI.mk
include mk/process_Fushan.mk
include mk/process_Paracou.mk
include mk/process_Mbaiki.mk
include mk/process_Luquillo.mk
include mk/process_Japan.mk
include mk/process_Canada.mk
include mk/process_Spain.mk
include mk/process_Sweden.mk
include mk/process_France.mk
include mk/process_Swiss.mk
include mk/process_NSW.mk
include mk/process_NVS.mk
include mk/process_US.mk
include mk/cible.tree.traits.mk
#-------------------------------------------------------
......@@ -25,198 +42,17 @@ $(D2)/TRY/data.TRY.std.rds:
#-------------------------------------------------------
GLOBAL: $(D3)/Done.txt
$(D3)/Done.txt: R/process.data/merge.all.processed.data.R sites R/process.data/process-fun.R $(D2)/traits.std.global.csv $(D5)/Done.txt
$(D3)/Done.txt: R/process.data/merge.all.processed.data.R #sites R/process.data/process-fun.R # $(D5)/Done.txt
Rscript $<
#-------------------------------------------------------
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,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
Rscript $< ; rm -f $(D5)/Done.txt
$(D2)/BCI/tree.csv: R/format.data/BCI.R $(shell find $(D1)/BCI -type f)
Rscript $< ; rm -f $(D4)/Done.txt
#-------------------------------------------------------
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,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
Rscript $< ; rm -f $(D5)/Done.txt
$(D2)/Japan/tree.csv: R/format.data/Japan.R $(shell find $(D1)/Japan -type f)
Rscript $< ; rm -f $(D4)/Done.txt
#-------------------------------------------------------
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,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
Rscript $< ; rm -f $(D5)/Done.txt
$(D2)/Luquillo/tree.csv: R/format.data/Luquillo.R $(shell find $(D1)/Luquillo -type f)
Rscript $< ; rm -f $(D4)/Done.txt
#-------------------------------------------------------
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,std.traits='global');"
$(D2)/Mbaiki/traits.csv: R/find.trait/Mbaiki.R R/find.trait/trait-fun.R $(D2)/Mbaiki/tree.csv
Rscript $< ; rm -f $(D5)/Done.txt
$(D2)/Mbaiki/tree.csv: R/format.data/Mbaiki.R $(shell find $(D1)/Mbaiki -type f)
Rscript $< ; rm -f $(D4)/Done.txt
#-------------------------------------------------------
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',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 $< ; rm -f $(D5)/Done.txt
$(D2)/Canada/tree.csv: R/format.data/Canada.R $(shell find $(D1)/Canada -type f)
Rscript $< ; rm -f $(D4)/Done.txt
#-------------------------------------------------------
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',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 $< ; rm -f $(D5)/Done.txt
$(D2)/France/tree.csv: R/format.data/France.R $(shell find $(D1)/France -type f)
Rscript $< ; rm -f $(D4)/Done.txt
#-------------------------------------------------------
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,std.traits='global');"
$(D2)/Fushan/traits.csv: R/find.trait/Fushan.R R/find.trait/trait-fun.R $(D2)/Fushan/tree.csv
Rscript $< ; rm -f $(D5)/Done.txt
$(D2)/Fushan/tree.csv: R/format.data/Fushan.R $(shell find $(D1)/Fushan -type f)
Rscript $< ; rm -f $(D4)/Done.txt
#-------------------------------------------------------
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',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 $< ; rm -f $(D5)/Done.txt
$(D2)/NSW/tree.csv: R/format.data/NSW.R $(shell find $(D1)/NSW -type f)
Rscript $< ; rm -f $(D4)/Done.txt
#-------------------------------------------------------
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',std.traits='global');"
$(D2)/NVS/traits.csv: R/find.trait/NVS.R R/find.trait/trait-fun.R $(D2)/NVS/tree.csv
Rscript $< ; rm -f $(D5)/Done.txt
$(D2)/NVS/tree.csv: R/format.data/NVS.R $(shell find $(D1)/NVS -type f)
Rscript $< ; rm -f $(D4)/Done.txt
#-------------------------------------------------------
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,std.traits='global');"
$(D2)/Paracou/traits.csv: R/find.trait/Paracou.R R/find.trait/trait-fun.R $(D2)/Paracou/tree.csv
Rscript $< ; rm -f $(D5)/Done.txt
$(D2)/Paracou/tree.csv: R/format.data/Paracou.R $(shell find $(D1)/Paracou -type f)
Rscript $< ; rm -f $(D4)/Done.txt
#-------------------------------------------------------
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',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 $< ; rm -f $(D5)/Done.txt
$(D2)/Spain/tree.csv: R/format.data/Spain.R $(shell find $(D1)/Spain -type f)
Rscript $< ; rm -f $(D4)/Done.txt
#-------------------------------------------------------
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',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 $< ; rm -f $(D5)/Done.txt
$(D2)/Sweden/tree.csv: R/format.data/Sweden.R $(shell find $(D1)/Sweden -type f)
Rscript $< ; rm -f $(D4)/Done.txt
#-------------------------------------------------------
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',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 $< ; rm -f $(D5)/Done.txt
$(D2)/Swiss/tree.csv: R/format.data/Swiss.R $(shell find $(D1)/Swiss -type f)
Rscript $< ; rm -f $(D4)/Done.txt
#-------------------------------------------------------
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',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 $< ; rm -f $(D5)/Done.txt
$(D2)/US/tree.csv: R/format.data/US.R $(shell find $(D1)/US -type f)
Rscript $< ; rm -f $(D4)/Done.txt
#-------------------------------------------------------
TEST.TREE: $(D4)/Done.txt
TEST.TREE: $(D4)/Done.txt tree.all.sites
$(D4)/Done.txt: R/format.data/test.tree.R $(D3tree)
Rscript $<
#-------------------------------------------------------
TEST.TRAITS: $(D5)/Done.txt
TEST.TRAITS: $(D5)/Done.txt #traits.all.sites
$(D5)/Done.txt: R/find.trait/test.traits.R $(D3traits)
Rscript $<
......
......@@ -7,7 +7,7 @@ library(lme4)
run.multiple.model.for.set.one.trait <- function(model.files,fun.model, trait,
type.filling, fname = 'data.all.no.std.csv',
type.filling, fname = 'data.all.no.log.csv',
cat.TF = FALSE, ...){
for (m in model.files)
try(run.model.for.set.one.trait (m, fun.model,trait,
......@@ -68,7 +68,7 @@ run.glmer <- function (model.file, trait,
source(model.file, local = TRUE)
model <- load.model()
#= Path for output
if(fname == 'data.all.no.std.csv') dir <- 'all.no.log'
if(fname == 'data.all.no.log.csv') dir <- 'all.no.log'
if(fname == 'data.all.csv') dir <- 'all.log'
path.out <- output.dir.glmer(dir, model$name, trait,
type.filling=type.filling)
......@@ -116,11 +116,11 @@ return(data.tree.tot)
#============================================================
load.and.prepare.data.for.glmer <- function(trait,
min.obs, sample.size, type.filling,
fname = 'data.all.no.std.csv',
fname = 'data.all.no.log.csv',
base.dir = "output/processed/",
cat.TF = FALSE){
### load data
if (fname == 'data.all.no.std.csv') type <- 'no.log'
if (fname == 'data.all.no.log.csv') type <- 'no.log'
if (fname == 'data.all.csv') type <- 'log'
if (cat.TF) cat <- 'cat'
if (!cat.TF) cat <- 'no.cat'
......@@ -131,11 +131,11 @@ return(df)
load.and.save.data.for.glmer <- function(trait,
min.obs = 10, sample.size = NA, type.filling = 'species',
fname = 'data.all.no.std.csv',
fname = 'data.all.no.log.csv',
base.dir = "output/processed/", cat.TF = FALSE){
### load data
data.tree.tot <- fun.load.data.all(base.dir,fname)
if (fname == 'data.all.no.std.csv') type <- 'no.log'
if (fname == 'data.all.no.log.csv') type <- 'no.log'
if (fname == 'data.all.csv') type <- 'log'
if (cat.TF) cat <- 'cat'
if (!cat.TF) cat <- 'no.cat'
......@@ -179,6 +179,10 @@ fun.center.and.standardized.var <- function(x){
return((x-mean(x))/sd(x))
}
fun.standardized.var <- function(x){
return(x/sd(x))
}
### get variables for lmer
fun.get.the.variables.for.glmer.no.tree.id <- function(data.tree,BATOT,CWM.tn,
abs.CWM.tntf,tf,min.BA.G=50){
......@@ -208,12 +212,12 @@ return(data.frame(dead=dead,
plot.id=plot.id,
set.id = set.id,
ecocode.id = ecocode.id,
sumTnTfBn.diff= fun.center.and.standardized.var(sumTnTfBn.diff),
sumTnTfBn.abs= fun.center.and.standardized.var(sumTnTfBn.abs),
Tf= fun.center.and.standardized.var(data.tree[[tf]]),
sumTnBn=fun.center.and.standardized.var(sumTnBn),
sumTfBn=fun.center.and.standardized.var(sumTfBn),
sumBn=fun.center.and.standardized.var(sumBn),
sumTnTfBn.diff= fun.standardized.var(sumTnTfBn.diff),
sumTnTfBn.abs= fun.standardized.var(sumTnTfBn.abs),
Tf= fun.standardized.var(data.tree[[tf]]),
sumTnBn=fun.standardized.var(sumTnBn),
sumTfBn=fun.standardized.var(sumTfBn),
sumBn=fun.standardized.var(sumBn),
stringsAsFactors = FALSE))
}
......@@ -262,19 +266,19 @@ return(data.frame(dead=dead,
plot.id=plot.id,
set.id = set.id,
ecocode.id = ecocode.id,
sumTnTfBn.abs.A_EV= fun.center.and.standardized.var(sumTnTfBn.abs.A_EV),
sumTnTfBn.abs.A_D= fun.center.and.standardized.var(sumTnTfBn.abs.A_D),
sumTnTfBn.abs.C= fun.center.and.standardized.var(sumTnTfBn.abs.C),
Tf.A_EV= fun.center.and.standardized.var(Tf.A_EV),
Tf.A_D= fun.center.and.standardized.var(Tf.A_D),
Tf.C= fun.center.and.standardized.var(Tf.C),
sumTnBn.A_EV=fun.center.and.standardized.var(sumTnBn.A_EV),
sumTnBn.A_D=fun.center.and.standardized.var(sumTnBn.A_D),
sumTnBn.C=fun.center.and.standardized.var(sumTnBn.C),
sumTfBn.A_EV=fun.center.and.standardized.var(sumTfBn.A_EV),
sumTfBn.A_D=fun.center.and.standardized.var(sumTfBn.A_D),
sumTfBn.C=fun.center.and.standardized.var(sumTfBn.C),
sumBn=fun.center.and.standardized.var(sumBn),
sumTnTfBn.abs.A_EV= fun.standardized.var(sumTnTfBn.abs.A_EV),
sumTnTfBn.abs.A_D= fun.standardized.var(sumTnTfBn.abs.A_D),
sumTnTfBn.abs.C= fun.standardized.var(sumTnTfBn.abs.C),
Tf.A_EV= fun.standardized.var(Tf.A_EV),
Tf.A_D= fun.standardized.var(Tf.A_D),
Tf.C= fun.standardized.var(Tf.C),
sumTnBn.A_EV=fun.standardized.var(sumTnBn.A_EV),
sumTnBn.A_D=fun.standardized.var(sumTnBn.A_D),
sumTnBn.C=fun.standardized.var(sumTnBn.C),
sumTfBn.A_EV=fun.standardized.var(sumTfBn.A_EV),
sumTfBn.A_D=fun.standardized.var(sumTfBn.A_D),
sumTfBn.C=fun.standardized.var(sumTfBn.C),
sumBn=fun.standardized.var(sumBn),
stringsAsFactors = FALSE))
}
......
......@@ -6,14 +6,6 @@ source("R/utils/plot.R")
source('R/utils/mem.R')
library(pander)
## test function to plot param in function of MAP
fm.MAT.MAP <- readRDS('output/lmer/all.no.log/SLA/species/lmer.LOGLIN.ER.AD.Tf.MAT.MAP/results.nolog.all.rds')
plot.fun.ci.param.var.climate(fm.MAT.MAP, 'SLA',
param.vec = c('sumTfBn', 'sumTnBn',
'sumTnTfBn.abs', 'Tf'),
var.vec = c('MAT', 'MAP'))
## load results all
......@@ -22,14 +14,13 @@ list.all.results <- readRDS('output/list.lmer.out.nolog.all.old.rds')
list.all.results <- readRDS('output/list.lmer.out.nolog.all.rds')
list.all.results <- readRDS('output/list.lmer.out.all.no.log.rds')
list.all.results <- readRDS('output/list.lmer.out.all.rds')
names.param <- unique(unlist(lapply(list.all.results,
function(x) names(x$lmer.summary$fixed.coeff.E))))
names.param2 <- names.param
names.param2[names.param2 == "sumBn:MAT"] <- "MAT:sumBn"
names.param2[names.param2 == "sumBn:MAP"] <- "MAP:sumBn"
names.param2[names.param2 == "Tf:MAP"] <- "MAP:Tf"
names.param2[names.param2 == "Tf:MAT"] <- "MAT:Tf"
names(names.param2) <-names.param
DF.global <- do.call( 'rbind', lapply(list.all.results,
......@@ -53,9 +44,12 @@ print(pander(res))
## add set random effect estim
pdf('figs/param.global.model.ER.AD.pdf')
par(mfrow = c(2,2))
## pdf('figs/param.global.model.ER.AD.pdf')
x11()
opar <- par()
m <- matrix(c(1:4,5,5), 2, 3)
layout(m, widths=c(4, 4, 1),
heights=c(4, 4))
for (i in c('Wood.density', 'SLA', 'Leaf.N', 'Max.height')){
param.vec <- c("logD", "Tf","sumBn", "sumTnBn","sumTfBn", "sumTnTfBn.abs")
list.temp <- list.all.results[[paste("all.no.log_", i ,
......@@ -69,7 +63,7 @@ param.BLUP <- list.temp$set.BLUP
print(i)
plot(param.mean,
xaxt = 'n', ylab = 'std parameters', xlab = NA,
main = i, ylim = c(-1, 1))
main = i, ylim = c(-0.6, 0.6))
abline(h = 0)
axis(1, 1:length(param.vec), labels = param.vec, las = 3)
fun.plot.error.bar(1:length(param.vec),
......@@ -81,52 +75,132 @@ fun.plot.error.bar(1:length(param.vec),
col = col.vec[rownames(param.BLUP)])
}
}
legend("topright",legend = names(col.vec), col = col.vec, pch = pch.vec,
ncol =2, bty = 'n')
par(mar=c(0, 0, 0, 0))
plot(1,1,pch = NA, xaxt = 'n', yaxt = 'n')
legend("center",legend = names(col.vec), col = col.vec, pch = pch.vec,
bty = 'n')
par(opar)
## dev.off()
## pdf('figs/param.global.model.ER.AD.norandom.pdf')
x11()
opar <- par()
m <- matrix(c(1:6), 2, 3)
layout(m, widths=c(4, 4, 4),
heights=c(4, 4))
for (i in c('Wood.density', 'SLA', 'Leaf.N', 'Max.height', 'Seed.mass')){
param.vec <- c("logD", "Tf","sumBn", "sumTnBn","sumTfBn", "sumTnTfBn.abs")
list.temp <- list.all.results[[paste("all.no.log_", i ,
"_species_lmer.LOGLIN.ER.AD.Tf.norandom",
sep = '')]]$lmer.summary
param.mean <- list.temp$fixed.coeff.E[param.vec]
param.std <- list.temp$fixed.coeff.Std.Error
names(param.std) <- names(list.temp$fixed.coeff.E)
param.std <- param.std[param.vec]
print(i)
plot(param.mean,
xaxt = 'n', ylab = 'std parameters', xlab = NA,
main = i, ylim = c(-0.3, 0.5))
abline(h = 0)
axis(1, 1:length(param.vec), labels = param.vec, las = 3)
fun.plot.error.bar(1:length(param.vec),
param.mean,
param.std)
}
dev.off()
## dev.off()
par(mfrow = c(2,2))
x11()
opar <- par()
m <- matrix(c(1:4,5,5), 2, 3)
layout(m, widths=c(4, 4, 1),
heights=c(4, 4))
for (i in c('Wood.density', 'SLA', 'Leaf.N', 'Max.height')){
DF.t <- DF.global[DF.global$trait == i, ]
list.temp <- list.all.results[[paste("all.no.log_", i ,
"_species_lmer.LOGLIN.ER.AD.Tf.MAT.MAP",
sep = '')]]$lmer.summary
print(i)
param.vec <- c('MAT', 'MAP', "logD", "Tf", 'MAT.Tf', 'MAP.Tf', "sumBn", 'MAT.sumBn', 'MAP.sumBn',
"sumTnBn", 'MAT.sumTnBn', 'MAP.sumTnBn', "sumTfBn", 'MAT.sumTfBn',
'MAP.sumTfBn', "sumTnTfBn.abs" , 'MAT.sumTnTfBn.abs',
'MAP.sumTnTfBn.abs')
param.vec.std <- paste(param.vec, 'Std.Error', sep = '.')
plot(unlist(DF.t[DF.t$model == "lmer.LOGLIN.ER.AD.Tf.MAT.MAP", param.vec]),
param.vec <- c('MAT', 'MAP', "logD", "Tf", 'Tf:MAT', 'Tf:MAP', "sumBn",
'MAT:sumBn', 'MAP:sumBn',
"sumTnBn", 'MAT:sumTnBn', 'MAP:sumTnBn', "sumTfBn",
'MAT:sumTfBn',
'MAP:sumTfBn', "sumTnTfBn.abs" , 'MAT:sumTnTfBn.abs',
'MAP:sumTnTfBn.abs')
param.mean <- list.temp$fixed.coeff.E[param.vec]
param.std <- list.temp$fixed.coeff.Std.Error
names(param.std) <- names(list.temp$fixed.coeff.E)
param.std <- param.std[param.vec]
param.BLUP <- list.temp$set.BLUP
plot(param.mean,
xaxt = 'n', ylab = 'std parameters', xlab = NA,
main = i, ylim = c(-1, 1))
main = i, ylim = c(-0.6, 0.6))
abline(h = 0)
axis(1, 1:length(param.vec), labels = param.vec, las = 3)
fun.plot.error.bar(1:length(param.vec),
DF.t[DF.t$model == "lmer.LOGLIN.ER.AD.Tf.MAT.MAP", param.vec],
DF.t[DF.t$model == "lmer.LOGLIN.ER.AD.Tf.MAT.MAP", param.vec.std])
param.mean,
param.std)
for (j in 1:length(param.vec)){
points(rep(j,nrow(param.BLUP)), param.BLUP[,param.vec[j]],
pch = pch.vec[rownames(param.BLUP)],
col = col.vec[rownames(param.BLUP)])
}
}
par(mar=c(0, 0, 0, 0))
plot(1,1,pch = NA, xaxt = 'n', yaxt = 'n')
legend("center",legend = names(col.vec), col = col.vec, pch = pch.vec,
bty = 'n')
par(opar)
## cat
## TODO
par(mfrow = c(2,2))
x11()
opar <- par()
m <- matrix(c(1:4), 2, 2)
layout(m, widths=c(4, 4),
heights=c(4, 4))
for (i in c('Wood.density', 'SLA', 'Leaf.N', 'Max.height')){
DF.t <- DF.global[DF.global$trait == i, ]
print(i)
param.vec <- c("logD","Tf.A_EV", "Tf.A_D", 'Tf.C',"sumBn",
"sumTnBn.A_EV", "sumTnBn.A_D", "sumTnBn.C",
"sumTfBn.A_EV", "sumTfBn.A_D","sumTfBn.C",
"sumTnTfBn.abs.A_EV" , "sumTnTfBn.abs.A_D", "sumTnTfBn.abs.C")
param.vec.std <- paste(param.vec, 'Std.Error', sep = '.')
mode.selected <- 'lmer.LOGLIN.ER.AD.Tf.CAT.norandom'
plot(unlist(DF.t[DF.t$model == mode.selected, param.vec]),
list.temp <- list.all.results[[paste("all.no.log_", i ,
"_species_lmer.LOGLIN.ER.AD.Tf.CAT.norandom",
sep = '')]]$lmer.summary
param.mean <- list.temp$fixed.coeff.E[param.vec]
param.std <- list.temp$fixed.coeff.Std.Error
names(param.std) <- names(list.temp$fixed.coeff.E)
param.std <- param.std[param.vec]
print(i)
plot(param.mean,
xaxt = 'n', ylab = 'std parameters', xlab = NA,
main = i, ylim = c(-1, 1))
main = i, ylim = c(-0.35, 0.5))
abline(h = 0)
axis(1, 1:length(param.vec), labels = param.vec, las = 3)
fun.plot.error.bar(1:length(param.vec),
DF.t[DF.t$model == mode.selected, param.vec],
DF.t[DF.t$model == mode.selected, param.vec.std])
param.mean,
param.std)
}
##
## test function to plot param in function of MAP TO TEST WHIT NEW OUTPUT !
par(mfrow = c(2, 2))
for (i in c('Wood.density', 'SLA', 'Leaf.N', 'Max.height')){
list.temp <- list.all.results[[paste("all.no.log_", i ,
"_species_lmer.LOGLIN.ER.AD.Tf.MAT.MAP",
sep = '')]]
plot.fun.ci.param.var.climate(list.temp, 'SLA',
param.vec = c('sumTfBn', 'sumTnBn',
'sumTnTfBn.abs', 'Tf'),
var.vec = c('MAT', 'MAP'))
}
This diff is collapsed.
......@@ -17,7 +17,7 @@ mem <- function() {
run.multiple.model.for.set.one.trait <- function(model.files, fun.model, trait,
type.filling, cat.TF = FALSE, fname = 'data.all.no.std.csv' , ...){
type.filling, cat.TF = FALSE, fname = 'data.all.no.log.csv' , ...){
for (m in model.files)
(run.model.for.set.one.trait (m, fun.model, trait,
type.filling = type.filling, cat.TF = cat.TF, fname, ...))
......@@ -75,12 +75,12 @@ fun.call.lmer.and.save <- function(formula, df.lmer, path.out){
run.lmer <- function (model.file, trait,
min.obs = 10, sample.size = NA,
type.filling, cat.TF, fname = 'data.all.no.std.csv') {
type.filling, cat.TF, fname = 'data.all.no.log.csv') {
require(lme4)
source(model.file, local = TRUE)
model <- load.model()
#= Path for output
if(fname == 'data.all.no.std.csv') dir <- 'all.no.log'
if(fname == 'data.all.no.log.csv') dir <- 'all.no.log'
if(fname == 'data.all.csv') dir <- 'all.log'
path.out <- output.dir.lmer(model$name, trait, dir,
type.filling = type.filling)
......@@ -129,10 +129,10 @@ return(data.tree.tot)
#============================================================
load.and.prepare.data.for.lmer <- function(trait,
cat.TF,
fname = 'data.all.no.std.csv',
fname = 'data.all.no.log.csv',
base.dir = "output/processed",
data.table.TF = FALSE){
if (fname == 'data.all.no.std.csv') type <- 'no.log'
if (fname == 'data.all.no.log.csv') type <- 'no.log'
if (fname == 'data.all.csv') type <- 'log'
if (cat.TF) cat <- 'cat'