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
1c7099dc
Commit
1c7099dc
authored
Mar 15, 2014
by
Georges Kunstler
Browse files
new makefile for global
parent
c58f583a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
1c7099dc
...
...
@@ -26,7 +26,7 @@ $(D2)/TRY/data.TRY.std.rds:
GLOBAL
:
$(D3)/Done.txt
$(D3)/Done.txt
:
R/process.data/global.R R/process.data/process-fun.R $(D2)/traits.std.global.csv $(D5)/Done.txt
Rscript
$<
Rscript
$<
;
Rscript R/process.data/merge.all.processed.data.R
#-------------------------------------------------------
...
...
R/find.trait/Mbaiki.R
View file @
1c7099dc
...
...
@@ -142,40 +142,6 @@ countsup.LeafN # 34
countsup.SLA
# 34
countsup.WSG
# 0
## #=============================================================
## # Phenology
## d.pheno <- read.csv2(file="data/raw/Mbaiki/getpheno_cofortraits_20140212.csv",header=TRUE)
## dim(d.pheno)
## names(d.pheno)[8] <- "pheno"
## head(d.pheno)
## head(data.species.3)
## Species.Name.From.List <- function (x) {
## genus <- x[1]
## sp <- x[2]
## lb <- paste(genus,sp,sep=" ")
## return(lb)
## }
## d.pheno$latin.binomial <- c(unlist(lapply(strsplit(as.character(d.pheno$species),split=" "),Species.Name.From.List)))
## Unique.Paste <- function (x) {
## r <- paste(unique(x),collapse=" ")
## return(r)
## }
## Mat.Pheno <- as.data.frame(tapply(as.character(d.pheno$pheno),d.pheno$latin.binomial,Unique.Paste))
## Mat.Pheno$latin.binomial <- row.names(Mat.Pheno)
## row.names(Mat.Pheno) <- NULL
## names(Mat.Pheno) <- c("D_EV","latin.binomial")
## Mat.Pheno$D_EV <- as.character(Mat.Pheno$D_EV)
## str(Mat.Pheno)
## # Set leaf-exchanger to evergreen
## w <- grep("leaf-exchanger",Mat.Pheno$D_EV)
## Mat.Pheno$D_EV[w] <- "EV"
## Mat.Pheno$D_EV[Mat.Pheno$D_EV=="decidue"] <- "D"
## Mat.Pheno$D_EV[Mat.Pheno$D_EV=="sempervirente"] <- "EV"
## Mat.Pheno$D_EV[!(Mat.Pheno$D_EV %in% c("D","EV"))] <- NA
## # Merge
## data.species.4 <- merge(data.species.3,Mat.Pheno,
## by.x="Species",by.y="latin.binomial",all.x=TRUE)
data.species.4
<-
data.species.3
#=============================================================
# WSG with Dryad
...
...
@@ -291,6 +257,46 @@ data.traits <- merge(data.traits,
data.cat.extract
[,
c
(
"sp"
,
"Phylo.group"
,
"Pheno.T"
)],
by
=
"sp"
)
#=============================================================
# Phenology
d.pheno
<-
read.csv2
(
file
=
"data/raw/Mbaiki/getpheno_cofortraits_20140212.csv"
,
header
=
TRUE
)
dim
(
d.pheno
)
names
(
d.pheno
)[
8
]
<-
"pheno"
head
(
d.pheno
)
head
(
data.species.3
)
Species.Name.From.List
<-
function
(
x
)
{
genus
<-
x
[
1
]
sp
<-
x
[
2
]
lb
<-
paste
(
genus
,
sp
,
sep
=
" "
)
return
(
lb
)
}
d.pheno
$
latin.binomial
<-
c
(
unlist
(
lapply
(
strsplit
(
as.character
(
d.pheno
$
species
),
split
=
" "
),
Species.Name.From.List
)))
Unique.Paste
<-
function
(
x
)
{
r
<-
paste
(
unique
(
x
),
collapse
=
" "
)
return
(
r
)
}
Mat.Pheno
<-
as.data.frame
(
tapply
(
as.character
(
d.pheno
$
pheno
),
d.pheno
$
latin.binomial
,
Unique.Paste
))
Mat.Pheno
$
latin.binomial
<-
row.names
(
Mat.Pheno
)
row.names
(
Mat.Pheno
)
<-
NULL
names
(
Mat.Pheno
)
<-
c
(
"D_EV"
,
"latin.binomial"
)
Mat.Pheno
$
D_EV
<-
as.character
(
Mat.Pheno
$
D_EV
)
str
(
Mat.Pheno
)
# Set leaf-exchanger to evergreen
w
<-
grep
(
"leaf-exchanger"
,
Mat.Pheno
$
D_EV
)
Mat.Pheno
$
D_EV
[
w
]
<-
"EV"
Mat.Pheno
$
D_EV
[
Mat.Pheno
$
D_EV
==
"decidue"
]
<-
"D"
Mat.Pheno
$
D_EV
[
Mat.Pheno
$
D_EV
==
"sempervirente"
]
<-
"EV"
Mat.Pheno
$
D_EV
[
!
(
Mat.Pheno
$
D_EV
%in%
c
(
"D"
,
"EV"
))]
<-
NA
names
(
Mat.Pheno
)
<-
c
(
'D_EV'
,
'Latin_name'
)
# Merge
data.traits
<-
merge
(
data.traits
,
Mat.Pheno
,
by
=
"Latin_name"
,
all.x
=
TRUE
,
all.y
=
FALSE
)
#
data.traits
$
Pheno.T
[
!
is.na
(
data.traits
$
D_EV
)]
<-
data.traits
$
D_EV
[
!
is.na
(
data.traits
$
D_EV
)]
data.traits
$
D_EV
<-
NULL
## compute perc of traits cover per species
print
(
sapply
(
c
(
'Leaf.N'
,
'SLA'
,
'Seed.mass'
,
'Wood.density'
,
'Max.height'
),
fun.compute.perc.cover.one.trait
,
data.traits
))
...
...
R/process.data/explore.processed.data.R
View file @
1c7099dc
...
...
@@ -20,31 +20,6 @@ system.time(data.all <- fread(file.path(filedir, "data.all.csv"),
if
(
dim
(
data.all
)[
1
]
!=
sum
(
mat.perc
[[
'num.obs'
]]))
stop
(
'error not same dimension per ecoregion and total'
)
## plots
fun.plot.hist.trait.per.set
(
data.all
)
to.pdf
(
fun.hist.var.set
(
data.all
,
var
=
'BATOT'
,
cex
=
0.6
),
filename
=
"figs/test.processed/fig.BATOT.set.pdf"
)
to.pdf
(
fun.hist.var.set
(
data.all
,
var
=
'G'
,
cex
=
0.6
),
filename
=
"figs/test.processed/fig.G.set.pdf"
)
to.pdf
(
fun.hist.var.set
(
data.all
,
var
=
'BA.G'
,
cex
=
0.6
),
filename
=
"figs/test.processed/fig.BA.G.set.pdf"
)
to.pdf
(
fun.hist.var.set
(
data.all
,
var
=
'D'
,
cex
=
0.6
),
filename
=
"figs/test.processed/fig.D.set.pdf"
)
to.dev
(
fun.plot.xy.set
(
data.all
,
var.x
=
'BATOT'
,
var.y
=
'BA.G'
,
cex
=
0.6
),
dev
=
png
,
filename
=
"figs/test.processed/fig.xy.BATOT.BA.G.set.png"
)
to.dev
(
fun.plot.xy.set
(
data.all
,
var.x
=
'D'
,
var.y
=
'BA.G'
,
cex
=
0.6
),
dev
=
png
,
filename
=
"figs/test.processed/fig.xy.D.BA.G.set.png"
)
to.dev
(
fun.plot.xy.set
(
data.all
,
var.x
=
'D'
,
var.y
=
'G'
,
cex
=
0.6
,
col
=
col.vec
[
data.all
$
set
]),
dev
=
png
,
filename
=
"figs/test.processed/fig.xy.D.G.set.png"
)
to.dev
(
fun.plot.xy.set
(
data.all
,
var.x
=
'BATOT'
,
var.y
=
'G'
,
cex
=
0.6
),
dev
=
png
,
filename
=
"figs/test.processed/fig.xy.BATOT.G.set.png"
)
########
### TODO
...
...
@@ -68,7 +43,7 @@ boxplot(data.all$BATOT ~ data.all$set, las = 3)
system.time
(
data.summarise
<-
fun.compute.all.var.cluster
(
data.all
))
### NEED TO CHECK WHY JAPAN REACH 300 of BATOT
### NEED TO CHECK WHY JAPAN REACH 300 of BATOT
par
(
mfrow
=
c
(
1
,
2
))
plot
(
data.summarise
$
MAP
,
data.summarise
$
BATOT
,
,
col
=
col.vec
[
data.summarise
$
set
],
cex
=
0.1
)
...
...
R/process.data/global.R
View file @
1c7099dc
...
...
@@ -5,5 +5,5 @@ source('R/process.data/process-fun.R')
set.big
<-
c
(
'Fushan'
,
'Paracou'
,
'BCI'
,
'Mbaiki'
,
'Luquillo'
,
'Japan'
)
set.inv
<-
c
(
'Spain'
,
'Sweden'
,
'Canada'
,
'France'
,
'Swiss'
,
'NSW'
,
'NVS'
,
'US'
)
for
(
i
in
set.bi
)
process_bigplot_dataset
(
i
,
Rlim
=
15
,
std.traits
=
'global'
)
for
(
i
in
set.in
)
process_inventory_dataset
(
i
,
std.traits
=
'global'
)
for
(
i
in
set.bi
g
)
process_bigplot_dataset
(
i
,
Rlim
=
15
,
std.traits
=
'global'
)
for
(
i
in
set.in
v
)
process_inventory_dataset
(
i
,
std.traits
=
'global'
)
R/process.data/merge.all.processed.data.R
View file @
1c7099dc
...
...
@@ -44,3 +44,49 @@ data.all$obs.id <- paste(data.all$ecocode,data.all$obs.id)
write.csv
(
data.all
,
file
=
file.path
(
filedir
,
"data.all.csv"
),
row.names
=
FALSE
)
cat
(
"finished"
,
file
=
file.path
(
filedir
,
"Done.txt"
))
#######################################
#######################################
## plots
fun.plot.hist.trait.per.set
(
data.all
)
pdf
(
"figs/test.processed/boxplot.pdf"
)
boxplot
(
BATOT
~
set
,
data
=
data.all
,
las
=
3
)
boxplot
(
D
~
set
,
data
=
data.all
,
las
=
3
)
boxplot
(
D
~
set
,
data
=
data.all
,
las
=
3
)
boxplot
(
BA.G
~
set
,
data
=
data.all
,
las
=
3
)
par
(
mar
=
c
(
10
,
4
,
4
,
4
))
barplot
(
tapply
((
data.all
$
Pheno.T
==
'D'
),
data.all
$
ecocode
,
function
(
x
)
sum
(
x
,
na.rm
=
TRUE
)
/
length
(
x
)),
las
=
3
,
yaln
=
'perc d'
)
par
(
mar
=
c
(
10
,
4
,
4
,
4
))
barplot
(
tapply
((
data.all
$
Phylo.group
==
'Gymnosperm'
),
data.all
$
ecocode
,
function
(
x
)
sum
(
x
,
na.rm
=
TRUE
)
/
length
(
x
)),
las
=
3
,
yaln
=
'perc gym'
)
dev.off
()
to.pdf
(
fun.hist.var.set
(
data.all
,
var
=
'BATOT'
,
cex
=
0.6
),
filename
=
"figs/test.processed/fig.BATOT.set.pdf"
)
to.pdf
(
fun.hist.var.set
(
data.all
,
var
=
'G'
,
cex
=
0.6
),
filename
=
"figs/test.processed/fig.G.set.pdf"
)
to.pdf
(
fun.hist.var.set
(
data.all
,
var
=
'BA.G'
,
cex
=
0.6
),
filename
=
"figs/test.processed/fig.BA.G.set.pdf"
)
to.pdf
(
fun.hist.var.set
(
data.all
,
var
=
'D'
,
cex
=
0.6
),
filename
=
"figs/test.processed/fig.D.set.pdf"
)
to.dev
(
fun.plot.xy.set
(
data.all
,
var.x
=
'BATOT'
,
var.y
=
'BA.G'
,
cex
=
0.6
),
dev
=
png
,
filename
=
"figs/test.processed/fig.xy.BATOT.BA.G.set.png"
)
to.dev
(
fun.plot.xy.set
(
data.all
,
var.x
=
'D'
,
var.y
=
'BA.G'
,
cex
=
0.6
),
dev
=
png
,
filename
=
"figs/test.processed/fig.xy.D.BA.G.set.png"
)
to.dev
(
fun.plot.xy.set
(
data.all
,
var.x
=
'D'
,
var.y
=
'G'
,
cex
=
0.6
,
col
=
col.vec
[
data.all
$
set
]),
dev
=
png
,
filename
=
"figs/test.processed/fig.xy.D.G.set.png"
)
to.dev
(
fun.plot.xy.set
(
data.all
,
var.x
=
'BATOT'
,
var.y
=
'G'
,
cex
=
0.6
),
dev
=
png
,
filename
=
"figs/test.processed/fig.xy.BATOT.G.set.png"
)
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