Preliminaries

sample size

data_color_merged %>%
  select(pop, pred_trt, tutor_pop) %>%
  ftable() 
##              tutor_pop solo AH AL
## pop pred_trt                     
## AH  N                    20 19 20
##     Y                    20 20 16
## AL  N                    20 20 20
##     Y                    21 20 19

Data processing for plotting

#prep dataset for facet wrap
data_long <- data_color_merged %>%

  select("pop","tutor_pop","pred_trt",
         
         "body_black_num", "body_black_area", "body_black_prop",
         "body_fuzzyblack_num", "body_fuzzyblack_area","body_fuzzyblack_prop",
         "body_melanin_num", "body_melanin_area","body_melanin_prop",
         "body_yellow_num", "body_yellow_area","body_yellow_prop",
         "body_orange_num", "body_orange_area","body_orange_prop",
         "body_xanthophore_num", "body_xanthophore_area", "body_xanthophore_prop",
         
         "tail_black_num", "tail_black_area", "tail_black_prop",
         "tail_fuzzyblack_num", "tail_fuzzyblack_area","tail_fuzzyblack_prop",
         "tail_melanin_num", "tail_melanin_area","tail_melanin_prop",
         "tail_yellow_num", "tail_yellow_area","tail_yellow_prop",
         "tail_orange_num", "tail_orange_area","tail_orange_prop",
         "tail_xanthophore_num", "tail_xanthophore_area", "tail_xanthophore_prop",
         
         "body_area","tail_area",'gono_resid') %>%
  
  pivot_longer(-c("pop", "tutor_pop", "pred_trt"),
               names_to = "variable",
               values_to = "value") %>%
  
  group_by(variable) %>%

  #reorder for neater plotting
  mutate(variable = as.factor(variable)) %>%
  mutate(variable = fct_relevel(variable,
         "body_black_num", "body_black_area", "body_black_prop",
         "body_fuzzyblack_num", "body_fuzzyblack_area","body_fuzzyblack_prop",
         "body_melanin_num", "body_melanin_area","body_melanin_prop",
         "body_yellow_num", "body_yellow_area","body_yellow_prop",
         "body_orange_num", "body_orange_area","body_orange_prop",
         "body_xanthophore_num", "body_xanthophore_area", "body_xanthophore_prop",
         
         "tail_black_num", "tail_black_area", "tail_black_prop",
         "tail_fuzzyblack_num", "tail_fuzzyblack_area","tail_fuzzyblack_prop",
         "tail_melanin_num", "tail_melanin_area","tail_melanin_prop",
         "tail_yellow_num", "tail_yellow_area","tail_yellow_prop",
         "tail_orange_num", "tail_orange_area","tail_orange_prop",
         "tail_xanthophore_num", "tail_xanthophore_area", "tail_xanthophore_prop",
         
         "body_area","tail_area",'gono_resid'))

HP vs LP, pooling all treatments

ggplot(data_long, aes(x =pop,fill = pop, y = value)) + 
  geom_boxplot() + facet_wrap(variable ~., scales = 'free', ncol = 3) +
    theme_bw() + theme(panel.grid.major = element_blank(),
                       panel.grid.minor = element_blank()) +
    scale_fill_manual(values=c("steelblue", "lightsalmon1" ))

HP, plot by predator and social treatment

ggplot(data_long %>% filter(pop=="AH"), 
       aes(x =tutor_pop ,fill = pred_trt, y = value)) + 
  geom_boxplot() + facet_wrap(variable ~., scales = 'free', ncol = 3) +
    theme_bw() + theme(panel.grid.major = element_blank(),
                       panel.grid.minor = element_blank()) +
    scale_fill_manual(values=c("lightsalmon1", "steelblue" ))

LP, plot by predator and social treatment

ggplot(data_long %>% filter(pop=="AL"), 
       aes(x =tutor_pop ,fill = pred_trt, y = value)) + 
  geom_boxplot() + facet_wrap(variable ~., scales = 'free', ncol = 3) +
    theme_bw() + theme(panel.grid.major = element_blank(),
                       panel.grid.minor = element_blank()) +
    scale_fill_manual(values=c("lightsalmon1", "steelblue" ))

HP vs LP, listing all treatments

ggplot(data_long,
       aes(x =tutor_pop:pred_trt ,fill = pop, y = value)) + 
  geom_boxplot() + facet_wrap(variable ~., scales = 'free', ncol = 3) +
    theme_bw() + theme(panel.grid.major = element_blank(),
                       panel.grid.minor = element_blank(),
                       legend.position = "top") +
    scale_fill_manual(values=c("steelblue","lightsalmon1" )) 

Correlation among colors and gonopodia

data_cor <- data_color_merged %>%
  gather(variable, value,
         body_melanin_prop, tail_melanin_prop, body_xanthophore_prop, tail_xanthophore_prop)
ggplot(data_cor, aes(x = value, y = gono_resid, color = pop, fill = pop)) + 
  geom_point(pch = 21, color = "black") + 
  geom_smooth(method = lm, alpha = 0.2) +
  stat_cor(method = "pearson") +
  theme_bw(base_size = 15) + 
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        aspect.ratio = 1,
        legend.position = "none") +
  scale_fill_manual(values = c("SteelBlue", "lightsalmon1")) +
  scale_color_manual(values = c("SteelBlue", "lightsalmon1")) +
  facet_wrap(~variable, nrow = 2)
## `geom_smooth()` using formula = 'y ~ x'

Analysis

Strategy: start with pop*(pred_trt + tutor_pop) and drop when non-significant

Body black

Both HP and LP males responded to social treatment. Body black solo > LP~HP

mod <- lmer(logit(body_black_prop) ~ pop+pred_trt + tutor_pop+ (1|mom_ID),
            data = data_color_merged)

summary(mod)$coefficient %>% kable(digits = 3)
Estimate Std. Error t value
(Intercept) -1.365 0.076 -17.850
popAL -0.043 0.088 -0.495
pred_trtY -0.051 0.055 -0.932
tutor_popAH -0.190 0.067 -2.836
tutor_popAL -0.121 0.067 -1.812
Anova(mod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: logit(body_black_prop)
##            Chisq Df Pr(>Chisq)  
## pop       0.2452  1     0.6205  
## pred_trt  0.8685  1     0.3514  
## tutor_pop 8.2954  2     0.0158 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(mod, ~ tutor_pop) %>% pairs() %>% kable(digits=3)
contrast estimate SE df t.ratio p.value
solo - AH 0.190 0.067 224.381 2.823 0.014
solo - AL 0.121 0.067 216.399 1.807 0.170
AH - AL -0.068 0.068 222.761 -1.002 0.577

Tail black

trend of pred+ having less tail black

mod <- lmer(car::logit(tail_black_prop) ~ pop+pred_trt + tutor_pop+ (1|mom_ID),
            data = data_color_merged)

summary(mod)$coefficient %>% kable(digits = 3)
Estimate Std. Error t value
(Intercept) -1.847 0.239 -7.715
popAL 0.550 0.334 1.644
pred_trtY -0.148 0.084 -1.772
tutor_popAH -0.107 0.103 -1.034
tutor_popAL -0.014 0.102 -0.134

Body melanin

LP overall have less body melanin compare to HP males They showed trend of responding differently to predator treatment; when reared in pred+, HP decreased melanin and LP increased.

mod <- lmer(logit(body_melanin_prop) ~ pop*pred_trt + tutor_pop+ (1|mom_ID),
            data = data_color_merged)

summary(mod)$coefficient %>% kable(digits = 3)
Estimate Std. Error t value
(Intercept) -0.982 0.070 -14.012
popAL -0.188 0.092 -2.055
pred_trtY -0.095 0.062 -1.543
tutor_popAH -0.006 0.053 -0.119
tutor_popAL -0.036 0.053 -0.681
popAL:pred_trtY 0.160 0.087 1.840
emmeans(mod, ~ pred_trt|pop) %>% pairs() %>% kable(digits=3)
contrast pop estimate SE df t.ratio p.value
N - Y AH 0.095 0.062 212.900 1.540 0.125
N - Y AL -0.065 0.062 217.401 -1.056 0.292

Tail melanin

Nothing

mod <- lmer(car::logit(tail_melanin_prop) ~ pop+pred_trt+tutor_pop+ (1|mom_ID),
            data = data_color_merged)

summary(mod)$coefficient %>% kable(digits = 3)
Estimate Std. Error t value
(Intercept) -1.829 0.240 -7.622
popAL 0.563 0.335 1.681
pred_trtY -0.127 0.083 -1.526
tutor_popAH -0.080 0.103 -0.775
tutor_popAL -0.020 0.101 -0.196

Body orange

Only LP fish is sensitive to social treatment; when reared alone they have more orange

mod <- lmer(car::logit(body_orange_prop) ~ pop*tutor_pop+ pred_trt+ (1|mom_ID),
            data = data_color_merged)

summary(mod)$coefficient %>% kable(digits = 3)
Estimate Std. Error t value
(Intercept) -2.399 0.142 -16.913
popAL 0.322 0.197 1.638
tutor_popAH 0.024 0.129 0.187
tutor_popAL 0.002 0.127 0.016
pred_trtY -0.026 0.071 -0.366
popAL:tutor_popAH -0.390 0.175 -2.225
popAL:tutor_popAL -0.183 0.173 -1.056
emmeans(mod, ~ tutor_pop|pop) %>% pairs() %>% kable(digits=3)
contrast pop estimate SE df t.ratio p.value
solo - AH AH -0.024 0.129 220.638 -0.186 0.981
solo - AL AH -0.002 0.127 210.121 -0.016 1.000
AH - AL AH 0.022 0.134 220.651 0.165 0.985
solo - AH AL 0.366 0.119 205.051 3.067 0.007
solo - AL AL 0.181 0.118 203.047 1.532 0.278
AH - AL AL -0.185 0.119 201.300 -1.557 0.267

Tail orange

Both HP and LP responded to social treatment; solo < HP ~ LP

mod <- lmer(car::logit(tail_orange_prop) ~ pop+tutor_pop+ pred_trt+ (1|mom_ID),
            data = data_color_merged)

summary(mod)$coefficient %>% kable(digits = 3)
Estimate Std. Error t value
(Intercept) -2.215 0.326 -6.788
popAL 0.131 0.443 0.296
tutor_popAH 0.264 0.175 1.504
tutor_popAL 0.446 0.173 2.580
pred_trtY 0.136 0.142 0.959
emmeans(mod, ~ tutor_pop) %>% pairs() %>% kable(digits=3)
contrast estimate SE df t.ratio p.value
solo - AH -0.264 0.176 210.379 -1.501 0.292
solo - AL -0.446 0.173 205.567 -2.577 0.029
AH - AL -0.182 0.178 208.678 -1.025 0.562

Body xantho

Population differ in response to tutor treatment; only AL is sensitive-ish, not significant.

mod <- lmer(car::logit(body_xanthophore_prop) ~ pop*tutor_pop+ pred_trt+ (1|mom_ID),
            data = data_color_merged)

summary(mod)$coefficient %>% kable(digits = 3)
Estimate Std. Error t value
(Intercept) -1.974 0.119 -16.572
popAL 0.218 0.164 1.329
tutor_popAH 0.108 0.114 0.948
tutor_popAL -0.041 0.113 -0.365
pred_trtY 0.002 0.063 0.034
popAL:tutor_popAH -0.330 0.156 -2.115
popAL:tutor_popAL -0.038 0.155 -0.245
Anova(mod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: car::logit(body_xanthophore_prop)
##                Chisq Df Pr(>Chisq)  
## pop           0.5000  1    0.47951  
## tutor_pop     0.9359  2    0.62629  
## pred_trt      0.0011  1    0.97320  
## pop:tutor_pop 5.2359  2    0.07295 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(mod, ~tutor_pop|pop) %>% pairs %>% kable(digits=3)
contrast pop estimate SE df t.ratio p.value
solo - AH AH -0.108 0.115 222.671 -0.944 0.613
solo - AL AH 0.041 0.113 211.962 0.364 0.930
AH - AL AH 0.149 0.119 222.791 1.259 0.420
solo - AH AL 0.222 0.106 206.156 2.082 0.096
solo - AL AL 0.079 0.105 203.736 0.750 0.734
AH - AL AL -0.143 0.106 202.070 -1.345 0.372

Tail xantho

This ones pretty interesting. 1. Both HP and LP males are influenced by social treatment; when raised with AL tutor, they develop more xantho on tail (marginal) 2. Only HP is sensitive to pred treatment; they develop more xantho in predator water.

mod <- lmer(car::logit(tail_xanthophore_prop) ~ pop*pred_trt + tutor_pop+ (1|mom_ID),
            data = data_color_merged)

summary(mod)$coefficient %>% kable(digits = 3)
Estimate Std. Error t value
(Intercept) -1.907 0.301 -6.342
popAL 0.778 0.428 1.820
pred_trtY 0.295 0.142 2.082
tutor_popAH -0.001 0.124 -0.006
tutor_popAL 0.274 0.122 2.241
popAL:pred_trtY -0.427 0.201 -2.126
Anova(mod, type =3)
## Analysis of Deviance Table (Type III Wald chisquare tests)
## 
## Response: car::logit(tail_xanthophore_prop)
##                Chisq Df Pr(>Chisq)    
## (Intercept)  40.2258  1  2.262e-10 ***
## pop           3.3138  1    0.06870 .  
## pred_trt      4.3360  1    0.03731 *  
## tutor_pop     6.5459  2    0.03790 *  
## pop:pred_trt  4.5184  1    0.03353 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(mod, ~tutor_pop) %>% pairs %>% kable(digits=3)
contrast estimate SE df t.ratio p.value
solo - AH 0.001 0.125 205.446 0.006 1.000
solo - AL -0.274 0.122 202.402 -2.240 0.067
AH - AL -0.275 0.126 204.158 -2.183 0.076
emmeans(mod, ~pred_trt|pop) %>% pairs %>% kable(digits=3)
contrast pop estimate SE df t.ratio p.value
N - Y AH -0.295 0.142 202.771 -2.081 0.039
N - Y AL 0.132 0.143 203.250 0.925 0.356

Gonopodium length among treatments

solo vs HP tutor vs LP tutor

Trend of solo fish having relatively shorter gonopodia, but not significant

mod <- lmer(gono_length ~ pop+pred_trt+tutor_pop+ length + (1|mom_ID) ,
            data = data_color_merged)

Anova(mod, type = 3)
## Analysis of Deviance Table (Type III Wald chisquare tests)
## 
## Response: gono_length
##               Chisq Df Pr(>Chisq)    
## (Intercept) 12.9019  1  0.0003282 ***
## pop          0.7101  1  0.3994059    
## pred_trt     0.4304  1  0.5118131    
## tutor_pop    4.6454  2  0.0980079 .  
## length      91.4419  1  < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(mod, ~tutor_pop) %>% pairs %>% kable(digits=3)
contrast estimate SE df t.ratio p.value
solo - AH -0.096 0.047 227.553 -2.044 0.104
solo - AL -0.086 0.048 222.123 -1.787 0.176
AH - AL 0.009 0.041 224.401 0.228 0.972

solo vs tutor

Significant went grouping the two tutored groups together.

mod <- lmer(gono_length ~ pop+pred_trt+tutor+ length + (1|mom_ID) ,
            data = data_color_merged)

Anova(mod, type = 3)
## Analysis of Deviance Table (Type III Wald chisquare tests)
## 
## Response: gono_length
##               Chisq Df Pr(>Chisq)    
## (Intercept) 13.1252  1  0.0002914 ***
## pop          0.7172  1  0.3970707    
## pred_trt     0.4316  1  0.5111979    
## tutor        4.6030  1  0.0319167 *  
## length      91.9168  1  < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans(mod, ~tutor) %>% pairs %>% kable(digits=3)
contrast estimate SE df t.ratio p.value
solo - tutor -0.091 0.043 226.647 -2.134 0.034

Correlation among gonopodia, color, brain, and behavior

Exploratory scatterplots

Stats in this preliminary plot are based on Gaussian correlations with no random effects so could be different from the GLMM models but should show the same trends

scatterplot<- 
  ggpairs(data_color_merged, 
        columns = c("gono_resid", "BM_resid", "sigmoid_prop",
                    "body_melanin_prop", 'tail_melanin_prop', 'body_xanthophore_prop', 'tail_xanthophore_prop'), 
        aes(color = pop),
        title = "Scatterplots & Correlation matrix")

print(scatterplot)

gonopodium - behavior

Relative gonopodia length is negatively correlated with sigmoid proportion

# ID is added as OLRE to help with overdispersion
mod <-glmer(cbind(sigmoid, sneak)  ~ gono_resid+pop+
              (1|ID)+(1|mom_ID), 
            data = data_color_merged,
            family = binomial())
summary(mod)$coefficients %>% kable(digit = 3)
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.309 0.271 -1.140 0.254
gono_resid -5.467 1.968 -2.778 0.005
popAL -0.396 0.382 -1.037 0.300
mod.fit <- emmip(mod, pop~gono_resid, cov.reduce = range, type = "response", plotit = F)

gono_behav <- ggplot(data = data_color_merged)+
  geom_point(aes(x = gono_resid, y = sigmoid_prop, color = pop), alpha = 0.3) +

  stat_summary_bin(aes(x = gono_resid, y = sigmoid_prop, color = pop),
                   fun.data = mean_se, 
                   bins=8, size =0.5, position = position_dodge(0.02))+
  
  geom_line(size = 1 ,data = mod.fit, aes(x = xvar, y = yvar, color = pop))+
  labs( x = "Residual gonopodium length", y = "Sigmoid proportion") +
  
  scale_color_manual("Population origin",
                     labels = c("HP","LP"),
                     values=c("SteelBlue", "lightsalmon1")) +
  
  theme_bw(base_size = 15)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.position = "bottom",
        aspect.ratio=1) 

gono_behav

brain size - behavior

Marginal: HP males that have larger brain sigmoids proportionally more

mod <-glmer(cbind(sigmoid, sneak)  ~ pop*BM_resid+
              (1|ID) + (1|mom_ID), 
            data = data_color_merged,
            family = binomial(),
            control=glmerControl(optimizer="bobyqa", optCtrl=list(maxfun=100000)))
## boundary (singular) fit: see help('isSingular')
summary(mod)$coefficients %>% kable(digit = 3)
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.045 0.423 -2.470 0.014
popAL 0.768 0.527 1.458 0.145
BM_resid 3.199 1.768 1.809 0.070
popAL:BM_resid -4.360 2.347 -1.858 0.063
emtrends(mod, ~pop, "BM_resid") %>% test
##  pop BM_resid.trend   SE  df z.ratio p.value
##  AH            3.20 1.77 Inf   1.809  0.0705
##  AL           -1.16 1.54 Inf  -0.754  0.4510
mod.fit <- emmip(mod, pop~BM_resid, cov.reduce = range, type = "response", plotit = F)

BM_behav <- ggplot(data = data_color_merged)+
  geom_point(aes(x = BM_resid, y = sigmoid_prop, color = pop), alpha = 0.3) +
  geom_line(size = 1 ,data = mod.fit, aes(x = xvar, y = yvar, color = pop))+
  
  stat_summary_bin(aes(x = BM_resid, y = sigmoid_prop, color = pop),
                   fun.data = mean_se, 
                   bins=8, size =0.5, position = position_dodge(0.025))+
  
  labs( x = "Residual brain mass", y = "Sigmoid proportion") +
  
  scale_color_manual("Population origin",
                     labels = c("HP","LP"),
                     values=c("SteelBlue", "lightsalmon1")) +
  scale_x_continuous(limits =c(-0.2506015, 0.4115183)) +
  
  theme_bw(base_size = 15)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.position = "bottom",
        aspect.ratio=1) 

BM_behav

brain size-gonopodium

Marginal: males with longer gonopodia have smaller brains

mod <-lmer(scale(BM)  ~ gono_resid+pop + weight +
              (1|mom_ID), 
            data = data_color_merged )

summary(mod)$coefficients %>% kable(digit = 4)
Estimate Std. Error t value
(Intercept) -2.4043 0.3498 -6.8739
gono_resid -1.8360 0.9941 -1.8468
popAL -0.3690 0.1681 -2.1948
weight 20.3387 2.5998 7.8231
Anova(mod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: scale(BM)
##              Chisq Df Pr(>Chisq)    
## gono_resid  3.4107  1    0.06478 .  
## pop         4.8172  1    0.02818 *  
## weight     61.2010  1  5.154e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mod <-lmer(BM_resid  ~ gono_resid+pop +  (1|mom_ID), 
            data = data_color_merged)
mod.fit <- emmip(mod, pop~gono_resid, cov.reduce = range, type = "response", plotit = F)

BM_gono <- ggplot(data = data_color_merged)+
  geom_point(aes(x = gono_resid, y = BM_resid, color = pop), alpha = 0.3) +
  geom_line(size = 1 ,data = mod.fit, aes(x = xvar, y = yvar, color = pop))+
  
  stat_summary_bin(aes(x = gono_resid, y = BM_resid, color = pop),
                   fun.data = mean_se, 
                   bins=8, size =0.5, position = position_dodge(0.025))+
  
  labs( x = "Residual gonopodium length", y = "Residual brain mass") +
  
  scale_color_manual("Population origin",
                     labels = c("HP","LP"),
                     values=c("SteelBlue", "lightsalmon1")) +
  
  theme_bw(base_size = 15)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.position = "bottom",
        aspect.ratio=1) 

BM_gono

Color

Didn’t run full sets yet - pending discussion on what we want to run.

All figures (old temp code for later use)

egg::ggarrange(gono_behav + theme(legend.position = "none"),
               BM_behav, 
               BM_gono + theme(legend.position = "none"), nrow = 1,labels = c("A","B","C"))

Variable key

1. Treatment variables & fish info:

 

2. Life history and morphology data:

 

3. Color data: