Commit 1c7099dc authored by Georges Kunstler's avatar Georges Kunstler
Browse files

new makefile for global

No related merge requests found
Showing with 90 additions and 63 deletions
+90 -63
...@@ -26,7 +26,7 @@ $(D2)/TRY/data.TRY.std.rds: ...@@ -26,7 +26,7 @@ $(D2)/TRY/data.TRY.std.rds:
GLOBAL: $(D3)/Done.txt 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 $(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
#------------------------------------------------------- #-------------------------------------------------------
......
...@@ -142,40 +142,6 @@ countsup.LeafN # 34 ...@@ -142,40 +142,6 @@ countsup.LeafN # 34
countsup.SLA # 34 countsup.SLA # 34
countsup.WSG # 0 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 data.species.4 <- data.species.3
#============================================================= #=============================================================
# WSG with Dryad # WSG with Dryad
...@@ -291,6 +257,46 @@ data.traits <- merge(data.traits, ...@@ -291,6 +257,46 @@ data.traits <- merge(data.traits,
data.cat.extract[,c("sp","Phylo.group","Pheno.T")], data.cat.extract[,c("sp","Phylo.group","Pheno.T")],
by="sp") 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 ## compute perc of traits cover per species
print(sapply(c('Leaf.N','SLA','Seed.mass','Wood.density','Max.height'), print(sapply(c('Leaf.N','SLA','Seed.mass','Wood.density','Max.height'),
fun.compute.perc.cover.one.trait,data.traits)) fun.compute.perc.cover.one.trait,data.traits))
......
...@@ -20,31 +20,6 @@ system.time(data.all <- fread(file.path(filedir, "data.all.csv"), ...@@ -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']])) if(dim(data.all)[1] != sum(mat.perc[['num.obs']]))
stop('error not same dimension per ecoregion and total') 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 ### TODO
...@@ -68,7 +43,7 @@ boxplot(data.all$BATOT ~ data.all$set, las = 3) ...@@ -68,7 +43,7 @@ boxplot(data.all$BATOT ~ data.all$set, las = 3)
system.time(data.summarise <- fun.compute.all.var.cluster(data.all)) 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)) par(mfrow=c(1,2))
plot(data.summarise$MAP,data.summarise$BATOT, plot(data.summarise$MAP,data.summarise$BATOT,
,col=col.vec[data.summarise$set],cex=0.1) ,col=col.vec[data.summarise$set],cex=0.1)
......
...@@ -5,5 +5,5 @@ source('R/process.data/process-fun.R') ...@@ -5,5 +5,5 @@ source('R/process.data/process-fun.R')
set.big <- c('Fushan', 'Paracou', 'BCI', 'Mbaiki', 'Luquillo', 'Japan') set.big <- c('Fushan', 'Paracou', 'BCI', 'Mbaiki', 'Luquillo', 'Japan')
set.inv <- c('Spain', 'Sweden', 'Canada', 'France', 'Swiss', 'NSW', 'NVS', 'US') 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.big) 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.inv) process_inventory_dataset(i, std.traits = 'global')
...@@ -44,3 +44,49 @@ data.all$obs.id <- paste(data.all$ecocode,data.all$obs.id) ...@@ -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) 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")
Supports Markdown
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