Commit c5de53b5 authored by Georges Kunstler's avatar Georges Kunstler
Browse files

new way of loading data to avoid memory issue

parent 98657240
......@@ -5,25 +5,19 @@ library(lme4)
run.models.for.set.all.traits <- function(model.file,fun.model, traits =
c("SLA", "Wood.density","Max.height","Leaf.N","Seed.mass"),
type.filling, ...){
for(trait in traits)
run.multiple.model.for.set.one.trait(model.file,fun.model, trait, type.filling=type.filling, ...)
}
run.multiple.model.for.set.one.trait <- function(model.files,fun.model, trait,
type.filling, ...){
type.filling, cat.TF, ...){
for (m in model.files)
try(run.model.for.set.one.trait (m, fun.model,trait,
type.filling=type.filling, ...))
type.filling=type.filling, cat.TF = cat.TF, ...))
}
run.model.for.set.one.trait <- function(model.file,fun.model, trait,
type.filling, ...){
type.filling, cat.TF, ...){
fun.model <- match.fun(fun.model)
try(fun.model(model.file, trait, type.filling=type.filling,...))
try(fun.model(model.file, trait, type.filling=type.filling, cat.TF = cat.TF, ...))
}
......@@ -68,7 +62,7 @@ fun.call.glmer.and.save <- function(formula,df.lmer,path.out){
run.glmer <- function (model.file, trait,
min.obs=5, sample.size=NA,
type.filling, fname = 'data.all.no.std.csv') {
type.filling, fname = 'data.all.no.std.csv', cat.TF) {
require(lme4)
source(model.file, local = TRUE)
model <- load.model()
......@@ -83,9 +77,10 @@ run.glmer <- function (model.file, trait,
'all',"trait",
trait,"\n")
df.glmer <- load.and.prepare.data.for.glmer(trait,
min.obs, sample.size,
type.filling=type.filling,
fname = fname) # return a DF
min.obs, sample.size,
type.filling=type.filling,
fname = fname,
cat.TF = cat.TF) # return a DF
cat("Ok data with Nobs",nrow(df.glmer),"\n")
#= Run model
fun.call.glmer.and.save(formula=model$glmer.formula,df.glmer,path.out)
......@@ -121,11 +116,32 @@ return(data.tree.tot)
load.and.prepare.data.for.glmer <- function(trait,
min.obs, sample.size, type.filling,
fname = 'data.all.no.std.csv',
base.dir = "output/processed/"){
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.csv') type <- 'log'
if (cat.TF) cat <- 'cat'
if (!cat.TF) cat <- 'no.cat'
fun.data.for.glmer(data.tree.tot,trait,type.filling=type.filling)
df <- readRDS(file = file.path(base.dir,paste('data.glmer', trait, type, cat,'rds', sep = '.')))
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',
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.csv') type <- 'log'
if (cat.TF) cat <- 'cat'
if (!cat.TF) cat <- 'no.cat'
df <- fun.data.for.glmer(data.tree.tot,trait,type.filling=type.filling, cat.TF = cat.TF)
saveRDS(df,file = file.path(base.dir,paste('data.glmer', trait, type, cat,'rds', sep = '.')))
}
fun.select.data.for.analysis <- function(data.tree,abs.CWM.tntf,
......@@ -196,7 +212,69 @@ return(data.frame(dead=dead,
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)))
sumBn=fun.center.and.standardized.var(sumBn),
stringsAsFactors = FALSE))
}
### get variables for lmer
fun.get.the.variables.for.glmer.no.tree.id.cat <- function(data.tree,BATOT,CWM.tn,
abs.CWM.tntf,tf,min.BA.G=50){
dead <- data.tree[["dead"]]
logD <- fun.center.and.standardized.var(log(data.tree[["D"]]))
logyear <- log(data.tree[["year"]])
MAT <- fun.center.and.standardized.var(data.tree[["MAT"]])
MAP <- fun.center.and.standardized.var(data.tree[["MAP"]])
species.id <- factor(data.tree[["sp"]])
tree.id <- factor(data.tree[["tree.id"]])
plot.id <- factor(data.tree[["plot"]])
set.id <- factor(data.tree[["set"]])
ecocode.id <- factor(data.tree[['ecocode']])
#get the three cwm per cat
vec.CWM.tn <- paste(CWM.tn, c('A_EV', 'A_D', 'C'), sep = '.')
vec.abs.CWM.tntf <- paste(abs.CWM.tntf, c('A_EV', 'A_D', 'C'), sep = '.')
sumTnTfBn.abs.A_EV<- data.tree[[vec.abs.CWM.tntf[1]]]
sumTnTfBn.abs.A_D <- data.tree[[vec.abs.CWM.tntf[2]]]
sumTnTfBn.abs.C <- data.tree[[vec.abs.CWM.tntf[3]]]
sumTnBn.A_EV<- data.tree[[vec.CWM.tn[1]]]
sumTnBn.A_D <- data.tree[[vec.CWM.tn[2]]]
sumTnBn.C <- data.tree[[vec.CWM.tn[3]]]
sumTfBn <- data.tree[[tf]]*data.tree[[BATOT]]
sumTfBn.A_EV <- as.numeric(data.tree[['SLA.cat']] == 1) *sumTfBn
sumTfBn.A_D <- as.numeric(data.tree[['SLA.cat']] == 2) *sumTfBn
sumTfBn.C <- as.numeric(data.tree[['SLA.cat']] == 3) *sumTfBn
sumBn <- data.tree[[BATOT]]
Tf.A_EV <- as.numeric(data.tree[['SLA.cat']] == 1) *data.tree[[tf]]
Tf.A_D <- as.numeric(data.tree[['SLA.cat']] == 2) *data.tree[[tf]]
Tf.C <- as.numeric(data.tree[['SLA.cat']] == 3) *data.tree[[tf]]
return(data.frame(dead=dead,
logD=logD,
logyear=logyear,
MAT = MAT,
MAP = MAP,
species.id=species.id,
tree.id=tree.id,
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),
stringsAsFactors = FALSE))
}
......@@ -205,7 +283,7 @@ return(data.frame(dead=dead,
# that will be used in a simple linear model
#============================================================
fun.data.for.glmer <- function(data.tree,trait,min.obs=10,
type.filling='species') {
type.filling='species', cat.TF = FALSE) {
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 SLA Wood.density or Max.height ")
......@@ -223,7 +301,23 @@ data.tree <- fun.select.data.for.analysis(data.tree,
perc.neigh.gs,
BATOT,min.obs)
#= DATA LIST FOR JAGS
glmer.data <- fun.get.the.variables.for.glmer.no.tree.id(data.tree,BATOT,CWM.tn,abs.CWM.tntf,tf)
if(!cat.TF) {
print('no cat')
glmer.data <- fun.get.the.variables.for.glmer.no.tree.id(data.tree,
BATOT,
CWM.tn,
abs.CWM.tntf,
tf)
}
if(cat.TF) {
print('cat')
glmer.data <- fun.get.the.variables.for.glmer.no.tree.id.cat(data.tree,
BATOT,
CWM.tn,
abs.CWM.tntf,
tf)
}
return(glmer.data)
}
......
......@@ -3,6 +3,19 @@
### FUNCTION TO RUN LMER ESTIMATION WITH NO logBA for all in one big model
library(lme4)
mem <- function() {
bit <- 8L * .Machine$sizeof.pointer
if (!(bit == 32L || bit == 64L)) {
stop("Unknown architecture", call. = FALSE)
}
node_size <- if (bit == 32L) 28L else 56L
usage <- gc()
sum(usage[, 1] * c(node_size, 8)) / (1024 ^ 2)
}
run.multiple.model.for.set.one.trait <- function(model.files, fun.model, trait,
type.filling, cat.TF = FALSE, fname = 'data.all.no.std.csv' , ...){
for (m in model.files)
......@@ -49,7 +62,7 @@ model.files.lmer.Tf.5 <-
model.files.lmer.Tf.6 <-
c("R/analysis/model.lmer.all/model.lmer.LOGLIN.ER.AD.Tf.CAT.norandom.R")
fun.call.lmer.and.save <- function(formula, df.lmer, path.out){
lmer.output <- lmer(formula = formula, data = df.lmer, REML = FALSE,
control = lmerControl(optCtrl = list(maxfun = 40000) ) )
......@@ -72,14 +85,13 @@ run.lmer <- function (model.file, trait,
dir.create(path.out, recursive = TRUE, showWarnings = FALSE)
cat("run lmer for model", model.file, " for trait",
trait, "\n")
df.lmer <- load.and.prepare.data.for.lmer(trait,
min.obs, sample.size,
type.filling = type.filling,
fname = fname, cat.TF = cat.TF)
df.lmer <- load.and.prepare.data.for.lmer(trait,fname = fname, cat.TF = cat.TF)
# return a DF
cat("Ok data with Nobs", nrow(df.lmer),
"\n")
#= Run model
print(mem())
#= Run model
fun.call.lmer.and.save(formula = model$lmer.formula.tree.id,
df.lmer, path.out)
rm(df.lmer)
......@@ -87,6 +99,7 @@ run.lmer <- function (model.file, trait,
}
#========================================================================
output.dir.lmer <- function (model, trait, set, type.filling) {
......@@ -112,17 +125,36 @@ return(data.tree.tot)
# Function to prepare data for lmer
#============================================================
load.and.prepare.data.for.lmer <- function(trait,
min.obs, sample.size, type.filling,
cat.TF,
fname = 'data.all.no.std.csv',
base.dir = "output/processed",
data.table.TF = FALSE){
if (fname == 'data.all.no.std.csv') type <- 'no.log'
if (fname == 'data.all.csv') type <- 'log'
if (cat.TF) cat <- 'cat'
if (!cat.TF) cat <- 'no.cat'
df <- readRDS(file = file.path(base.dir,paste('data', trait, type, cat,'rds', sep = '.')))
return( df)
}
load.and.save.data.for.lmer <- function(trait,
min.obs= 10, sample.size = NA, type.filling = species,
cat.TF= FALSE,
fname = 'data.all.no.std.csv',
base.dir = "output/processed",
data.table.TF = FALSE){
if(!data.table.TF) data.tree.tot <- fun.load.data.all(base.dir,fname)
if(data.table.TF) {
require(data.table)
data.tree.tot <- fread(file.path(base.dir, fname))
}
fun.data.for.lmer(data.tree.tot, trait, type.filling = type.filling, cat.TF = cat.TF)
df <- fun.data.for.lmer(data.tree.tot, trait,
type.filling = type.filling, cat.TF = cat.TF)
if (fname == 'data.all.no.std.csv') type <- 'no.log'
if (fname == 'data.all.csv') type <- 'log'
if (cat.TF) cat <- 'cat'
if (!cat.TF) cat <- 'no.cat'
saveRDS(df,file = file.path(base.dir,paste('data', trait, type, cat,'rds', sep = '.')))
}
fun.select.data.for.analysis <- function(data.tree, abs.CWM.tntf, perc.neigh.sp,
......@@ -131,30 +163,33 @@ fun.select.data.for.analysis <- function(data.tree, abs.CWM.tntf, perc.neigh.sp,
min.perc.neigh.gs = 0.95,
min.BA.G = -60,
max.BA.G = 500){
select.temp <-(1:nrow(data.tree))[!is.na(data.tree[["BA.G"]]) &
!is.na(data.tree[["D"]]) &
data.tree[["BA.G"]]>min.BA.G &
data.tree[["BA.G"]]<max.BA.G &
data.tree[["D"]]>9.9 &
!is.na(data.tree[[abs.CWM.tntf]]) &
!is.na(data.tree[[BATOT]]) &
data.tree[[perc.neigh.sp]] >
min.perc.neigh.sp &
!is.na(data.tree[[perc.neigh.sp]]) &
data.tree[[perc.neigh.gs]] >
min.perc.neigh.gs &
!is.na(data.tree[[perc.neigh.gs]])]
## remove tree with NA
data.tree <- subset(data.tree, subset = (!is.na(data.tree[["BA.G"]])) &
(!is.na(data.tree[["D"]])) )
## remove tree with zero
data.tree <- subset(data.tree, subset = data.tree[["BA.G"]]>min.BA.G &
data.tree[["BA.G"]]<max.BA.G &
data.tree[["D"]]>9.9)
## select species with no missing traits
select.temp <- (!is.na(data.tree[[abs.CWM.tntf]]) &
!is.na(data.tree[[BATOT]]))
data.tree <- data.tree[select.temp, ]
# select obs abov min perc.neigh species
data.tree <- subset(data.tree, subset = data.tree[[perc.neigh.sp]] >
min.perc.neigh.sp &
!is.na(data.tree[[perc.neigh.sp]]))
# select obs abov min perc.neigh genus
data.tree <- subset(data.tree, subset = data.tree[[perc.neigh.gs]] >
min.perc.neigh.gs &
!is.na(data.tree[[perc.neigh.gs]]))
data.tree <- data.tree[select.temp ,]
# select species with minimum obs
data.tree <- subset(data.tree, subset = data.tree[["sp"]] %in%
names(table(factor(data.tree[["sp"]])))[
table(factor(data.tree[["sp"]]))>min.obs])
return(data.tree)
select.temp <- (1:nrow(data.tree))[data.tree[["sp"]] %in%
names(table(factor(data.tree[["sp"]])))[
table(factor(data.tree[["sp"]]))>min.obs]]
data.tree <- data.tree[select.temp, ]
DT <- drop(data.tree)
rm(data.tree)
gc()
return(DT)
}
fun.center.and.standardized.var <- function(x){
......@@ -169,12 +204,12 @@ logG <- fun.center.and.standardized.var(log(data.tree[["BA.G"]] + min.BA.G))
logD <- fun.center.and.standardized.var(log(data.tree[["D"]]))
MAT <- fun.center.and.standardized.var(data.tree[["MAT"]])
MAP <- fun.center.and.standardized.var(data.tree[["MAP"]])
species.id <- factor(data.tree[["sp"]])
tree.id <- factor(data.tree[["tree.id"]])
plot.id <- factor(data.tree[["plot"]])
species.id <- as.character(factor(data.tree[["sp"]]))
tree.id <- as.character(factor(data.tree[["tree.id"]]))
plot.id <- as.character(factor(data.tree[["plot"]]))
set.id <- factor(data.tree[["set"]])
ecocode.id <- factor(data.tree[['ecocode']])
set.id <- as.character(factor(data.tree[["set"]]))
ecocode.id <- as.character(factor(data.tree[['ecocode']]))
#= multiply CWMs by BATOT
sumTnTfBn.abs <- data.tree[[abs.CWM.tntf]]*
......@@ -184,20 +219,21 @@ sumTfBn <- data.tree[[tf]]*data.tree[[BATOT]]
sumTnTfBn.diff <- sumTnBn-sumTfBn
sumBn <- data.tree[[BATOT]]
return(data.frame(logG = logG,
logD = logD,
MAT = MAT,
MAP = MAP,
species.id = species.id,
tree.id = tree.id,
set.id = set.id,
ecocode.id = ecocode.id,
plot.id = plot.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)))
logD = logD,
MAT = MAT,
MAP = MAP,
species.id = species.id,
tree.id = tree.id,
set.id = set.id,
ecocode.id = ecocode.id,
plot.id = plot.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),
stringsAsFactors = FALSE))
}
fun.get.the.variables.for.lmer.tree.id.cat <- function(data.tree, BATOT, CWM.tn,
......@@ -231,6 +267,9 @@ sumTfBn.A_EV <- as.numeric(data.tree[['SLA.cat']] == 1) *sumTfBn
sumTfBn.A_D <- as.numeric(data.tree[['SLA.cat']] == 2) *sumTfBn
sumTfBn.C <- as.numeric(data.tree[['SLA.cat']] == 3) *sumTfBn
sumBn <- data.tree[[BATOT]]
Tf.A_EV <- as.numeric(data.tree[['SLA.cat']] == 1) *data.tree[[tf]]
Tf.A_D <- as.numeric(data.tree[['SLA.cat']] == 2) *data.tree[[tf]]
Tf.C <- as.numeric(data.tree[['SLA.cat']] == 3) *data.tree[[tf]]
return(
data.frame(logG = logG,
logD = logD,
......@@ -247,12 +286,9 @@ data.frame(logG = logG,
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(data.tree[[tf]] *
as.numeric(data.tree[['SLA.cat']] == 1)),
Tf.A_D= fun.center.and.standardized.var(data.tree[[tf]] *
as.numeric(data.tree[['SLA.cat']] == 2)),
Tf.C = fun.center.and.standardized.var(data.tree[[tf]] *
as.numeric(data.tree[['SLA.cat']] == 3)),
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),
......@@ -287,16 +323,22 @@ data.tree <- fun.select.data.for.analysis(data.tree,
BATOT,
min.obs)
#= DATA LIST FOR LMER
if(!cat.TF) lmer.data <- fun.get.the.variables.for.lmer.tree.id(data.tree,
if(!cat.TF) {
print('no cat')
lmer.data <- fun.get.the.variables.for.lmer.tree.id(data.tree,
BATOT,
CWM.tn,
abs.CWM.tntf,
tf)
if(cat.TF) lmer.data <- fun.get.the.variables.for.lmer.tree.id.cat(data.tree,
}
if(cat.TF) {
print('cat')
lmer.data <- fun.get.the.variables.for.lmer.tree.id.cat(data.tree,
BATOT,
CWM.tn,
abs.CWM.tntf,
tf)
}
return(lmer.data)
}
......
load.model <- function () {
list(name="lmer.LOGLIN.ER.AD.Tf.MAT.MAP",
lmer.formula.tree.id=formula("logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+MAT:Tf+MAP:Tf+MAT+MAP+logD+sumTfBn+MAsumTfBn:MAT+sumTfBn:MAP+sumBn+sumBn:MAT+sumBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+sumTnTfBn.abs+sumTnTfBn.abs:MAT+sumTnTfBn.abs:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sumTfBn-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)+(sumTnTfBn.abs-1|set.id)"))
}
......@@ -6,7 +6,7 @@ other.model <- c("R/analysis/model.lmer.all/model.lmer.LOGLIN.ER.AD.Tf.norandom.
traits <- c('Wood.density', "SLA", 'Leaf.N', 'Max.height')
for (t in traits[1]){
run.multiple.model.for.set.one.trait(c(other.model[2]),
run.lmer,t,type.filling='species', cat.TF = TRUE)
run.multiple.model.for.set.one.trait(model.files.lmer.Tf.1[3],
run.lmer,t,type.filling='species', cat.TF = FALSE)
}
......@@ -6,6 +6,8 @@ rm(list = ls())
source("R/process.data/process-fun.R")
source("R/process.data/test.tree.CWM-fun.R")
source("R/utils/plot.R")
source("R/utils/mem.R")
source("R/analysis/lmer.run.nolog.all.R")
filedir <- "output/processed"
......@@ -16,9 +18,15 @@ mat.perc <- read.csv(file = file.path(filedir, "all.sites.perc.traits.csv"),
library(data.table)
system.time(data.all <- fread(file.path(filedir, "data.all.csv"),
stringsAsFactors = FALSE))
system.time(data.all <- read.csv(file.path(filedir, "data.all.csv"),
stringsAsFactors = FALSE))
system.time( data.all <- fun.load.data.all(filedir,fname = "data.all.csv"))
system.time(data.all.no.std <- fread(file.path(filedir, "data.all.no.std.csv"),
stringsAsFactors = FALSE))
df.lmer <- fun.data.for.lmer(data.all, 'Max.height',
type.filling = 'species', cat.TF = FALSE)
if(dim(data.all)[1] != sum(mat.perc[['num.obs']]))
stop('error not same dimension per ecoregion and total')
......
......@@ -11,7 +11,7 @@ data.sample <- read.csv(fname,
stringsAsFactors = FALSE, nrows = 1000)
classes <- sapply(data.sample, class)
classes[classes=='integer'] <- "numeric"
nrows <- as.numeric(system(paste('wc -l < ' fname),
nrows <- as.numeric(system(paste('wc -l < ', fname),
intern = TRUE))
data <- read.csv(fname,
......
#!/bin/bash
export LD_LIBRARY_PATH=/usr/lib64/R/library
mkdir -p trait.workshop
for trait in "'SLA'" "'Leaf.N'" "'Wood.density'" "'Max.height'" "'Seed.mass'"; do
echo "/usr/local/R/R-3.0.1/bin/Rscript -e \"source('R/analysis/glmer.run.all.R'); load.and.save.data.for.glmer($trait);print('done')\"" > trait.workshop/gdata1$trait.sh
qsub trait.workshop/gdata1$trait.sh -l nodes=2:ppn=1 -N "gdata1$trait" -q opt32G -j oe
echo "/usr/local/R/R-3.0.1/bin/Rscript -e \"source('R/analysis/glmer.run.all.R'); load.and.save.data.for.glmer($trait, cat.TF=TRUE);print('done')\"" > trait.workshop/gdata2$trait.sh
qsub trait.workshop/gdata2$trait.sh -l nodes=2:ppn=1 -N "gdata2$trait" -q opt32G -j oe
echo "/usr/local/R/R-3.0.1/bin/Rscript -e \"source('R/analysis/glmer.run.all.R'); load.and.save.data.for.glmer($trait, fname = 'data.all.csv');print('done')\"" > trait.workshop/gdata3$trait.sh
qsub trait.workshop/gdata3$trait.sh -l nodes=2:ppn=1 -N "gdata3$trait" -q opt32G -j oe
echo "/usr/local/R/R-3.0.1/bin/Rscript -e \"source('R/analysis/glmer.run.all.R'); load.and.save.data.for.glmer($trait, cat.TF=TRUE, fname = 'data.all.csv');print('done')\"" > trait.workshop/gdata4$trait.sh
qsub trait.workshop/gdata4$trait.sh -l nodes=2:ppn=1 -N "gdata4$trait" -q opt32G -j oe
done
#!/bin/bash
export LD_LIBRARY_PATH=/usr/lib64/R/library
mkdir -p trait.workshop
for trait in "'SLA'" "'Leaf.N'" "'Wood.density'" "'Max.height'" "'Seed.mass'"; do
echo "Rscript -e \"source('R/analysis/glmer.run.all.R'); load.and.save.data.for.glmer($trait);print('done')\"" > trait.workshop/gdata1$trait.sh
bash trait.workshop/gdata1$trait.sh
echo "Rscript -e \"source('R/analysis/glmer.run.all.R'); load.and.save.data.for.glmer($trait, cat.TF=TRUE);print('done')\"" > trait.workshop/gdata2$trait.sh
bash trait.workshop/gdata2$trait.sh
echo "Rscript -e \"source('R/analysis/glmer.run.all.R'); load.and.save.data.for.glmer($trait, fname = 'data.all.csv');print('done')\"" > trait.workshop/gdata3$trait.sh
bash trait.workshop/gdata3$trait.sh
echo "Rscript -e \"source('R/analysis/glmer.run.all.R'); load.and.save.data.for.glmer($trait, cat.TF=TRUE, fname = 'data.all.csv');print('done')\"" > trait.workshop/gdata4$trait.sh
bash trait.workshop/gdata4$trait.sh
done
#!/bin/bash
export LD_LIBRARY_PATH=/usr/lib64/R/library
mkdir -p trait.workshop
for trait in "'SLA'" "'Leaf.N'" "'Wood.density'" "'Max.height'" "'Seed.mass'"; do
echo "/usr/local/R/R-3.0.1/bin/Rscript -e \"source('R/analysis/lmer.run.nolog.all.R'); load.and.save.data.for.lmer($trait, data.table.TF = FALSE);print('done')\"" > trait.workshop/data1$trait.sh
qsub trait.workshop/data1$trait.sh -l nodes=2:ppn=1 -N "data1$trait" -q opt32G -j oe
echo "/usr/local/R/R-3.0.1/bin/Rscript -e \"source('R/analysis/lmer.run.nolog.all.R'); load.and.save.data.for.lmer($trait, data.table.TF = FALSE, cat.TF=TRUE);print('done')\"" > trait.workshop/data2$trait.sh
qsub trait.workshop/data2$trait.sh -l nodes=2:ppn=1 -N "data2$trait" -q opt32G -j oe
echo "/usr/local/R/R-3.0.1/bin/Rscript -e \"source('R/analysis/lmer.run.nolog.all.R'); load.and.save.data.for.lmer($trait, data.table.TF = FALSE, fname = 'data.all.csv');print('done')\"" > trait.workshop/data3$trait.sh
qsub trait.workshop/data3$trait.sh -l nodes=2:ppn=1 -N "data3$trait" -q opt32G -j oe
echo "/usr/local/R/R-3.0.1/bin/Rscript -e \"source('R/analysis/lmer.run.nolog.all.R'); load.and.save.data.for.lmer($trait, data.table.TF = FALSE, cat.TF=TRUE, fname = 'data.all.csv');print('done')\"" > trait.workshop/data4$trait.sh
qsub trait.workshop/data4$trait.sh -l nodes=2:ppn=1 -N "data4$trait" -q opt32G -j oe
done
#!/bin/bash
export LD_LIBRARY_PATH=/usr/lib64/R/library
mkdir -p trait.workshop
for trait in "SLA" "Leaf.N" "Wood.density" "Max.height" "Seed.mass"; do
echo "Rscript -e \"source('R/analysis/lmer.run.nolog.all.R'); load.and.save.data.for.lmer('$trait', data.table.TF = TRUE);print('done')\"" > trait.workshop/data1$trait.sh
bash trait.workshop/data1$trait.sh
echo "Rscript -e \"source('R/analysis/lmer.run.nolog.all.R'); load.and.save.data.for.lmer('$trait', data.table.TF = TRUE, cat.TF=TRUE);print('done')\"" > trait.workshop/data2$trait.sh
bash trait.workshop/data2$trait.sh
echo "Rscript -e \"source('R/analysis/lmer.run.nolog.all.R'); load.and.save.data.for.lmer('$trait', data.table.TF = TRUE, fname = 'data.all.csv');print('done')\"" > trait.workshop/data3$trait.sh
bash trait.workshop/data3$trait.sh