iii) Behavioural transitions
All analyses were performed using R v. 4.1.2 (R Core Team, 2013). We
determined the phylogenetic signal of larval social behaviour, as
estimated by Pagel’s λ (Pagel 1999), using both the ‘fitDiscrete’
function in geiger (Pennell et al. 2014) and ‘phylosig’ fromphytools (Revell, 2012). We also used ‘fitDiscrete’ to compare
models of evolutionary transition rates between solitary and gregarious
states throughout the phylogeny. We used a likelihood ratio test to
compare the null model, which assumes equal between-state transition
rates across the tree, against the all-rates-different model, which
assumes the between-state transition rate is different in either
direction. We then used the ‘make.simmap’ function in ape(Paradis and Schliep 2018) and the best-fitting transition rate model to
estimate the social behaviour character state at each node, and the
number of independent transitions to gregariousness throughout the
phylogeny. We constrained the root node to the solitary character state
based on estimations from a larger butterfly phylogeny that the last
common ancestor of Heliconiini was solitary with high (67%) confidence
(McLellan et al., 2023). This improved confidence in estimations around
basal nodes. When analysing categorical social behaviour, we used the
‘ace’ function in ape to estimate the most likely character
states at each node. This function does not allow the option to
constrain the root node, nor the use of the ‘all rates different’
evolution model with a multi-levelled, discrete variable. We therefore
performed the analyses under the ‘equal rates’ model. Additionally, we
performed phylogenetic pathway analyses (PPA) using the packagephylopath (von Hardenberg and Gonzalez-Voyer, 2013) on
categorical behavioural data and host plant usage data. Our first model
set exclusively tested social behavioural evolution, to test the
hypothesis that increasing levels of gregariousness evolves from
solitariness in a linear pattern. We included the number of larval host
plants used in our second model set to investigate the order in which
increased host specialisation and transitions to gregariousness
typically evolve.