Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Kunstler Georges
traitcompet
Commits
98657240
Commit
98657240
authored
Apr 22, 2014
by
Georges Kunstler
Browse files
start explore results with MAT and CAT
parent
6fd5b3c4
Changes
15
Hide whitespace changes
Inline
Side-by-side
R/analysis/lmer.nolog.all.output.figs.R
View file @
98657240
#!/usr/bin/env Rscript
rm
(
list
=
ls
())
source
(
"R/analysis/lmer.output-fun.R"
)
source
(
"R/analysis/lmer.run.nolog.all.R"
)
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
list.all.results
<-
readRDS
(
'output/list.lmer.out.no.log.all.temp.rds'
)
list.all.results
<-
readRDS
(
'output/list.lmer.out.nolog.all.old.rds'
)
list.all.results
<-
readRDS
(
'output/list.lmer.out.nolog.all.rds'
)
names.param
<-
unique
(
unlist
(
lapply
(
list.all.results
,
function
(
x
)
names
(
x
$
lmer.summary
$
fixed.coeff.E
))))
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"
...
...
@@ -33,8 +48,8 @@ print(pander(res))
## plot the parameters
pdf
(
'figs/param.global.model.ER.AD.pdf'
)
par
(
mfrow
=
c
(
2
,
2
))
par
(
mfrow
=
c
(
2
,
2
))
for
(
i
in
c
(
'Wood.density'
,
'SLA'
,
'Leaf.N'
,
'Max.height'
)){
DF.t
<-
DF.global
[
DF.global
$
trait
==
i
,
]
print
(
i
)
...
...
@@ -53,11 +68,11 @@ fun.plot.error.bar(1:length(param.vec),
dev.off
()
par
(
mfrow
=
c
(
2
,
2
))
for
(
i
in
c
(
'Wood.density'
,
'SLA'
,
'Leaf.N'
,
'Max.height'
)){
DF.t
<-
DF.global
[
DF.global
$
trait
==
i
,
]
print
(
i
)
param.vec
<-
c
(
"Tf"
,
'MAT.Tf'
,
'MAP.Tf'
,
"logD"
,
"sumBn"
,
'MAT.sumBn'
,
'MAP.sumBn'
,
param.vec
<-
c
(
"Tf"
,
'MAT.Tf'
,
'MAP.Tf'
,
'MAT'
,
'MAP'
,
"logD"
,
"sumBn"
,
'MAT.sumBn'
,
'MAP.sumBn'
,
"sumTnBn"
,
'MAT.sumTnBn'
,
'MAP.sumTnBn'
,
"sumTfBn"
,
'MAT.sumTfBn'
,
'MAP.sumTfBn'
,
"sumTnTfBn.abs"
,
'MAT.sumTnTfBn.abs'
,
'MAP.sumTnTfBn.abs'
)
...
...
@@ -73,3 +88,26 @@ fun.plot.error.bar(1:length(param.vec),
}
## cat
## TODO
par
(
mfrow
=
c
(
2
,
2
))
for
(
i
in
c
(
'Wood.density'
,
'SLA'
,
'Leaf.N'
,
'Max.height'
)){
DF.t
<-
DF.global
[
DF.global
$
trait
==
i
,
]
print
(
i
)
param.vec
<-
c
(
"Tf.A_EV"
,
"Tf.A_D"
,
'Tf.C'
,
"logD"
,
"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.norandom'
plot
(
unlist
(
DF.t
[
DF.t
$
model
==
mode.selected
,
param.vec
]),
xaxt
=
'n'
,
ylab
=
'std parameters'
,
xlab
=
NA
,
main
=
i
,
ylim
=
c
(
-1
,
1
))
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
])
}
R/analysis/lmer.output-fun.R
View file @
98657240
...
...
@@ -620,11 +620,17 @@ return(list(sp = list.sp, ge = list.ge))
## start code to predict regression line with CI
library
(
lme4
)
library
(
ggplot2
)
# Plotting
data
(
"Orthodont"
,
package
=
"MEMSS"
)
fm1
<-
lmer
(
formula
=
distance
~
age
*
Sex
+
(
age
|
Subject
)
,
data
=
Orthodont
)
## library(ggplot2) # Plotting
## data("Orthodont",package="MEMSS")
## fm1 <- lmer(
## formula = distance ~ age*Sex + (age|Subject)
## , data = Orthodont)
## df.lmer <- load.and.prepare.data.for.lmer(trait = 'Wood.density',
## min.obs = 10, sample.size = NA,
## type.filling = 'species',
## fname = 'data.all.no.std.csv',
## cat.TF = FALSE)
fun.prepare.data.pred
<-
function
(
data
,
var
,
n.length
=
100
){
...
...
@@ -649,24 +655,94 @@ return(new.data)
fun.predict.ci.lmer
<-
function
(
fm
,
newdata
){
mm
<-
model.matrix
(
terms
(
fm1
),
newdat
)
newdat
$
distance
<-
mm
%*%
fixef
(
fm1
)
pvar1
<-
diag
(
mm
%*%
tcrossprod
(
vcov
(
fm1
),
mm
))
newdat
<-
data.frame
(
newdat
,
plo
=
newdat
$
distance
-1.96
*
sqrt
(
pvar1
),
phi
=
newdat
$
distance
+1.96
*
sqrt
(
pvar1
))
return
(
newdat
)
fun.predict.ci.lmer
<-
function
(
fm
,
newdat
,
param
,
param.var
){
newdat
[[
param
]]
<-
1
mm
<-
model.matrix
(
terms
(
fm
),
newdat
)
mm2
<-
mm
mm2
[,
!
colnames
(
mm2
)
%in%
c
(
param
,
param.var
)]
<-
0
pred
<-
(
mm2
%*%
fixef
(
fm
))
/
mean
(
mm
[,
param
])
pvar1
<-
diag
(
mm2
%*%
tcrossprod
(
vcov
(
fm
),
mm
))
dat
<-
data.frame
(
pred
=
pred
,
plo
=
pred
-1.96
*
sqrt
(
pvar1
),
phi
=
pred
+1.96
*
sqrt
(
pvar1
))
return
(
dat
)
}
## newdat <- fun.prepare.data.pred(data = df.lmer, 'MAT', n.length= 100)
## newdat <- fun.predict.ci.lmer(fm.MAT.MAP, newdat, param = 'sumTfBn', param.var = 'MAT:sumTfBn')
fun.generate.pred.dat
<-
function
(
n.length
=
100
){
list.res.MAT
<-
list
(
logG
=
0
,
logD
=
0
,
MAT
=
seq
(
-1.89
,
2.84
,
length
=
n.length
),
MAP
=
0
,
species.id
=
1
,
tree.id
=
1
,
set.id
=
1
,
ecocode.id
=
1
,
plot.id
=
1
,
sumTnTfBn.diff
=
0
,
sumTnTfBn.abs
=
0
,
Tf
=
0
,
sumTnBn
=
0
,
sumTfBn
=
0
,
sumBn
=
0
)
list.res.MAP
<-
list
(
logG
=
0
,
logD
=
0
,
MAT
=
0
,
MAP
=
seq
(
-1.36
,
4.02
,
length
=
n.length
),
species.id
=
1
,
tree.id
=
1
,
set.id
=
1
,
ecocode.id
=
1
,
plot.id
=
1
,
sumTnTfBn.diff
=
0
,
sumTnTfBn.abs
=
0
,
Tf
=
0
,
sumTnBn
=
0
,
sumTfBn
=
0
,
sumBn
=
0
)
new.data.MAT
<-
expand.grid
(
list.res.MAT
)
new.data.MAP
<-
expand.grid
(
list.res.MAP
)
list.new.data
<-
list
(
MAT
=
new.data.MAT
,
MAP
=
new.data.MAP
)
return
(
list.new.data
)
}
plot.fun.ci.param.var.climate
<-
function
(
fm
,
trait
,
param.vec
,
var.vec
,
n.length
=
100
){
list.new.data
<-
fun.generate.pred.dat
(
n.length
=
100
)
par
(
mfrow
=
c
(
length
(
var.vec
),
length
(
param.vec
)))
for
(
var
in
var.vec
){
newdat
<-
list.new.data
[[
var
]]
for
(
param
in
param.vec
){
param.var
=
paste
(
var
,
param
,
sep
=
':'
)
if
(
param
==
'Tf'
)
param.var
=
paste
(
param
,
var
,
sep
=
':'
)
dat.pred
<-
fun.predict.ci.lmer
(
fm.MAT.MAP
,
newdat
,
param
,
param.var
)
plot
(
newdat
[[
var
]],
dat.pred
$
pred
,
type
=
'l'
,
ylim
=
c
(
-1
,
1
),
xlab
=
var
,
ylab
=
param
)
lines
(
newdat
[[
var
]],
dat.pred
$
plo
,
lty
=
2
)
lines
(
newdat
[[
var
]],
dat.pred
$
phi
,
lty
=
2
)
abline
(
h
=
0
,
lwd
=
2
)
param.est
<-
fixef
(
fm
)
param.sd
<-
sqrt
(
diag
(
vcov
(
fm
)))
names
(
param.sd
)
<-
names
(
param.est
)
abline
(
h
=
param.est
[
param
],
col
=
'grey'
)
abline
(
h
=
param.est
[
param
]
+
1.96
*
param.sd
[
param
],
lty
=
2
,
col
=
'grey'
)
abline
(
h
=
param.est
[
param
]
-
1.96
*
param.sd
[
param
],
lty
=
2
,
col
=
'grey'
)
}
}
}
newdat
<-
fun.prepare.data.pred
(
data
=
newdat
,
'age'
)
newdat
<-
fun.predict.ci.lmer
(
fm1
,
newdat
)
## TODO TES THAT !
#plot confidence
## # test
## fm.MAT.MAP <- readRDS('output/lmer/all.no.log/Wood.density/species/lmer.LOGLIN.ER.AD.Tf.MAT.MAP/results.nolog.all.rds')
## fun.ci.param.var.climate(fm.MAT.MAP, 'Wood.density', param = 'sumTfBn', var = 'MAT')
g0
<-
ggplot
(
newdat
,
aes
(
x
=
age
,
y
=
distance
,
colour
=
Sex
))
+
geom_point
()
g0
+
geom_errorbar
(
aes
(
ymin
=
plo
,
ymax
=
phi
))
+
opts
(
title
=
"CI based on fixed-effects uncertainty ONLY"
)
R/analysis/lmer.run.nolog.all.R
View file @
98657240
...
...
@@ -3,26 +3,18 @@
### FUNCTION TO RUN LMER ESTIMATION WITH NO logBA for all in one big model
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
,
cat.TF
,
...
){
type.filling
,
cat.TF
=
FALSE
,
fname
=
'data.all.no.std.csv'
,
...
){
for
(
m
in
model.files
)
(
run.model.for.set.one.trait
(
m
,
fun.model
,
trait
,
type.filling
=
type.filling
,
cat.TF
=
cat.TF
,
...
))
type.filling
=
type.filling
,
cat.TF
=
cat.TF
,
fname
,
...
))
}
run.model.for.set.one.trait
<-
function
(
model.file
,
fun.model
,
trait
,
type.filling
,
cat.TF
,
...
){
type.filling
,
cat.TF
,
fname
,
...
){
fun.model
<-
match.fun
(
fun.model
)
try
(
fun.model
(
model.file
,
trait
,
type.filling
=
type.filling
,
cat.TF
=
cat.TF
,
...
))
try
(
fun.model
(
model.file
,
trait
,
type.filling
=
type.filling
,
cat.TF
=
cat.TF
,
fname
=
fname
,
...
))
}
...
...
@@ -51,8 +43,13 @@ model.files.lmer.Tf.4 <-
"R/analysis/model.lmer.all/model.lmer.LOGLIN.HD.Tf.MAT.MAP.R"
,
"R/analysis/model.lmer.all/model.lmer.LOGLIN.simplecomp.Tf.MAT.MAP.R"
)
model.files.lmer.Tf.5
<-
c
(
"R/analysis/model.lmer.all/model.lmer.LOGLIN.ER.AD.Tf.norandom.R"
)
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
)
)
)
...
...
@@ -118,8 +115,13 @@ 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.tree.tot
<-
fun.load.data.all
(
base.dir
,
fname
)
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
)
}
...
...
R/analysis/model.lmer.all/model.lmer.LOGLIN.E.Tf.MAT.MAP.R
View file @
98657240
load.model
<-
function
()
{
list
(
name
=
"lmer.LOGLIN.E.Tf.MAT.MAP"
,
lmer.formula.tree.id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+Tf:MAT+Tf:MAP+
logD+
MAT+MAP+sumBn+sumBn:MAT+sumBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)"
)
)
lmer.formula.tree.id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+Tf:MAT+Tf:MAP+MAT+MAP+
logD+
sumBn+sumBn:MAT+sumBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)"
)
)
}
...
...
R/analysis/model.lmer.all/model.lmer.LOGLIN.ER.AD.Tf
deleted
100644 → 0
View file @
6fd5b3c4
load
.
model
<-
function
()
{
list
(
name
=
"lmer.LOGLIN.ER.Tf"
,
lmer
.
formula
.
tree
.
id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+logD+sumTfBn+sumBn+sumTnBn+sumTnTfBn.abs+(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)"
))
}
R/analysis/model.lmer.all/model.lmer.LOGLIN.ER.AD.Tf.CAT.norandom.R
View file @
98657240
load.model
<-
function
()
{
list
(
name
=
"lmer.LOGLIN.ER.AD.Tf.norandom"
,
lmer.formula.tree.id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf.A_EV+Tf.A_D+Tf.C+logD+sumTfBn.A_EV+sumTfBn.A_D+sumTfBn.C+
sumBn+
sumTnBn.A_EV+sumTnBn.A_D+sumTnBn.C+sumTnTfBn.abs.A_EV+sumTnTfBn.abs.A_D+sumTnTfBn.abs.C+(logD-1|species.id)"
))
list
(
name
=
"lmer.LOGLIN.ER.AD.Tf.
CAT.
norandom"
,
lmer.formula.tree.id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf.A_EV+Tf.A_D+Tf.C+logD+
sumBn+
sumTfBn.A_EV+sumTfBn.A_D+sumTfBn.C+sumTnBn.A_EV+sumTnBn.A_D+sumTnBn.C+sumTnTfBn.abs.A_EV+sumTnTfBn.abs.A_D+sumTnTfBn.abs.C+(logD-1|species.id)"
))
}
...
...
R/analysis/model.lmer.all/model.lmer.LOGLIN.ER.AD.Tf.MAT.MAP.R
View file @
98657240
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+Tf:MAT+Tf:MAP+MAT+MAP+logD+sumBn+sumBn:MAT+sumBn:MAP+sumTfBn+sumTfBn:MAT+sumTfBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+sumTnTfBn.abs+sumTnTfBn.abs:MAT+sumTnTfBn.abs:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sum
Tf
Bn-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)+(sumTnTfBn.abs-1|set.id)"
))
lmer.formula.tree.id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+Tf:MAT+Tf:MAP+MAT+MAP+logD+sumBn+sumBn:MAT+sumBn:MAP+sumTfBn+sumTfBn:MAT+sumTfBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+sumTnTfBn.abs+sumTnTfBn.abs:MAT+sumTnTfBn.abs:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sum
Tf
Bn-1|set.id)+(sumTnBn-1|set.id)+(sumTnTfBn.abs-1|set.id)"
))
}
...
...
R/analysis/model.lmer.all/model.lmer.LOGLIN.ER.AD.Tf.R
View file @
98657240
load.model
<-
function
()
{
list
(
name
=
"lmer.LOGLIN.ER.AD.Tf"
,
lmer.formula.tree.id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+logD+sum
Tf
Bn+sumBn+sumTnBn+sumTnTfBn.abs+(logD-1|species.id)+(Tf-1|set.id)+(sum
Tf
Bn-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)+(sumTnTfBn.abs-1|set.id)"
))
lmer.formula.tree.id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+logD+sumBn+sum
Tf
Bn+sumTnBn+sumTnTfBn.abs+(logD-1|species.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sum
Tf
Bn-1|set.id)+(sumTnBn-1|set.id)+(sumTnTfBn.abs-1|set.id)"
))
}
...
...
R/analysis/model.lmer.all/model.lmer.LOGLIN.ER.Tf.MAT.MAP.R
View file @
98657240
load.model
<-
function
()
{
list
(
name
=
"lmer.LOGLIN.ER.Tf.MAT.MAP"
,
lmer.formula.tree.id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+Tf:MAT+Tf:MAP+MAT+MAP+logD+sum
Tf
Bn+sum
Tf
Bn:MAT+sum
Tf
Bn:MAP+sumBn+sumBn:MAT+sumBn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sum
Tf
Bn-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)"
))
lmer.formula.tree.id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+Tf:MAT+Tf:MAP+MAT+MAP+logD+sumBn+sumBn:MAT+sumBn:MAP+sum
Tf
Bn+sum
Tf
Bn:MAT+sum
Tf
Bn:MAP+sumTnBn+sumTnBn:MAT+sumTnBn:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sum
Tf
Bn-1|set.id)+(sumTnBn-1|set.id)"
))
}
...
...
R/analysis/model.lmer.all/model.lmer.LOGLIN.ER.Tf.R
View file @
98657240
load.model
<-
function
()
{
list
(
name
=
"lmer.LOGLIN.ER.Tf"
,
lmer.formula.tree.id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+logD+sum
Tf
Bn+sumBn+sumTnBn+(logD-1|species.id)+(Tf-1|set.id)+(sum
Tf
Bn-1|set.id)+(sumBn-1|set.id)+(sumTnBn-1|set.id)"
))
lmer.formula.tree.id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+logD+sumBn+sum
Tf
Bn+sumTnBn+(logD-1|species.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sum
Tf
Bn-1|set.id)+(sumTnBn-1|set.id)"
))
}
R/analysis/model.lmer.all/model.lmer.LOGLIN.R.Tf.MAT.MAP.R
View file @
98657240
load.model
<-
function
()
{
list
(
name
=
"lmer.LOGLIN.R.Tf.MAT.MAP"
,
lmer.formula.tree.id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+
logD+
MAT+MAP+
sumBn+Tf:MAT+Tf:MAP
+sumBn:MAT+sumBn:MAP+sumTfBn+sumTfBn:MAT+sumTfBn:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTfBn-1|set.id)"
))
lmer.formula.tree.id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+
Tf:
MAT+
Tf:
MAP+
MAT+MAP+logD+sumBn
+sumBn:MAT+sumBn:MAP+sumTfBn+sumTfBn:MAT+sumTfBn:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sumBn-1|set.id)+(sumTfBn-1|set.id)"
))
}
...
...
R/analysis/model.lmer.all/model.lmer.LOGLIN.nocomp.Tf.MAT.MAP.R
View file @
98657240
load.model
<-
function
()
{
list
(
name
=
"lmer.LOGLIN.nocomp.Tf.MAT.MAP"
,
lmer.formula.tree.id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+
logD+MAT+MAP+
Tf:MAT+Tf:MAP+(logD-1|species.id)+(Tf-1|set.id)"
))
lmer.formula.tree.id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+Tf:MAT+Tf:MAP
+MAT+MAP+logD
+(logD-1|species.id)+(Tf-1|set.id)"
))
}
...
...
R/analysis/model.lmer.all/model.lmer.LOGLIN.simplecomp.Tf.MAT.MAP.R
View file @
98657240
load.model
<-
function
()
{
list
(
name
=
"lmer.LOGLIN.simplecomp.Tf.MAT.MAP"
,
lmer.formula.tree.id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+
logD+MAT+MAP+
Tf:MAT+Tf:MAP+sumBn+sumBn:MAT+sumBn:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sumBn-1|set.id)"
))
lmer.formula.tree.id
=
formula
(
"logG~1+(1|set.id)+(1|species.id)+(1|plot.id)+Tf+Tf:MAT+Tf:MAP
+MAT+MAP+logD
+sumBn+sumBn:MAT+sumBn:MAP+(logD-1|species.id)+(Tf-1|set.id)+(sumBn-1|set.id)"
))
}
...
...
R/utils/mem.R
View file @
98657240
...
...
@@ -10,3 +10,34 @@ mem <- function() {
usage
<-
gc
()
sum
(
usage
[,
1
]
*
c
(
node_size
,
8
))
/
(
1024
^
2
)
}
# improved list of objects
.ls.objects
<-
function
(
pos
=
1
,
pattern
,
order.by
,
decreasing
=
FALSE
,
head
=
FALSE
,
n
=
5
)
{
napply
<-
function
(
names
,
fn
)
sapply
(
names
,
function
(
x
)
fn
(
get
(
x
,
pos
=
pos
)))
names
<-
ls
(
pos
=
pos
,
pattern
=
pattern
)
obj.class
<-
napply
(
names
,
function
(
x
)
as.character
(
class
(
x
))[
1
])
obj.mode
<-
napply
(
names
,
mode
)
obj.type
<-
ifelse
(
is.na
(
obj.class
),
obj.mode
,
obj.class
)
obj.prettysize
<-
napply
(
names
,
function
(
x
)
{
capture.output
(
print
(
object.size
(
x
),
units
=
"auto"
))
})
obj.size
<-
napply
(
names
,
object.size
)
obj.dim
<-
t
(
napply
(
names
,
function
(
x
)
as.numeric
(
dim
(
x
))[
1
:
2
]))
vec
<-
is.na
(
obj.dim
)[,
1
]
&
(
obj.type
!=
"function"
)
obj.dim
[
vec
,
1
]
<-
napply
(
names
,
length
)[
vec
]
out
<-
data.frame
(
obj.type
,
obj.size
,
obj.prettysize
,
obj.dim
)
names
(
out
)
<-
c
(
"Type"
,
"Size"
,
"PrettySize"
,
"Rows"
,
"Columns"
)
if
(
!
missing
(
order.by
))
out
<-
out
[
order
(
out
[[
order.by
]],
decreasing
=
decreasing
),
]
if
(
head
)
out
<-
head
(
out
,
n
)
out
}
# shorthand
lsos
<-
function
(
...
,
n
=
10
)
{
.ls.objects
(
...
,
order.by
=
"Size"
,
decreasing
=
TRUE
,
head
=
TRUE
,
n
=
n
)
}
launch_all_lmer.nolog.global.bash
View file @
98657240
...
...
@@ -6,18 +6,24 @@ 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');;print('done')
\"
"
>
trait.workshop/species1
$trait
.sh
echo
"/usr/local/R/R-3.0.1/bin/Rscript -e
\"
source('R/analysis/lmer.run.nolog.all.R');
run.multiple.model.for.set.one.trait(model.files.lmer.Tf.1[3], run.lmer,
$trait
,type.filling='species', fname = 'data.all.csv');run.multiple.model.for.set.one.trait(model.files.lmer.Tf.1[3], run.lmer,
$trait
,type.filling='species')
;print('done')
\"
"
>
trait.workshop/species1
$trait
.sh
qsub trait.workshop/species1
$trait
.sh
-l
nodes
=
1:ppn
=
1
-N
"lmerall1
$trait
"
-q
opt32G
-j
oe
echo
"/usr/local/R/R-3.0.1/bin/Rscript -e
\"
source('R/analysis/lmer.run.nolog.all.R');run.multiple.model.for.set.one.trait(model.files.lmer.Tf.2[3], run.lmer,
$trait
,type.filling='species');print('done')
\"
"
>
trait.workshop/species2
$trait
.sh
echo
"/usr/local/R/R-3.0.1/bin/Rscript -e
\"
source('R/analysis/lmer.run.nolog.all.R');run.multiple.model.for.set.one.trait(model.files.lmer.Tf.2[3],
run.lmer,
$trait
,type.filling='species', fname = 'data.all.csv');run.multiple.model.for.set.one.trait(model.files.lmer.Tf.2[3],
run.lmer,
$trait
,type.filling='species');print('done')
\"
"
>
trait.workshop/species2
$trait
.sh
qsub trait.workshop/species2
$trait
.sh
-l
nodes
=
1:ppn
=
1
-N
"lmerall2
$trait
"
-q
opt32G
-j
oe
echo
"/usr/local/R/R-3.0.1/bin/Rscript -e
\"
source('R/analysis/lmer.run.nolog.all.R');run.multiple.model.for.set.one.trait(model.files.lmer.Tf.3[3], run.lmer,
$trait
,type.filling='species');print('done')
\"
"
>
trait.workshop/species3
$trait
.sh
echo
"/usr/local/R/R-3.0.1/bin/Rscript -e
\"
source('R/analysis/lmer.run.nolog.all.R');run.multiple.model.for.set.one.trait(model.files.lmer.Tf.3[3],
run.lmer,
$trait
,type.filling='species', fname = 'data.all.csv');run.multiple.model.for.set.one.trait(model.files.lmer.Tf.3[3],
run.lmer,
$trait
,type.filling='species');print('done')
\"
"
>
trait.workshop/species3
$trait
.sh
qsub trait.workshop/species3
$trait
.sh
-l
nodes
=
1:ppn
=
1
-N
"lmerall3
$trait
"
-q
opt32G
-j
oe
echo
"/usr/local/R/R-3.0.1/bin/Rscript -e
\"
source('R/analysis/lmer.run.nolog.all.R');run.multiple.model.for.set.one.trait(model.files.lmer.Tf.4[3], run.lmer,
$trait
,type.filling='species');print('done')
\"
"
>
trait.workshop/species4
$trait
.sh
echo
"/usr/local/R/R-3.0.1/bin/Rscript -e
\"
source('R/analysis/lmer.run.nolog.all.R');run.multiple.model.for.set.one.trait(model.files.lmer.Tf.4[3],
run.lmer,
$trait
,type.filling='species', fname = 'data.all.csv');run.multiple.model.for.set.one.trait(model.files.lmer.Tf.4[3],
run.lmer,
$trait
,type.filling='species');print('done')
\"
"
>
trait.workshop/species4
$trait
.sh
qsub trait.workshop/species4
$trait
.sh
-l
nodes
=
1:ppn
=
1
-N
"lmerall4
$trait
"
-q
opt32G
-j
oe
echo
"/usr/local/R/R-3.0.1/bin/Rscript -e
\"
source('R/analysis/lmer.run.nolog.all.R');run.multiple.model.for.set.one.trait(model.files.lmer.Tf.5, run.lmer,
$trait
,type.filling='species', fname = 'data.all.csv');run.multiple.model.for.set.one.trait(model.files.lmer.Tf.5, run.lmer,
$trait
,type.filling='species');print('done')
\"
"
>
trait.workshop/species5
$trait
.sh
qsub trait.workshop/species5
$trait
.sh
-l
nodes
=
1:ppn
=
1
-N
"lmerall5
$trait
"
-q
opt32G
-j
oe
echo
"/usr/local/R/R-3.0.1/bin/Rscript -e
\"
source('R/analysis/lmer.run.nolog.all.R');run.multiple.model.for.set.one.trait(model.files.lmer.Tf.6, run.lmer,
$trait
,type.filling='species', cat.TF = TRUE, fname = 'data.all.csv');run.multiple.model.for.set.one.trait(model.files.lmer.Tf.6, run.lmer,
$trait
,type.filling='species', cat.TF = TRUE);print('done')
\"
"
>
trait.workshop/species6
$trait
.sh
qsub trait.workshop/species6
$trait
.sh
-l
nodes
=
1:ppn
=
1
-N
"lmerall6
$trait
"
-q
opt32G
-j
oe
done
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment