Chapter 9 Behavioural differences

9.1 Behavioral index

Index that aggregates bites, hisses, retreats and avoidance traits into a single continuous scale ranging between 0 (tame) and 1 (aggressive).

sample_metadata %>% 
        rowwise() %>%
        mutate(behaviour = sum(c_across(c(bites, hisses,retreats,avoidance))/4, na.rm = TRUE)) %>%
        ungroup() %>% 
        mutate(sex = factor(sex)) %>% 
        dplyr::select(origin,behaviour) %>% 
        ggplot(aes(x=origin,y=behaviour,group=origin)) + 
            geom_dotplot(binaxis='y', 
               stackdir='center', 
               dotsize = .4,
               fill="grey") + 
        theme_classic()

9.2 Bites

sample_metadata %>% 
    select(origin, bites) %>% 
    group_by(origin, bites) %>%
    summarise(count = n(), .groups = "drop") %>%
    pivot_wider(names_from = bites, values_from = count, values_fill = 0) %>%
    rename(NoBites = `0`, Bites = `1`) %>% 
    select(NoBites, Bites) %>%
    as.matrix() %>% 
    chisq.test() %>% 
    tidy()
# A tibble: 1 × 4
  statistic  p.value parameter method                                                      
      <dbl>    <dbl>     <int> <chr>                                                       
1      11.8 0.000590         1 Pearson's Chi-squared test with Yates' continuity correction

9.3 Hisses

sample_metadata %>% 
    select(origin, hisses) %>% 
    group_by(origin, hisses) %>%
    summarise(count = n(), .groups = "drop") %>%
    pivot_wider(names_from = hisses, values_from = count, values_fill = 0) %>%
    rename(NoHisses = `0`, Hisses = `1`) %>% 
    select(NoHisses, Hisses) %>%
    as.matrix() %>% 
    chisq.test() %>% 
    tidy()
# A tibble: 1 × 4
  statistic  p.value parameter method                                                      
      <dbl>    <dbl>     <int> <chr>                                                       
1      11.2 0.000809         1 Pearson's Chi-squared test with Yates' continuity correction

9.4 Retreats

sample_metadata %>% 
    select(origin, retreats) %>% 
    group_by(origin, retreats) %>%
    summarise(count = n(), .groups = "drop") %>%
    pivot_wider(names_from = retreats, values_from = count, values_fill = 0) %>%
    rename(NoRetreats = `0`, Retreats = `1`) %>% 
    select(NoRetreats, Retreats) %>%
    as.matrix() %>% 
    chisq.test() %>% 
    tidy()
# A tibble: 1 × 4
  statistic p.value parameter method                                                      
      <dbl>   <dbl>     <int> <chr>                                                       
1      5.44  0.0197         1 Pearson's Chi-squared test with Yates' continuity correction

9.5 Fear

sample_metadata %>% 
    select(origin, avoidance) %>% 
    group_by(origin, avoidance) %>%
    summarise(count = n(), .groups = "drop") %>%
    pivot_wider(names_from = avoidance, values_from = count, values_fill = 0) %>%
    rename(NoAvoidance = `0`, Avoidance = `1`) %>% 
    select(NoAvoidance, NoAvoidance) %>%
    as.matrix() %>% 
    chisq.test() %>% 
    tidy()
# A tibble: 1 × 4
  statistic   p.value parameter method                                  
      <dbl>     <dbl>     <dbl> <chr>                                   
1      15.5 0.0000820         1 Chi-squared test for given probabilities