---
title: Figure 3
output: html_document
editor_options: 
  chunk_output_type: console
---
# Init
```{r}
d<-read.csv("Fig3_Data.csv")
head(d)

d$slope <- as.character(d$slope)

library(dabestr)
```

# Stepping pattern change

## Three-point contact area

```{r}
ATripod <- function(d,antsp){
  df <- subset(d,ant==antsp)
  unpaired_mean_diff <- dabest(df, slope, ATripod,
                               idx = c("0","60"),
                               paired = FALSE)
  
  unpaired_mean_diff
  p<-median_diff(unpaired_mean_diff,reps=5000)
  plot(p,
       rawplot.ylim=c(30,90),effsize.ylim=c(-10,50),float.contrast = F
  )
}
pF <- ATripod(d,"Formica")
pC <-  ATripod(d,"Cataglyphis")
ggpubr::ggarrange(pC,pF)
```

## Front leg effective lever arm

```{r}
LeverArm <- function(d,antsp){
  df <- subset(d,ant==antsp)
  unpaired_mean_diff <- dabest(df, slope, LeverArm1,
                               idx = c("0","60"),
                               paired = FALSE)
  unpaired_mean_diff
  p<-median_diff(unpaired_mean_diff,reps=5000)
  plot(p,
       rawplot.ylim=c(6,12),effsize.ylim=c(-1,5),float.contrast = F
  )
}
pF <- LeverArm(d,"Formica")
pC <-  LeverArm(d,"Cataglyphis")
ggpubr::ggarrange(pC,pF)
```


# Body Height

```{r}
BodyHeight <- function(d,antsp){
  df <- subset(d,ant==antsp)
  unpaired_mean_diff <- dabest(df, slope, BodyHeight,
                               idx = c("0","60"),
                               paired = FALSE)
  unpaired_mean_diff
  p<-median_diff(unpaired_mean_diff,reps=5000)
  plot(p,
       rawplot.ylim=c(1.5,6),effsize.ylim=c(-2.5,2),float.contrast = F
  )
}
pF <- BodyHeight(d,"Formica")
pC <- BodyHeight(d,"Cataglyphis")
ggpubr::ggarrange(pC,pF)
```
