setwd("~/Google Drive/Agrosavia/Colaboraciones/Fabricio/Peso_hojas")
## There is a fundamental tradeoff between specific leaf area (SLA, the ratio of leaf area to leaf dry mass)
## and leaf dry matter content (LDMC, the ratio of dry leaf mas to fresh mass). The tradeoff reflects a rapid production of vegetative biomass (high SLA, low LDMC) or
## efficient conservation of nutrients for reproductive tissues (low SLA, high LDMC) (Poorter and Garnier, 1999).
## We measured SLA and LDMC of three leaves per tree from three genotypes of cacao (10, 44, and 46) differing in photosynthesis (low, high, and medium, respectively) and
## production (low, medium, and high, respectively) to establish if higher production is related to high LDMC but low SLA values.
datos<-read.table("peso_hoja2.csv", sep = ",", header = T)
attach(datos)
datos.field<-subset(datos, trat=="field" )
detach(datos)
attach(datos.field)
arbol<-as.factor(arbol)
fit1<-aov(sla~gen)
fit2<-aov(ldmc~gen)
summary(fit1)
## Df Sum Sq Mean Sq F value Pr(>F)
## gen 2 259 129.4 0.859 0.436
## Residuals 24 3616 150.7
summary(fit2)
## Df Sum Sq Mean Sq F value Pr(>F)
## gen 2 0.01446 0.007231 10.07 0.000667 ***
## Residuals 24 0.01723 0.000718
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# diagnósticos SLA
layout(matrix(1:4,2,2))
plot(fit1)
## hat values (leverages) are all = 0.1111111
## and there are no factor predictors; no plot no. 5

layout(1)
# diagnósticos numérico
shapiro.test(resid(fit1))
##
## Shapiro-Wilk normality test
##
## data: resid(fit1)
## W = 0.9571, p-value = 0.3168
bartlett.test(resid(fit1)~gen)
##
## Bartlett test of homogeneity of variances
##
## data: resid(fit1) by gen
## Bartlett's K-squared = 0.96909, df = 2, p-value = 0.616
# diagnósticos LDMC
layout(matrix(1:4,2,2))
plot(fit2)
## hat values (leverages) are all = 0.1111111
## and there are no factor predictors; no plot no. 5

layout(1)
# diagnósticos numérico
shapiro.test(resid(fit2))
##
## Shapiro-Wilk normality test
##
## data: resid(fit2)
## W = 0.94603, p-value = 0.1715
bartlett.test(resid(fit2)~gen)
##
## Bartlett test of homogeneity of variances
##
## data: resid(fit2) by gen
## Bartlett's K-squared = 0.90866, df = 2, p-value = 0.6349
# Contraste de medias SLA
library(emmeans)
contrast <- emmeans(fit1, ~ gen)
plot(contrast, comparisons = TRUE, xlab ="SLA")

# Contraste de medias LDMC
library(emmeans)
contrast <- emmeans(fit2, ~ gen)
plot(contrast, comparisons = TRUE, xlab ="LDMC")

# Trade-off SLA vs LDMC
library("ggpubr")
## Loading required package: ggplot2
ggscatter(datos.field, x = "sla", y = "ldmc",
add = "reg.line", conf.int = F,
cor.coef = TRUE, cor.method = "pearson",
xlab = "SLA", ylab = "LDMC")
## `geom_smooth()` using formula 'y ~ x'

library(ggplot2)
# SLA
ggplot(datos, aes(trat, sla, group = gen, colour = gen)) +
stat_summary (aes(group = gen), fun.data = mean_se) +
stat_summary (aes(group = gen), fun = mean, geom = "line") +
labs(x = "treatment", y = "SLA") +
theme_linedraw() +
theme(
plot.title = element_text(hjust = 0.5, size = 20),
strip.text = element_text(size = 20),
axis.title.y = element_text(size = 20),
axis.title.x = element_text(size = 20),
axis.text.x = element_text(size = 14),
axis.text.y = element_text(size = 14)
) +
theme_classic()

# LDMC
ggplot(datos, aes(trat, ldmc, group = gen, colour = gen)) +
stat_summary (aes(group = gen), fun.data = mean_se) +
stat_summary (aes(group = gen), fun = mean, geom = "line") +
labs(x = "treatment", y = "LDMC") +
theme_linedraw() +
theme(
plot.title = element_text(hjust = 0.5, size = 20),
strip.text = element_text(size = 20),
axis.title.y = element_text(size = 20),
axis.title.x = element_text(size = 20),
axis.text.x = element_text(size = 14),
axis.text.y = element_text(size = 14)
) +
theme_classic()
