Commit 3bd7fd04 authored by Kunstler Georges's avatar Kunstler Georges
Browse files

save deid data

parent 9eae3fda
......@@ -82,6 +82,46 @@ call.lmer.and.save <- function(formula, df.lmer, path.out,
file = file.path(path.out, name.file))
}
save.deid.data <- function(model.file, trait,
min.obs = 10, sample.size = NA,
ecocode.var = 'koppen',
data.type ='simple',
var.sample = NA,
select.biome = NA,
merge.biomes.TF = FALSE,
sample.vec.TF = FALSE){
require(lme4)
source(model.file, local = TRUE)
model <- load.model()
#= Path for output
path.out <- output.dir('lmer', model$name, trait, data.type)
print(path.out)
dir.create(path.out, recursive = TRUE, showWarnings = FALSE)
cat("run lmer for model", model.file, " for trait",
trait, "\n")
list.df.lmer <- load.data.for.lmer(trait,
data.type = data.type,
sample.size. = sample.size,
ecocode.var. = ecocode.var,
var.sample. = var.sample,
select.biome. = select.biome,
merge.biomes.TF = merge.biomes.TF,
sample.vec.TF. = sample.vec.TF)
# return a list of DF
cat("Ok data with Nobs", nrow(list.df.lmer[[1]]),
"\n")
print(names(list.df.lmer[[1]]))
print(dim(list.df.lmer[[1]]))
write.csv(list.df.lmer[[1]],
file = file.path("output/processed",paste('data.deid', trait, data.type, 'csv',
sep = '.')),
row.names = FALSE)
}
run.lmer <- function (model.file, trait,
......@@ -113,6 +153,8 @@ run.lmer <- function (model.file, trait,
# return a list of DF
cat("Ok data with Nobs", nrow(list.df.lmer[[1]]),
"\n")
# if(merge.biomes.TF) df <- merge.biomes(df) TO MOVE AFTER
print(names(list.df.lmer[[1]]))
print(dim(list.df.lmer[[1]]))
#= Run model
......@@ -175,7 +217,7 @@ load.data.for.lmer <- function(trait, data.type,
df <- dplyr::mutate(df,sp.name = ifelse(is.na(sp.name), 'missing.sp',
sp.name))
if(merge.biomes.TF) df <- merge.biomes(df)
# if(merge.biomes.TF) df <- merge.biomes(df) TO MOVE AFTER
if(!is.na(select.biome.)) {
df <- dplyr::filter(df, biomes == select.biome.)
}
......
#!/bin/bash
# Georges Kunstler 14/05/2014
# read one variable
export LD_LIBRARY_PATH=/usr/lib64/R/library
mkdir -p Rscript_temp
# test parameter
nbargs=$#
echo "number of arguments="$nbargs
if [ $nbargs -ne 1 ]
then
echo "need one and only one argument"
echo " usage :"
echo " ./launch_all_lmer.sh sample.size"
exit 100
fi
samplesize=$1
# "'Seed.mass'" "'Leaf.N'"
for trait in "'SLA'" "'Wood.density'" "'Max.height'" ; do
# # INTRA 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.intra.0[1], save.deid.data,$trait, data.type = 'intra');print('done')\"" > Rscript_temp/allINTRA0.DEID${trait}.sh
qsub Rscript_temp/allINTRA0.DEID${trait}.sh -d ~/trait.competition.workshop -l nodes=1:ppn=1,mem=8gb -N "lmerall2all.INTRA0.DEID${trait}" -q opt32G -j oe
done
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