---
# System prepended metadata

title: Test for relationship between weight and response variables
tags: [Rscripts]

---

---
tags: Rscripts
---
# Test for relationship between weight and response variables
### Author: Jocelyn P. Colella
### (e.g., is weight a covariate?)
It's not! No significant relationship between weight and ANY response variable.

## Male and Female EE vs. weight
- All comparisons insignificant: no relationship between weight and EE
![](https://i.imgur.com/hfVcNtz.png)



## Male and Female RQ vs. weight
- All comparisons insignificant: no relationship between weight and RQ
![](https://i.imgur.com/e1k4VUD.png)



## Male and Female H2O vs. weight
- All comparisons insignificant: no relationships between weight and H2O
- AFTER corrected 29g female weight to 19g
- ![](https://i.imgur.com/jDpbKvj.png)


## Male and Female VO2 vs. weight
- All comparisons insignificant: no relationship between weight and VO2
![](https://i.imgur.com/zFYPesz.png)


## Male and Female VCO2 vs. weight
- All comparisons insignificant: no relationship between weight and VCO2
![](https://i.imgur.com/SFF68QD.png)



```
### TEST FOR A RELATIONSHIP BETWEEN WEIGHT AND ALL RESPONSE VARIABLES
### 
setwd("~/Documents/Jocie/projects/Pero_respo/Analyses/data/")

######## BASELINE F (day and night)
BL_animalweight <- BL_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
BL_meanEE <- BL_noOL_F %>% group_by(Animal_ID) %>% summarise(EE = mean(EE)) %>% select(EE)
BL_EEwt <- cbind(BL_animalweight, BL_meanEE)
summary(lm(BL_meanEE[[1]] ~ BL_animalweight[[1]]))

BL_F_eeXwt_plot <- ggscatter(BL_EEwt, x = "weight", y = "EE", palette = "jco",
                               add = "reg.line") +
  stat_cor(label.y = 0.37) +
  stat_regline_equation(label.y = 0.40) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  labs(title="Baseline", x = "", y ="Female: EE")
BL_F_eeXwt_plot

######## hot F (day and night)
hot_animalweight <- hot_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
hot_meanEE <- hot_noOL_F %>% group_by(Animal_ID) %>% summarise(EE = mean(EE)) %>% select(EE)
hot_EEwt <- cbind(hot_animalweight, hot_meanEE)
summary(lm(hot_meanEE[[1]] ~ hot_animalweight[[1]]))

hot_F_eeXwt_plot <- ggscatter(hot_EEwt, x = "weight", y = "EE", palette = "jco",
                           add = "reg.line") +
  stat_cor(label.y = 0.37) +
  stat_regline_equation(label.y = 0.40) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  labs(title="Hot", x = "", y ="")
hot_F_eeXwt_plot

######## cold F (day and night)
cold_animalweight <- cold_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
cold_meanEE <- cold_noOL_F %>% group_by(Animal_ID) %>% summarise(EE = mean(EE)) %>% select(EE)
cold_EEwt <- cbind(cold_animalweight, cold_meanEE)
summary(lm(cold_meanEE[[1]] ~ cold_animalweight[[1]]))

cold_F_eeXwt_plot <- ggscatter(cold_EEwt, x = "weight", y = "EE", palette = "jco",
                           add = "reg.line") +
  stat_cor(label.y = 0.37) +
  stat_regline_equation(label.y = 0.39) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  labs(title="Cold", x = "", y ="")
cold_F_eeXwt_plot


######## MALES ###########
######## BASELINE M (day and night)
BL_animalweight <- BL_noOL_M %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
BL_meanEE <- BL_noOL_M %>% group_by(Animal_ID) %>% summarise(EE = mean(EE)) %>% select(EE)
BL_EEwt <- cbind(BL_animalweight, BL_meanEE)
summary(lm(BL_meanEE[[1]] ~ BL_animalweight[[1]]))

BL_M_eeXwt_plot <- ggscatter(BL_EEwt, x = "weight", y = "EE", palette = "jco",
                               add = "reg.line") +
  stat_cor(label.y = 0.37) +
  stat_regline_equation(label.y = 0.40) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  labs(title="", x = "Males: EE", y ="")
BL_M_eeXwt_plot


######## hot M (day and night)
hot_animalweight <- hot_noOL_M %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
hot_meanEE <- hot_noOL_M %>% group_by(Animal_ID) %>% summarise(EE = mean(EE)) %>% select(EE)
hot_EEwt <- cbind(hot_animalweight, hot_meanEE)
summary(lm(hot_meanEE[[1]] ~ hot_animalweight[[1]]))

hot_M_eeXwt_plot <- ggscatter(hot_EEwt, x = "weight", y = "EE", palette = "jco",
                            add = "reg.line") +
  stat_cor(label.y = 0.365) +
  stat_regline_equation(label.y = 0.39) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  labs(title="", x = "Weight (g)", y ="")
hot_M_eeXwt_plot


######## cold M (day and night)
cold_animalweight <- cold_noOL_M %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
cold_meanEE <- cold_noOL_M %>% group_by(Animal_ID) %>% summarise(EE = mean(EE)) %>% select(EE)
cold_EEwt <- cbind(cold_animalweight, cold_meanEE)
summary(lm(cold_meanEE[[1]] ~ cold_animalweight[[1]]))

cold_M_eeXwt_plot <- ggscatter(cold_EEwt, x = "weight", y = "EE", palette = "jco",
                             add = "reg.line") +
  stat_cor(label.y = 0.375) +
  stat_regline_equation(label.y = 0.39) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  labs(title="", x = "", y ="")
cold_M_eeXwt_plot


# Panelled plot, (row 1 = females, row 2= males)
#grid.arrange(BL_F_eeXwt_plot, hot_F_eeXwt_plot, cold_F_eeXwt_plot, 
#             BL_M_eeXwt_plot, hot_M_eeXwt_plot, cold_M_eeXwt_plot, 
#             top = "EE X weight",
#             nrow = 2)

#TO CREATE A PLOT WITH EVEN SIZED SUBPLOTS
ggdraw() +
  draw_plot(BL_F_eeXwt_plot,  x = 0, y = 0.5, width = .33, height = .5) +
  draw_plot(hot_F_eeXwt_plot, x = 0.33, y = 0.5, width = .33, height = .5) +
  draw_plot(cold_F_eeXwt_plot, x = 0.66, y = 0.5, width = .33, height = .5) +
  
  draw_plot(BL_M_eeXwt_plot,  x = 0,    y = 0.02, width = .33, height = .5) +
  draw_plot(hot_M_eeXwt_plot,  x = 0.33, y = 0.02, width = .33, height = .5) +
  draw_plot(cold_M_eeXwt_plot, x = 0.66, y = 0.02, width = .33, height = .5)




###########################################################################
###########################################################################
######################### RQ plots#########################
######## BASELINE F (day and night)
BL_animalweight <- BL_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
BL_meanRQ <- BL_noOL_F %>% group_by(Animal_ID) %>% summarise(RQ = mean(RQ)) %>% select(RQ)
BL_RQwt <- cbind(BL_animalweight, BL_meanRQ)
summary(lm(BL_meanRQ[[1]] ~ BL_animalweight[[1]]))

BL_F_rqXwt_plot <- ggscatter(BL_RQwt, x = "weight", y = "RQ", palette = "jco",
                             add = "reg.line") +
  stat_cor(label.y = 1.2) +
  stat_regline_equation(label.y = 1.25) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  labs(title="Baseline", x = "", y ="Female: RQ")
BL_F_rqXwt_plot


######## hot F (day and night)
hot_animalweight <- hot_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
hot_meanRQ <- hot_noOL_F %>% group_by(Animal_ID) %>% summarise(RQ = mean(RQ)) %>% select(RQ)
hot_RQwt <- cbind(hot_animalweight, hot_meanRQ)
summary(lm(hot_meanRQ[[1]] ~ hot_animalweight[[1]]))

hot_F_rqXwt_plot <- ggscatter(hot_RQwt, x = "weight", y = "RQ", palette = "jco",
                              add = "reg.line") +
  stat_cor(label.y = 1.2) +
  stat_regline_equation(label.y = 1.24) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  labs(title="Hot", x = "", y ="")
hot_F_rqXwt_plot


######## cold F (day and night)
cold_animalweight <- cold_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
cold_meanRQ <- cold_noOL_F %>% group_by(Animal_ID) %>% summarise(RQ = mean(RQ)) %>% select(RQ)
cold_RQwt <- cbind(cold_animalweight, cold_meanRQ)
summary(lm(cold_meanRQ[[1]] ~ cold_animalweight[[1]]))

cold_F_rqXwt_plot <- ggscatter(cold_RQwt, x = "weight", y = "RQ", palette = "jco",
                               add = "reg.line") +
  stat_cor(label.y = 1.2) +
  stat_regline_equation(label.y = 1.24) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  labs(title="Cold", x = "", y ="")
cold_F_rqXwt_plot


######## MALES ###########
######## BASELINE M (day and night)
BL_animalweight <- BL_noOL_M %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
BL_meanRQ <- BL_noOL_M %>% group_by(Animal_ID) %>% summarise(RQ = mean(RQ)) %>% select(RQ)
BL_RQwt <- cbind(BL_animalweight, BL_meanRQ)
summary(lm(BL_meanRQ[[1]] ~ BL_animalweight[[1]]))

BL_M_rqXwt_plot <- ggscatter(BL_RQwt, x = "weight", y = "RQ", palette = "jco",
                             add = "reg.line") +
  stat_cor(label.y = 1.2) +
  stat_regline_equation(label.y = 1.24) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  labs(title="", x = "", y ="Male: RQ")
BL_M_rqXwt_plot


######## hot M (day and night)
hot_animalweight <- hot_noOL_M %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
hot_meanRQ <- hot_noOL_M %>% group_by(Animal_ID) %>% summarise(RQ = mean(RQ)) %>% select(RQ)
hot_RQwt <- cbind(hot_animalweight, hot_meanRQ)
summary(lm(hot_meanRQ[[1]] ~ hot_animalweight[[1]]))

hot_M_rqXwt_plot <- ggscatter(hot_RQwt, x = "weight", y = "RQ", palette = "jco",
                              add = "reg.line") +
  stat_cor(label.y = 1.2) +
  stat_regline_equation(label.y = 1.24) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  labs(title="", x = "Weight (g)", y ="")
hot_M_rqXwt_plot


######## cold M (day and night)
cold_animalweight <- cold_noOL_M %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
cold_meanRQ <- cold_noOL_M %>% group_by(Animal_ID) %>% summarise(RQ = mean(RQ)) %>% select(RQ)
cold_RQwt <- cbind(cold_animalweight, cold_meanRQ)
summary(lm(cold_meanRQ[[1]] ~ cold_animalweight[[1]]))

cold_M_rqXwt_plot <- ggscatter(cold_RQwt, x = "weight", y = "RQ", palette = "jco",
                               add = "reg.line") +
  stat_cor(label.y = 1.2) +
  stat_regline_equation(label.y = 1.24) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  labs(title="", x = "", y ="")
cold_M_rqXwt_plot


#TO CREATE A PLOT WITH EVEN SIZED SUBPLOTS
ggdraw() +
  draw_plot(BL_F_rqXwt_plot,  x = 0, y = 0.5, width = .33, height = .5) +
  draw_plot(hot_F_rqXwt_plot, x = 0.33, y = 0.5, width = .33, height = .5) +
  draw_plot(cold_F_rqXwt_plot, x = 0.66, y = 0.5, width = .33, height = .5) +
  
  draw_plot(BL_M_rqXwt_plot,  x = 0,    y = 0.02, width = .33, height = .5) +
  draw_plot(hot_M_rqXwt_plot,  x = 0.33, y = 0.02, width = .33, height = .5) +
  draw_plot(cold_M_rqXwt_plot, x = 0.66, y = 0.02, width = .33, height = .5)






###########################################################################
###########################################################################
######################### H2Omg plots#########################
######## BASELINE F (day and night)
BL_animalweight <- BL_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
BL_meanH2Omg <- BL_noOL_F %>% group_by(Animal_ID) %>% summarise(H2Omg = mean(H2Omg)) %>% select(H2Omg)
BL_H2Omgwt <- cbind(BL_animalweight, BL_meanH2Omg)
summary(lm(BL_meanH2Omg[[1]] ~ BL_animalweight[[1]]))

BL_F_H2OmgXwt_plot <- ggscatter(BL_H2Omgwt, x = "weight", y = "H2Omg", palette = "jco",
                                add = "reg.line") +
  stat_cor(label.y = 0.3) +
  stat_regline_equation(label.y = 0.28) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  labs(title="Baseline", x = "", y ="Female: H2Omg")
BL_F_H2OmgXwt_plot


######## hot F (day and night)
hot_animalweight <- hot_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
hot_meanH2Omg <- hot_noOL_F %>% group_by(Animal_ID) %>% summarise(H2Omg = mean(H2Omg)) %>% select(H2Omg)
hot_H2Omgwt <- cbind(hot_animalweight, hot_meanH2Omg)
summary(lm(hot_meanH2Omg[[1]] ~ hot_animalweight[[1]]))

hot_F_H2OmgXwt_plot <- ggscatter(hot_H2Omgwt, x = "weight", y = "H2Omg", palette = "jco",
                                 add = "reg.line") +
  stat_cor(label.y = 0.3) +
  stat_regline_equation(label.y = 0.28) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  labs(title="Hot", x = "", y ="")
hot_F_H2OmgXwt_plot


######## cold F (day and night)
cold_animalweight <- cold_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
cold_meanH2Omg <- cold_noOL_F %>% group_by(Animal_ID) %>% summarise(H2Omg = mean(H2Omg)) %>% select(H2Omg)
cold_H2Omgwt <- cbind(cold_animalweight, cold_meanH2Omg)
summary(lm(cold_meanH2Omg[[1]] ~ cold_animalweight[[1]]))

cold_F_H2OmgXwt_plot <- ggscatter(cold_H2Omgwt, x = "weight", y = "H2Omg", palette = "jco",
                                  add = "reg.line") +
  stat_cor(label.y = 0.3) +
  stat_regline_equation(label.y = 0.28) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  labs(title="Cold", x = "", y ="")
cold_F_H2OmgXwt_plot


######## MALES ###########
######## BASELINE M (day and night)
BL_animalweight <- BL_noOL_M %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
BL_meanH2Omg <- BL_noOL_M %>% group_by(Animal_ID) %>% summarise(H2Omg = mean(H2Omg)) %>% select(H2Omg)
BL_H2Omgwt <- cbind(BL_animalweight, BL_meanH2Omg)
summary(lm(BL_meanH2Omg[[1]] ~ BL_animalweight[[1]]))

BL_M_H2OmgXwt_plot <- ggscatter(BL_H2Omgwt, x = "weight", y = "H2Omg", palette = "jco",
                                add = "reg.line") +
  stat_cor(label.y = 0.3) +
  stat_regline_equation(label.y = 0.28) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  labs(title="", x = "", y ="Male: H2Omg")
BL_M_H2OmgXwt_plot


######## hot M (day and night)
hot_animalweight <- hot_noOL_M %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
hot_meanH2Omg <- hot_noOL_M %>% group_by(Animal_ID) %>% summarise(H2Omg = mean(H2Omg)) %>% select(H2Omg)
hot_H2Omgwt <- cbind(hot_animalweight, hot_meanH2Omg)
summary(lm(hot_meanH2Omg[[1]] ~ hot_animalweight[[1]]))

hot_M_H2OmgXwt_plot <- ggscatter(hot_H2Omgwt, x = "weight", y = "H2Omg", palette = "jco",
                                 add = "reg.line") +
  stat_cor(label.y = 0.3) +
  stat_regline_equation(label.y = 0.28) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  labs(title="", x = "Weight (g)", y ="")
hot_M_H2OmgXwt_plot


######## cold M (day and night)
cold_animalweight <- cold_noOL_M %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
cold_meanH2Omg <- cold_noOL_M %>% group_by(Animal_ID) %>% summarise(H2Omg = mean(H2Omg)) %>% select(H2Omg)
cold_H2Omgwt <- cbind(cold_animalweight, cold_meanH2Omg)
summary(lm(cold_meanH2Omg[[1]] ~ cold_animalweight[[1]]))

cold_M_H2OmgXwt_plot <- ggscatter(cold_H2Omgwt, x = "weight", y = "H2Omg", palette = "jco",
                                  add = "reg.line") +
  stat_cor(label.y = 0.3) +
  stat_regline_equation(label.y = 0.28) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  labs(title="", x = "", y ="")
cold_M_H2OmgXwt_plot


#TO CREATE A PLOT WITH EVEN SIZED SUBPLOTS
ggdraw() +
  draw_plot(BL_F_H2OmgXwt_plot,  x = 0, y = 0.5, width = .33, height = .5) +
  draw_plot(hot_F_H2OmgXwt_plot, x = 0.33, y = 0.5, width = .33, height = .5) +
  draw_plot(cold_F_H2OmgXwt_plot, x = 0.66, y = 0.5, width = .33, height = .5) +
  
  draw_plot(BL_M_H2OmgXwt_plot,  x = 0,    y = 0.02, width = .33, height = .5) +
  draw_plot(hot_M_H2OmgXwt_plot,  x = 0.33, y = 0.02, width = .33, height = .5) +
  draw_plot(cold_M_H2OmgXwt_plot, x = 0.66, y = 0.02, width = .33, height = .5)






##########################################################################
###########################################################################
######################### VO2 plots#########################
######## BASELINE F (day and night)
BL_animalweight <- BL_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
BL_meanVO2 <- BL_noOL_F %>% group_by(Animal_ID) %>% summarise(VO2 = mean(VO2)) %>% select(VO2)
BL_VO2wt <- cbind(BL_animalweight, BL_meanVO2)
summary(lm(BL_meanVO2[[1]] ~ BL_animalweight[[1]]))

BL_F_VO2Xwt_plot <- ggscatter(BL_VO2wt, x = "weight", y = "VO2", palette = "jco",
                              add = "reg.line") +
  stat_cor(label.y = 1.2) +
  stat_regline_equation(label.y = 1.29) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  labs(title="Baseline", x = "", y ="Female: VO2")
BL_F_VO2Xwt_plot


######## hot F (day and night)
hot_animalweight <- hot_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
hot_meanVO2 <- hot_noOL_F %>% group_by(Animal_ID) %>% summarise(VO2 = mean(VO2)) %>% select(VO2)
hot_VO2wt <- cbind(hot_animalweight, hot_meanVO2)
summary(lm(hot_meanVO2[[1]] ~ hot_animalweight[[1]]))

hot_F_VO2Xwt_plot <- ggscatter(hot_VO2wt, x = "weight", y = "VO2", palette = "jco",
                               add = "reg.line") +
  stat_cor(label.y = 1.2) +
  stat_regline_equation(label.y = 1.29) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  labs(title="Hot", x = "", y ="")
hot_F_VO2Xwt_plot


######## cold F (day and night)
cold_animalweight <- cold_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
cold_meanVO2 <- cold_noOL_F %>% group_by(Animal_ID) %>% summarise(VO2 = mean(VO2)) %>% select(VO2)
cold_VO2wt <- cbind(cold_animalweight, cold_meanVO2)
summary(lm(cold_meanVO2[[1]] ~ cold_animalweight[[1]]))

cold_F_VO2Xwt_plot <- ggscatter(cold_VO2wt, x = "weight", y = "VO2", palette = "jco",
                                add = "reg.line") +
  stat_cor(label.y = 1.2) +
  stat_regline_equation(label.y = 1.29) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  labs(title="Cold", x = "", y ="")
cold_F_VO2Xwt_plot


######## MALES ###########
######## BASELINE M (day and night)
BL_animalweight <- BL_noOL_M %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
BL_meanVO2 <- BL_noOL_M %>% group_by(Animal_ID) %>% summarise(VO2 = mean(VO2)) %>% select(VO2)
BL_VO2wt <- cbind(BL_animalweight, BL_meanVO2)
summary(lm(BL_meanVO2[[1]] ~ BL_animalweight[[1]]))

BL_M_VO2Xwt_plot <- ggscatter(BL_VO2wt, x = "weight", y = "VO2", palette = "jco",
                              add = "reg.line") +
  stat_cor(label.y = 1.2) +
  stat_regline_equation(label.y = 1.29) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  labs(title="", x = "", y ="Male: VO2")
BL_M_VO2Xwt_plot


######## hot M (day and night)
hot_animalweight <- hot_noOL_M %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
hot_meanVO2 <- hot_noOL_M %>% group_by(Animal_ID) %>% summarise(VO2 = mean(VO2)) %>% select(VO2)
hot_VO2wt <- cbind(hot_animalweight, hot_meanVO2)
summary(lm(hot_meanVO2[[1]] ~ hot_animalweight[[1]]))

hot_M_VO2Xwt_plot <- ggscatter(hot_VO2wt, x = "weight", y = "VO2", palette = "jco",
                               add = "reg.line") +
  stat_cor(label.y = 1.2) +
  stat_regline_equation(label.y = 1.29) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  labs(title="", x = "Weight (g)", y ="")
hot_M_VO2Xwt_plot


######## cold M (day and night)
cold_animalweight <- cold_noOL_M %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
cold_meanVO2 <- cold_noOL_M %>% group_by(Animal_ID) %>% summarise(VO2 = mean(VO2)) %>% select(VO2)
cold_VO2wt <- cbind(cold_animalweight, cold_meanVO2)
summary(lm(cold_meanVO2[[1]] ~ cold_animalweight[[1]]))

cold_M_VO2Xwt_plot <- ggscatter(cold_VO2wt, x = "weight", y = "VO2", palette = "jco",
                                add = "reg.line") +
  stat_cor(label.y = 1.2) +
  stat_regline_equation(label.y = 1.26) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  labs(title="", x = "", y ="")
cold_M_VO2Xwt_plot


#TO CREATE A PLOT WITH EVEN SIZED SUBPLOTS
ggdraw() +
  draw_plot(BL_F_VO2Xwt_plot,  x = 0, y = 0.5, width = .33, height = .5) +
  draw_plot(hot_F_VO2Xwt_plot, x = 0.33, y = 0.5, width = .33, height = .5) +
  draw_plot(cold_F_VO2Xwt_plot, x = 0.66, y = 0.5, width = .33, height = .5) +
  
  draw_plot(BL_M_VO2Xwt_plot,  x = 0,    y = 0.02, width = .33, height = .5) +
  draw_plot(hot_M_VO2Xwt_plot,  x = 0.33, y = 0.02, width = .33, height = .5) +
  draw_plot(cold_M_VO2Xwt_plot, x = 0.66, y = 0.02, width = .33, height = .5)





##########################################################################
###########################################################################
######################### VCO2 plots#########################
######## BASELINE F (day and night)
BL_animalweight <- BL_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
BL_meanVCO2 <- BL_noOL_F %>% group_by(Animal_ID) %>% summarise(VCO2 = mean(VCO2)) %>% select(VCO2)
BL_VCO2wt <- cbind(BL_animalweight, BL_meanVCO2)
summary(lm(BL_meanVCO2[[1]] ~ BL_animalweight[[1]]))

BL_F_VCO2Xwt_plot <- ggscatter(BL_VCO2wt, x = "weight", y = "VCO2", palette = "jco",
                               add = "reg.line") +
  stat_cor(label.y = 1.1) +
  stat_regline_equation(label.y = 1.02) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  labs(title="Baseline", x = "", y ="Female: VCO2")
BL_F_VCO2Xwt_plot


######## hot F (day and night)
hot_animalweight <- hot_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
hot_meanVCO2 <- hot_noOL_F %>% group_by(Animal_ID) %>% summarise(VCO2 = mean(VCO2)) %>% select(VCO2)
hot_VCO2wt <- cbind(hot_animalweight, hot_meanVCO2)
summary(lm(hot_meanVCO2[[1]] ~ hot_animalweight[[1]]))

hot_F_VCO2Xwt_plot <- ggscatter(hot_VCO2wt, x = "weight", y = "VCO2", palette = "jco",
                                add = "reg.line") +
  stat_cor(label.y = 1.1) +
  stat_regline_equation(label.y = 1.02) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  labs(title="Hot", x = "", y ="")
hot_F_VCO2Xwt_plot


######## cold F (day and night)
cold_animalweight <- cold_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
cold_meanVCO2 <- cold_noOL_F %>% group_by(Animal_ID) %>% summarise(VCO2 = mean(VCO2)) %>% select(VCO2)
cold_VCO2wt <- cbind(cold_animalweight, cold_meanVCO2)
summary(lm(cold_meanVCO2[[1]] ~ cold_animalweight[[1]]))

cold_F_VCO2Xwt_plot <- ggscatter(cold_VCO2wt, x = "weight", y = "VCO2", palette = "jco",
                                 add = "reg.line") +
  stat_cor(label.y = 1.1) +
  stat_regline_equation(label.y = 1.04) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  labs(title="Cold", x = "", y ="")
cold_F_VCO2Xwt_plot


######## MALES ###########
######## BASELINE M (day and night)
BL_animalweight <- BL_noOL_M %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
BL_meanVCO2 <- BL_noOL_M %>% group_by(Animal_ID) %>% summarise(VCO2 = mean(VCO2)) %>% select(VCO2)
BL_VCO2wt <- cbind(BL_animalweight, BL_meanVCO2)
summary(lm(BL_meanVCO2[[1]] ~ BL_animalweight[[1]]))

BL_M_VCO2Xwt_plot <- ggscatter(BL_VCO2wt, x = "weight", y = "VCO2", palette = "jco",
                               add = "reg.line") +
  stat_cor(label.y = 1.1) +
  stat_regline_equation(label.y = 1.02) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  labs(title="", x = "", y ="Male: VCO2")
BL_M_VCO2Xwt_plot


######## hot M (day and night)
hot_animalweight <- hot_noOL_M %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
hot_meanVCO2 <- hot_noOL_M %>% group_by(Animal_ID) %>% summarise(VCO2 = mean(VCO2)) %>% select(VCO2)
hot_VCO2wt <- cbind(hot_animalweight, hot_meanVCO2)
summary(lm(hot_meanVCO2[[1]] ~ hot_animalweight[[1]]))

hot_M_VCO2Xwt_plot <- ggscatter(hot_VCO2wt, x = "weight", y = "VCO2", palette = "jco",
                                add = "reg.line") +
  stat_cor(label.y = 1.1) +
  stat_regline_equation(label.y = 1.02) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  labs(title="", x = "Weight (g)", y ="")
hot_M_VCO2Xwt_plot


######## cold M (day and night)
cold_animalweight <- cold_noOL_M %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
cold_meanVCO2 <- cold_noOL_M %>% group_by(Animal_ID) %>% summarise(VCO2 = mean(VCO2)) %>% select(VCO2)
cold_VCO2wt <- cbind(cold_animalweight, cold_meanVCO2)
summary(lm(cold_meanVCO2[[1]] ~ cold_animalweight[[1]]))

cold_M_VCO2Xwt_plot <- ggscatter(cold_VCO2wt, x = "weight", y = "VCO2", palette = "jco",
                                 add = "reg.line") +
  stat_cor(label.y = 1.1) +
  stat_regline_equation(label.y = 1.05) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  labs(title="", x = "", y ="")
cold_M_VCO2Xwt_plot


#TO CREATE A PLOT WITH EVEN SIZED SUBPLOTS
ggdraw() +
  draw_plot(BL_F_VCO2Xwt_plot,  x = 0, y = 0.5, width = .33, height = .5) +
  draw_plot(hot_F_VCO2Xwt_plot, x = 0.33, y = 0.5, width = .33, height = .5) +
  draw_plot(cold_F_VCO2Xwt_plot, x = 0.66, y = 0.5, width = .33, height = .5) +
  
  draw_plot(BL_M_VCO2Xwt_plot,  x = 0,    y = 0.02, width = .33, height = .5) +
  draw_plot(hot_M_VCO2Xwt_plot,  x = 0.33, y = 0.02, width = .33, height = .5) +
  draw_plot(cold_M_VCO2Xwt_plot, x = 0.66, y = 0.02, width = .33, height = .5)
```



### Explore H2O and weight relationship for Females
![](https://i.imgur.com/QxuyA4Q.png)

NOTE: Significant relationship for Night+Day combined and daytime alone, but not for nighttime alone (p = 0.062)


```
#################################################################
#################################################################
#################################################################
# EXPLORE WHY H2O and WEIGHT share a relationship for FEMALES
######## hot F (day and night)
hot_animalweight <- hot_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
hot_meanH2Omg <- hot_noOL_F %>% group_by(Animal_ID) %>% summarise(H2Omg = mean(H2Omg)) %>% select(H2Omg)
hot_H2Omgwt <- cbind(hot_animalweight, hot_meanH2Omg)
summary(lm(hot_meanH2Omg[[1]] ~ hot_animalweight[[1]]))

hot_F_H2OmgXwt_plot <- ggscatter(hot_H2Omgwt, x = "weight", y = "H2Omg", palette = "jco",
                                 add = "reg.line") +
  stat_cor(label.y = 0.35) +
  stat_regline_equation(label.y = 0.33) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  labs(title="Night+Day", x = "", y ="H2O (mg)")
hot_F_H2OmgXwt_plot


######## hot F - DAY only
hot_animalweight <- hot_day_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
hot_meanH2Omg <- hot_day_noOL_F %>% group_by(Animal_ID) %>% summarise(H2Omg = mean(H2Omg)) %>% select(H2Omg)
hot_H2Omgwt <- cbind(hot_animalweight, hot_meanH2Omg)
summary(lm(hot_meanH2Omg[[1]] ~ hot_animalweight[[1]]))

hot_day_F_H2OmgXwt_plot <- ggscatter(hot_H2Omgwt, x = "weight", y = "H2Omg", palette = "jco",
                                 add = "reg.line") +
  stat_cor(label.y = 0.35) +
  stat_regline_equation(label.y = 0.33) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  labs(title="Day", x = "Weight", y ="")
hot_day_F_H2OmgXwt_plot

######## hot F - NIGHT only
hot_animalweight <- hot_night_noOL_F %>% group_by(Animal_ID) %>% summarise(weight = mean(weight)) %>% select(weight)
hot_meanH2Omg <- hot_night_noOL_F %>% group_by(Animal_ID) %>% summarise(H2Omg = mean(H2Omg)) %>% select(H2Omg)
hot_H2Omgwt <- cbind(hot_animalweight, hot_meanH2Omg)
summary(lm(hot_meanH2Omg[[1]] ~ hot_animalweight[[1]]))

hot_night_F_H2OmgXwt_plot <- ggscatter(hot_H2Omgwt, x = "weight", y = "H2Omg", palette = "jco",
                                 add = "reg.line") +
  stat_cor(label.y = 0.35) +
  stat_regline_equation(label.y = 0.33) +
  theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "lines")) +
  theme(plot.title = element_text(size = 14, hjust=0.5)) +
  labs(title="Night", x = "", y ="")
hot_night_F_H2OmgXwt_plot


####COMBINED FIGURE
ggdraw() +
  draw_plot(hot_F_H2OmgXwt_plot,      x = 0,     y = 0,   width = .33, height = 1) +
  draw_plot(hot_day_F_H2OmgXwt_plot,  x = 0.33,  y = 0, width = .33, height = 1) +
  draw_plot(hot_night_F_H2OmgXwt_plot, x = 0.66, y = 0,   width = .33, height = 1)
  
