Commit 6a2bd1f0 authored by kunstler's avatar kunstler
Browse files

fix error load data intra

parent bfc1e8d6
......@@ -37,7 +37,7 @@ model.files.lmer.Tf.2 <- file.path(path.model,
c("model.lmer.LOGLIN.ER.AD.Tf.intra.r.set.species.R",
"model.lmer.LOGLIN.ER.AD.Tf.intra.r.set.fixed.biomes.species.R"))
model.files.lmer.Tf.3 <- file.path(path.model,
c("model.lmer.LOGLIN.ER.AD.Tf.intra.r.ecocode.species.R"))
c("model.lmer.LOGLIN.ER.AD.Tf.r.ecocode.species.R"))
......@@ -159,7 +159,7 @@ load.data.for.lmer <- function(trait, data.type,
if(!is.na(select.set.)) {
df <- dplyr::filter(df, set == select.set.)
}
if(!is.na(sample.size.) ){
if(!is.na(sample.size.)){
if(sample.size. < length(unique(df$plot))){
if(!sample.vec.TF.){
if(sample.size. > length(unique(df$plot))){
......@@ -186,6 +186,7 @@ load.data.for.lmer <- function(trait, data.type,
df <- select.one.census.per.plot(df)
}
list.sd <- get.sd.lmer(df, trait, min.obs = 10)
print('sd ok')
res <- format.data.for.lmer(df, trait,
data.type = data.type,
ecocode.var = ecocode.var.)
......@@ -288,9 +289,7 @@ load.and.save.data.for.lmer <- function(trait,
min.obs= 10,
data.type = 'simple',
base.dir = "output/processed"){
fname <- switch(data.type, 'simple' = 'data.all.no.log.all.census.rds',
'all.census' = 'data.all.no.log.all.census.rds',
'intra' = 'data.all.no.log.all.census.rds')
fname <- 'data.all.no.log.all.census.rds'
data.tree.tot <- readRDS(file.path(base.dir, fname))
df <- select.data.trait(data.tree.tot, trait)
saveRDS(df,file = file.path(base.dir,paste('data', trait, data.type, 'rds',
......@@ -402,7 +401,7 @@ return(data.frame(logG = logG,
# Function to prepare data for lmer with CWM data
#============================================================
format.data.for.lmer <- function(data.tree, trait, min.obs = 10,
data.type = 'simple', ecocode.var = 'wwf') {
data.type = 'simple', ecocode.var = 'wwf') {
if(! trait %in% c("SLA", "Leaf.N", "Seed.mass",
"SLA", "Wood.density", "Max.height"))
stop("need trait to be in SLA Leaf.N Seed.mass
......@@ -425,8 +424,11 @@ if(data.type == 'simple' | data.type == 'all.census') {
if(data.type =='intra') {
print('intra')
lmer.data <- get.variables.intra(data.tree,
BATOT,
ecocode.var)
BATOT,
CWM.tn,
abs.CWM.tntf,
tf,
ecocode.var)
}
return(lmer.data)
}
......
......@@ -22,7 +22,7 @@ samplesize=$1
# "'Seed.mass'" "'Leaf.N'"
for trait in "'SLA'" "'Wood.density'" "'Max.height'" ; do
# # ALL data
# # ALL data 0
echo "/usr/local/R/R-3.1.1/bin/Rscript -e \"source('R/analysis/lmer.run.R'); run.multiple.model.for.set.one.trait(model.files.lmer.Tf.0[1], run.lmer,$trait);print('done')\"" > Rscript_temp/all0${trait}.sh
qsub Rscript_temp/all0${trait}.sh -d ~/trait.competition.workshop -l nodes=1:ppn=1,mem=8gb -N "lmerall2all.0${trait}" -q opt32G -j oe
......@@ -30,7 +30,7 @@ samplesize=$1
echo "/usr/local/R/R-3.1.1/bin/Rscript -e \"source('R/analysis/lmer.run.R'); run.multiple.model.for.set.one.trait(model.files.lmer.Tf.0[2], merge.biomes.TF = TRUE, run.lmer,$trait);print('done')\"" > Rscript_temp/all02${trait}.sh
qsub Rscript_temp/all02${trait}.sh -d ~/trait.competition.workshop -l nodes=1:ppn=1,mem=8gb -N "lmerall2all.02${trait}" -q opt32G -j oe
# # ALL data
# # ALL data 1
echo "/usr/local/R/R-3.1.1/bin/Rscript -e \"source('R/analysis/lmer.run.R'); run.multiple.model.for.set.one.trait(model.files.lmer.Tf.1[1], run.lmer,$trait);print('done')\"" > Rscript_temp/allf${trait}.sh
qsub Rscript_temp/allf${trait}.sh -d ~/trait.competition.workshop -l nodes=1:ppn=1,mem=8gb -N "lmerall2all.f${trait}" -q opt32G -j oe
......@@ -38,7 +38,7 @@ samplesize=$1
echo "/usr/local/R/R-3.1.1/bin/Rscript -e \"source('R/analysis/lmer.run.R'); run.multiple.model.for.set.one.trait(model.files.lmer.Tf.1[2], merge.biomes.TF = TRUE, run.lmer,$trait);print('done')\"" > Rscript_temp/allf2${trait}.sh
qsub Rscript_temp/allf2${trait}.sh -d ~/trait.competition.workshop -l nodes=1:ppn=1,mem=8gb -N "lmerall2all.f2${trait}" -q opt32G -j oe
# # INTRA
# # INTRA 2
echo "/usr/local/R/R-3.1.1/bin/Rscript -e \"source('R/analysis/lmer.run.R'); run.multiple.model.for.set.one.trait(model.files.lmer.Tf.2[1], run.lmer,$trait, data.type = 'intra');print('done')\"" > Rscript_temp/allINTRA${trait}.sh
qsub Rscript_temp/allINTRA${trait}.sh -d ~/trait.competition.workshop -l nodes=1:ppn=1,mem=8gb -N "lmerall2all.INTRA${trait}" -q opt32G -j oe
......@@ -47,7 +47,7 @@ samplesize=$1
qsub Rscript_temp/allINTRA2${trait}.sh -d ~/trait.competition.workshop -l nodes=1:ppn=1,mem=8gb -N "lmerall2all.INTRA2${trait}" -q opt32G -j oe
# # ecocode
# # ecocode 3
echo "/usr/local/R/R-3.1.1/bin/Rscript -e \"source('R/analysis/lmer.run.R'); run.multiple.model.for.set.one.trait(model.files.lmer.Tf.3[1], run.lmer,$trait, data.type = 'simple');print('done')\"" > Rscript_temp/allECO${trait}.sh
qsub Rscript_temp/allECO${trait}.sh -d ~/trait.competition.workshop -l nodes=1:ppn=1,mem=8gb -N "lmerall2all.ECO${trait}" -q opt32G -j oe
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment