-
Notifications
You must be signed in to change notification settings - Fork 0
/
abundance-density-tl.Rtex
1162 lines (770 loc) · 64.5 KB
/
abundance-density-tl.Rtex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%--------------------------------------------------------------------------------------------------------------------------------%
% Code and text for "A mechanistic model to compare the importance of interrelated population measures"
% by Tim CD Lucas, Hilde Herbots and Kate Jones
% See code chunk "settings" to see important switches (run large simulations or not etc.)
%
%---------------------------------------------------------------------------------------------------------------------------------%
\documentclass[11pt]{article}
\usepackage[sc]{mathpazo} %Like Palatino with extensive math support
\usepackage{fullpage}
\usepackage[authoryear,sectionbib,sort]{natbib}
\linespread{1.7}
\usepackage[utf8]{inputenc}
\usepackage{lineno}
\renewcommand{\refname}{Literature Cited}
\renewcommand{\cite}{\citep}
\usepackage[nomarkers, nolists,figuresonly]{endfloat}
\usepackage[width = 0.9\textwidth]{caption}
\usepackage{verbatim, graphicx, xcomment, array}
\usepackage{amsmath}
\DeclareGraphicsExtensions{pdf, eps, png}
\usepackage{booktabs}
\PassOptionsToPackage{hyphens}{url}
\usepackage[pdftex,hidelinks]{hyperref}
%%%%%%%%%%%%%%%%%%%%%
% Line numbering
%%%%%%%%%%%%%%%%%%%%%
%\usepackage{lineno}
% Please use line numbering with your initial submission and
% subsequent revisions. After acceptance, please turn line numbering
% off by adding percent signs to the lines %\usepackage{lineno} and
% to %\linenumbers{} and %\modulolinenumbers[3] below.
\title{Role of inter-related population-level host traits in determining pathogen richness and zoonotic risk}
% This version of the LaTeX template was last updated on
% April 28, 2017.
%%%%%%%%%%%%%%%%%%%%%
% Authorship
%%%%%%%%%%%%%%%%%%%%%
% Please remove authorship information while your paper is under review,
% unless you wish to waive your anonymity under double-blind review. You
% will need to add this information back in to your final files after
% acceptance.
\author{
Tim C.D. Lucas\textsuperscript{1,2,$\ast$}\\
Hilde M. Wilkinson-Herbots\textsuperscript{3}\\
Kate E. Jones\textsuperscript{2,4,$\ast$}
}
\date{}
\begin{document}
\maketitle
\noindent{} 1. Oxford Big Data Institute, Li Ka Shing Centre for Health Information and Discovery, University of Oxford, Oxford, OX3~7FZ, United Kingdom.;
\noindent{} 2. Centre for Biodiversity and Environment Research, Department of Genetics, Evolution and Environment, University College London, Gower Street, London, WC1E~6BT, United Kingdom
\noindent{} 3. Department of Statistical Science, University College London, Gower Street, London, WC1E~6BT, United Kingdom;
\noindent{} 4. Institute of Zoology, Zoological Society of London, Regent's Park, London, NW1~4RY, United Kingdom.
\noindent{} \textbf{ORCIDs} Lucas, 0000-0003-4694-8107. Jones, 0000-0001-5231-3293.
\noindent{} $\ast$ Corresponding authors; e-mail: [email protected], [email protected].
\bigskip
\textit{Word count}: 4371
\textit{Manuscript elements}: Figure~1, figure~2, table~1, online appendices~A and B (including figure~A1, figure~A2, figure~A3, figure~A4, table~A1, table~A2, table~A3 and table~A4). Figures~1 and 2 are to print in color.
\bigskip
\textit{Keywords}: Pathogen competition, zoonotic disease, metapopulations, host pathogen richness, bats, emerging infectious disease.
\bigskip
\textit{Manuscript type}: Article. %Or e-article, note, e-note, natural history miscellany, e-natural history miscellany, comment, reply, invited symposium, or countdown to 150.
\bigskip
\noindent{\footnotesize Prepared using the suggested \LaTeX{} template for \textit{Am.\ Nat.}}
\linenumbers{}
\modulolinenumbers[3]
\newpage{}
% running title: Population-level drivers of pathogen richness
%%begin.rcode settings, echo = FALSE, cache = FALSE, message = FALSE, results = 'hide'
####################################
### Important simulation options ###
####################################
# Compilation options
# Run simulations? This will take many hours
runAllSims <- FALSE
# Save raw simulation output
# This will take ~10GB or so.
# If false, summary statistics of each simulation are saved instead.
saveData <- FALSE
# Display extra figures in final documents?
extraFigs <- 'hide'
# How many cores do you want to use to run simulations?
nCores <- 8
##########################
### End options ###
##########################
opts_chunk$set(cache.path = '.abundanceCache/', fig.path = 'figure/')
source('misc/KnitrOptions.R')
%%end.rcode
%%begin.rcode ggplot, cache = FALSE
source('misc/theme_tcdl.R')
theme_set(theme_grey() + theme_pub)
%%end.rcode
%%begin.rcode libs, cache = FALSE, result = FALSE
# My package. For running and analysing Epidemiological sims.
# https://github.com/timcdlucas/metapopepi
library(MetapopEpi)
# Data manipulations
library(reshape2)
library(dplyr)
# Calc confidence intervals (could probably do with broom instead now.)
library(binom)
# To tidy up stats models/tests
library(broom)
# Run simulations in parallel
library(parallel)
# plotting
library(ggplot2)
library(palettetown)
# Get nice fonts in base graphics
library(showtext)
library(assertthat)
%%end.rcode
\section*{Abstract}
Zoonotic diseases are an increasingly important source of human infectious diseases, and host pathogen richness of reservoir host species is a critical driver of spill-over risk.
Population-level traits of hosts such as population size, host density and geographic range size have all been shown to be important determinants of host pathogen richness.
However, empirically identifying the independent influences of these traits has proven difficult as many of these traits directly depend on each other.
Here we develop a mechanistic, metapopulation, susceptible-infected-recovered model to identify the independent influences of these population-level traits on the ability of a newly evolved pathogen to invade and persist in host populations in the presence of an endemic pathogen.
We use bats as a case study as they are highly social and an important source of zoonotic disease.
We show that larger populations and group sizes had a greater influence on the chances of pathogen invasion and persistence than increased host density or the number of groups.
As anthropogenic change affects these traits to different extents, this increased understanding of how traits independently determine pathogen richness will aid in predicting future zoonotic spill-over risk.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section*{Introduction}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\tmpsection*{General Intro}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% A basic introduction to the field,
% comprehensible to a scientist in any discipline.
%1. Zoonotics important - determinants of pathogen richness important
% Pop-level is important as shown by corr studies.
% Sometimes the definitions are difficults
% While density been studied, population abundance has not despite being a fundementall characteristic.
Zoonotic diseases are a major source of human infectious disease \cite{jones2008global, taylor2001risk}.
Epidemics of emerging, zoonotic diseases pose a major threat to human health and economic development \cite{world2016ebola, ebola2015worldbank}.
The probability of zoonotic spill-over depends on, amongst other factors, the number of pathogen species carried by reservoir host species (pathogen richness) \cite{wolfe2000deforestation}.
Empirical, comparative studies across reservoir host species, suggest that host morphological and life-history traits, such as large body size and longevity, correlate strongly with high pathogen richness \cite{kamiya2014determines, luis2013comparison}.
However, traits related to reservoir host population biology are also expected to affect disease dynamics and therefore influence pathogen richness.
Population-level traits such as increased host density \cite{morand1998density, kamiya2014determines, nunn2003comparative}, large geographic range size \cite{nunn2003comparative, turmelle2009correlates, kamiya2014determines} and greater population structure (nonrandom interactions between individuals) \cite{maganga2014bat, turmelle2009correlates} have been shown to correlate with high pathogen richness, although the evidence for a relationship with group size (number of individuals in a social group) has been equivocal in many studies \cite{vitone2004body, gay2014parasite, rifkin2012animals, nunn2003comparative, turmelle2009correlates}.
Population size (total number of individuals), an important population-level trait, has rarely been included in comparative studies, despite its importance in describing epidemiological populations \cite{begon2002clarification}.
%4. then talk about the limitations of taking a comparative approach
Collinearity between explanatory variables is a common problem in correlative studies, and this issue is exacerbated when there are clear, causal relationships between explanatory variables.
There are two particularly clear relationships between the population-level traits associated with pathogen richness.
Firstly, host density, $d$, host population size, $N$, and geographic range size, $a$, are, by definition, linked by $d = N / a$ (see electronic supplementary material, table~S1 for all parameters used) and this relationship has broad empirical support \cite{blackburn2006variations}.
Secondly, host population size can be decomposed into two components, the number of groups, $m$, and the average size of a group, $n$, with $N = mn$.
%While less clear, geographic range size and host population structure are also related.
Correlative, comparative studies would be especially poor at identifying which, if any, of these traits causally affect pathogen richness.
This lack of discriminatory power is particularly important with respect to global change and its effects on zoonotic disease emergence.
Population-level traits such as population size and geographic range size, although interrelated, will respond differently to global change and the response will be species specific.
Some host species may suffer geographic range contractions while their density remains constant \cite{thomas2004extinction}.
Other host species might retain their geographic range but have a depressed population density \cite{craigie2010large}.
Only by knowing which of these interrelated traits control pathogen richness will we be able to predict future changes in pathogen richness.
%The alternative is mechanistic models.
Mechanistic models provide one method for comparing the importance of intrinsically related traits and can provide a deeper understanding of the system than correlative approaches.
Theoretical studies have established that a number of host population-level traits are important for epidemiological dynamics and the maintenance of pathogen richness.
In particular, host density, population structure and group size are well established as having central roles in pathogen dynamics \cite{colizza2007invasion, may1979population, anderson1979population, colizza2007invasion}.
A number of studies have found that increased host population structure can promote pathogen coexistence \cite{qiu2013vector, allen2004sis, nunes2006localized}.
While these studies have examined whether these population-level traits can promote pathogen richness, none have attempted to distinguish which might be the most important.
Mechanistic models that try to disentangle the interplay between population-level traits including host density, population size, geographic range size, group size and the number of groups are critically needed.
%7. what you are going to do that is new (ie tease apart these interdependencies) - using case study on bats (and why this is a good group to ask this particular question on)
Here, we use multipathogen models to individually vary host population-level traits.
We examine a simple deterministic model to establish whether a newly evolved pathogen can invade into an unstructured population in the presence of strong competition from an endemic pathogen strain.
We then examine a stochastic, metapopulation model that was parameterised to broadly mimic wild bat populations.
We used bats as a case study as group (colony) size is very variable between bat species and bat colonies are often very stable \cite{kerth2011bats, mccracken1981social, jones2009pantheria, kerth2008causes}.
Furthermore, bats are particularly relevant in the context of zoonotic disease as they are thought to be reservoirs for a number of recent, important outbreaks \cite{calisher2006bats, li2005bats}.
We examined how the interrelated population-level traits affect the ability of a newly evolved pathogen to invade and persist in a population.
We used these simulations to examine two specific hypotheses.
First, we investigated whether host population size or density more strongly promotes the invasion of a new pathogen.
Secondly, we investigated whether the invasion of a new pathogen is more strongly promoted by group size or the number of groups.
We found that population size has a much stronger effect on the invasion of a new pathogen than host density.
We also found that increasing population size by increasing group size promotes pathogen invasion much more than increasing population size by increasing the number of groups.
%%begin.rcode SimSetup
# These apply to both topo and disp sims. And probably should apply to extinction sims if I include them.
# How long should the simulation last?
nEvent <- 1.4e6
# When should the invading pathogen be added.
invadeT <- 6e5
# Total time
TotalTime <- 75
# Sims per parameter set.
each <- 100
# How often should the population be sampled. Only sampled populations are saved.
sample <- 1000
source('abundance-density-functions-tl.R')
%%end.rcode
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Constant density size.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%begin.rcode DensSimsFuncs
#################################
# Density sim definitions #
#################################
# Keep density constant. Alter population size via colonySize
# How many simulations to run?
nDensSims <- 15 * each
# Parameters for constant density
# Area and meanColonySize are the actal input arguments
pop <- rep(c(2000, 4000, 8000, 16000, 32000), each = 3 * each)
colonySize <- pop / 20
# make a copy of colonySize for use in text.
dep1 <- unique(colonySize)
area <- pop / 0.8
side <- sqrt(area)
tran <- rep(c(0.1, 0.2, 0.3), times = 5 * each)
%%end.rcode
%%begin.rcode runDensSim, eval = runAllSims, cache = TRUE
# Create and set seed (seed object is used to set seed in each separate simulation.'
seed <- 1
set.seed(seed)
# If we want to save the data, make a directory for it.
if(saveData){
dir.create('Data/fullsimoutput/')
}
# Run sims.
z <- mclapply(1:nDensSims, . %>% fullSim1, mc.preschedule = FALSE, mc.cores = nCores)
z <- do.call(rbind, z)
# Save summary data.
write.csv(z, file = 'Data/DensSims.csv')
%%end.rcode
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Constant density 2.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%begin.rcode Dens2SimsFuncs
#################################
# Density2 sim definitions #
#################################
# Keep density constant. Alter population size via colonyNumber
# How many simulations to run?
nDens2Sims <- 15 * each
# Parameters for constant density
# Area and meanColonySize are the actal input arguments
pop <- rep(c(2000, 4000, 8000, 16000, 32000), each = 3 * each)
colonySize <- 400
colonyNumber <- pop / colonySize
# make a copy of colony number for use in text
dep2 <- unique(colonyNumber )
area <- pop / 0.8
side <- sqrt(area)
tran <- rep(c(0.1, 0.2, 0.3), times = 5 * each)
%%end.rcode
%%begin.rcode runDens2Sim, eval = runAllSims, cache = TRUE
# Create and set seed (seed object is used to set seed in each separate simulation.'
seed <- 2
set.seed(seed)
# Run sims.
z <- mclapply(1:nDens2Sims, . %>% fullSim2, mc.preschedule = FALSE, mc.cores = nCores)
z <- do.call(rbind, z)
# Save summary data.
write.csv(z, file = 'Data/Dens2Sims.csv')
%%end.rcode
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Constant Population.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%begin.rcode PopSimsFuncs
#################################
# Population sim definitions #
#################################
# Keep population constant. Alter density by area
# How many simulations to run?
nPopSims <- 15 * each
# Parameters for constant density
# Area and meanColonySize are the actal input arguments
pop <- 8000
colonySize <- pop / 20
area <- rep(c(40000, 20000, 10000, 5000, 2500), each = 3 * each)
side <- sqrt(area)
# save density values for use in text.
dep3 <- c(40000, 20000, 10000, 5000, 2500)
depDens <- pop / dep3
tran <- rep(c(0.1, 0.2, 0.3), times = 5 * each)
%%end.rcode
%%begin.rcode runPopSim, eval = runAllSims, cache = TRUE
# Create and set seed (seed object is used to set seed in each separate simulation.'
seed <- 3
set.seed(seed)
# Run sims.
z <- mclapply(1:nPopSims, . %>% fullSim3, mc.preschedule = FALSE, mc.cores = nCores)
z <- do.call(rbind, z)
# Save summary data.
write.csv(z, file = 'Data/PopSims.csv')
%%end.rcode
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section*{Methods}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[t]
\centering
\includegraphics[width=0.4\textwidth]{figure/SIRoption1}
\caption[Schematic of the two-pathogen SIR model used]{
Schematic of the two-pathogen SIR model used.
Individuals are in one of five epidemiological classes, susceptible (orange, $S$), infected with Pathogen~1, Pathogen~2 or both (blue, $I_1, I_2, I_{12}$, respectively) or recovered and immune from further infection (green, $R$).
Transitions between classes occur as indicated by solid arrows and depend on transmission rate ($\beta$), coinfection adjustment factor ($\alpha$) and recovery rate ($\gamma$).
Births ($\Lambda$) and deaths ($\mu$) are indicated by dashed arrows.
%Parameter symbols for transitions are indicated.
Note that individuals in $I_{12}$ move into $R$, not back to $I_1$ or $I_2$.
That is, recovery from one pathogen causes immediate recovery from the other pathogen.
}
\label{f:sir}
\end{figure}
\subsection*{Two pathogen SIR model}
We developed a multipathogen, susceptible-infected-recovered (SIR) compartment model to examine the probability that a newly evolved pathogen would invade and persist into a population in the presence of an identical, endemic pathogen.
Susceptible individuals were counted in class $S$ (figure~\ref{f:sir}) while infected individuals were counted in classes $I_1$, $I_2$ and $I_{12}$, being individuals infected with Pathogen~1, Pathogen~2 or both, respectively.
Recovered individuals, $R$, were immune to both pathogens, even if they had only been infected by one (i.e.\ there was complete cross-immunity).
Furthermore, recovery from one pathogen moved an individual into the recovered class, even if the individual was coinfected (figure~\ref{f:sir}).
Though our study was restricted to two pathogens, this modelling choice allows the model to be easily expanded to include many pathogens.
Our assumption of immediate recovery from all other pathogens is likely to be reasonable \cite{munywoki2015influence} as any up-regulation of innate immune response or acquired immunity would affect both pathogens equally.
The coinfection rate (the rate at which an infected individual is infected with a second pathogen) was adjusted compared to the infection rate by a factor $\alpha$.
Birth rate ($\Lambda$) was set equal to the death rate ($\mu$), meaning the population did not systematically increase or decrease.
New born individuals entered the susceptible class.
Infection and coinfection were assumed not to cause increased mortality as bats show no clinical signs of infection for a number of viruses \cite{halpin2011pteropid, deThoisy2016bioecological}.
Population structure is present in bat populations as demonstrated by the existence of subspecies, measurements of genetic dissimilarity and behavioural studies \cite{kerth2011bats, mccracken1981social, burns2014correlates}.
Therefore assuming a fully-mixed population is an oversimplification.
Consequently, the population was modelled as a metapopulation network with groups being nodes and dispersal between groups being indicated by edges (electronic supplementary material, figure~S1).
Individuals within a group interacted randomly so that the group was fully mixed.
Dispersal occurred at a rate $\xi$ between groups connected by an edge in the network.
The dispersal rate from a group $y$ with degree $k_y$ to group $x$ was $\xi / k_y$.
Note that this rate was not affected by the degree and size of group $x$ and the total rate of dispersal was not affected by the degree of a group.
We examined the full model using stochastic, continuous-time simulations, in \emph{R} \cite{R, metapopepi}.
The full details of the model are given in electronic supplementary material~S1.
\subsection*{Deterministic model}
\label{s:determ}
We examined a single-group, deterministic model to establish a baseline expectation for whether a newly evolved pathogen strain could invade into a population in the presence of an identical strain given the assumptions of our two-pathogen SIR model (for details see electronic supplementary material~S2).
If we first consider the endemic pathogen (Pathogen~1) we have a typical SIR model with vital dynamics \cite{Kermack1932} with equilibrium values $S^\ast = \frac{\mu + \gamma}{\beta}$ and $I_1^\ast = \frac{\Lambda n}{\gamma + \mu} - \frac{\mu }{\beta}$ where $\beta$ and $\gamma$ are the transmission and recovery rates and $n$ is the group size.
When Pathogen~2 is introduced, its rate of change can be written as
\begin{align}
\frac{dI_2}{dt} & = \beta S^\ast I_2 + \alpha \beta I_1^\ast I_2 - (\gamma + \mu) I_2 \label{path2I}
\end{align}
which is greater than zero when $\alpha\left( \Lambda R_0 - \mu \right) I_2 > 0$ (with $R_0 = \frac{\beta N }{\gamma + \mu}$ being the basic reproduction number and being equal for the two identical pathogens).
As $\Lambda = \mu$ due to the assumption of a stable population size, $\Lambda R_0 - \mu$ is greater than zero,
Therefore, $\frac{dI_2}{dt}$ is greater than zero provided $\alpha$ is greater than zero.
That is, provided cross-immunity is not complete, Pathogen~2 will invade in this deterministic model.
This means that it is only stochastic extinction that would prevent a pathogen from invading into a population.
Our more detailed simulations are therefore examining how effectively different population-level traits alleviate stochastic extinction or allow longer term persistence.
\subsection*{Parameter selection}
\label{s:paramSelect}
While some fixed parameters were chosen to approximate those found in wild bat populations, others were chosen for modelling reasons.
Assuming equal birth and death rates, $\Lambda$ and $\mu$, were both set to 0.05 per year giving a generation time of 20 years \cite{jones2009pantheria, kerth2008causes}.
Setting birth and death rates equal gives a stochastically varying population size but given the length of the simulations groups were very unlikely to go extinct.
Although it is difficult to directly estimate infection durations in wild bat populations \cite{plowright2015ecological}, evidence suggests these can be on the scale of days \cite{amengual2007temporal} up to months or years \cite{peel2012henipavirus, sohayati2011evidence, rahman2010characterization}.
Here we set the infection duration, $\frac{1}{\gamma}$, to one year which is a long lasting, but non-chronic, infection.
As estimating transmission rates is particularly difficult we used three values of the transmission rate, $\beta$: 0.1, 0.2 and 0.3.
These values were chosen as very high values of $R_0$ were required so that a reasonable number of simulations experienced an invasion of Pathogen~2.
The coinfection adjustment parameter, $\alpha$, was set to 0.1.
%Therefore, an individual with a single infection was 90\% less likely to gain a second infection.
The deterministic model showed that $\alpha = 0$ and $\alpha > 0$ are qualitatively different with the number of individuals infected with Pathogen~2 being stable and increasing respectively.
The case where Pathogen~2 does not invade and spread ($\alpha = 0$) is not important for pathogen richness so we chose a small, non-zero value for $\alpha$.
The dispersal rate, $\xi$, was set to 0.01 which yields 17\% of individuals dispersing in their lifetime.
This relates to a species with juvenile dispersal of a proportion of males and very few females \cite{kerth2008causes, chen2008sex}.
%\subsection*{Population-level factors} % This isn't a full subsection...
The effect of geographic range size on disease dynamics occurred through changes in the metapopulation network.
Dispersal was only allowed to occur between two groups if they were connected nodes in the metapopulation network.
The metapopulation network was created for each simulation by randomly placing groups in a square space which represented the geographic range of the species (electronic supplementary material, figure~S1).
Groups within a threshold distance of each other were connected in the metapopulation network.
This meant that the metapopulation network was not necessarily connected (made up of a single connected component).
To ensure connected metapopulation networks would have required repeatedly resampling the group locations until a connected metapopulation occurred.
However, this would have biased the mean degree, $\bar{k}$.
Therefore, it was considered preferential to keep the unconnected networks.
\subsection*{Experimental setup}
A total of 4500 simulations were run.
In each simulation, each group in the host population was seeded with 20 individuals infected with Pathogen~1.
A `burn-in' of \rinline{invadeT} events was run to allow Pathogen~1 to spread and reach equilibrium.
Plotting of preliminary simulations was used to determine that \rinline{invadeT} events was enough to ensure equilibrium.
After this burn-in, five host individuals infected with Pathogen~2 were added to one randomly selected group.
The invasion and persistence of Pathogen~2 was considered successful if any individuals infected with Pathogen~2 remained at the end of the simulation.
As simulations with many individuals and infection events had more events per unit time, the end of the simulation had to be defined in terms of time rather than the number of events.
Simulations were run until \rinline{TotalTime} years had elapsed since the introduction of Pathogen~2.
This value was chosen so that pathogens had to persist for multiple host generations in order to be considered persistent.
%The results were also checked to confirm that decreasing this value did not qualitatively change the results.
Three sets of 1500 simulations were run in which three population parameters were varied: (\emph{i}) geographic range size (with corresponding change in host density), (\emph{ii}) group size (with corresponding change in population size), and (\emph{iii}) the number of groups (with corresponding change in population size).
To allow comparisons between simulation sets, the parameter that was being varied in each set was assigned its default value multiplied by 0.25, 0.5, 1, 2 and 4.
To examine whether host density had a stronger effect on pathogen invasion than population size, results from simulation set \emph{i} were compared to those from sets \emph{ii} and \emph{iii}.
To examine whether group size or the number of groups was the more important component of population size, results from simulation set \emph{ii} were compared to those from \emph{iii}.
%The default geographic range size was 10000 km\textsuperscript{2} with a range of 2500--40000 km\textsuperscript{2}.
The spatial scale is arbitrary; only the ratio between the geographic range size and the threshold distance for groups being connected in the metapopulation network had any effect on simulation outcomes.
We parameterised the spatial scale by arbitrarily selecting a threshold distance of 100 km. .
The default (10000 km\textsuperscript{2}) and upper and lower bounds of the geographic range size (2500--40000 km\textsuperscript{2}) were then selected to maximise the range of $\bar{k}$ (electronic supplementary material, figure~S2) while not having many simulations with networks that were unconnected.
That is, we aimed for low host density populations to have relatively sparse population networks, while high host density populations had fully-connected metapopulation networks.
This reflects the existence of both isolation-by-distance \cite{chen2008sex, o2015genetic, vonhof2015range} and panmixia \cite{peel2013continent, petit1999male, calisher2006bats} in bat species.
The default group size was 400 with a range of 100--1600 which is representative of many bat species \cite{jones2009pantheria}.
The default number of groups was 20 with a range of 5--80.
This minimum value is close to the minimum possible for the population to still be considered a metapopulation, while the maximum value was constrained by computational costs.
In the first set of simulations (\emph{i}), host density was varied by keeping population size constant ($N$ = 8000, $n$ = 400, $m$ = 20) while varying geographic range size.
The values of geographic range size used were 2500, 5000, 10000, 20000 and 40000 km\textsuperscript{2} which gave density values of \rinline{depDens[5:2]} and \rinline{depDens[1]} animals per km\textsuperscript{2}.
In the second set of simulations (\emph{ii}), population size was varied by changing group size while the number of groups was kept constant.
To keep host density constant, geographic range size was increased as population size increased.
The values of group size used were 100, 200, 400, 800 and 1600 while geographic range size was set to 2500, 5000, 10000, 20000 and 40000 km\textsuperscript{2}.
This gave population sizes of 2000, 4000, 8000, 16000 and 32000 while host density remained at 0.8 hosts per km\textsuperscript{2}.
In the third set of simulations (\emph{iii}), population size was varied by changing the number of groups while group size was kept constant.
Again, to keep host density constant, geographic range size was increased as population size increased.
The numbers of groups used were 5, 10, 20, 40 and 80 while geographic range size was set to 2500, 5000, 10000, 20000 and 40000 km\textsuperscript{2}.
Again, this gave population sizes of 2000, 4000, 8000, 16000 and 32000 while host density remained at 0.8 hosts per km\textsuperscript{2}.
%%begin.rcode calcMeans
# Constant density, altered colony size
# Need to remove rows with errors to auto find classes of columns
dens1text <- readLines('Data/DensSims.csv')
rmerrors <- dens1text[!grepl('Error in', dens1text)]
rmerrors <- rmerrors[nchar(rmerrors) > 3]
dens1 <- read.csv(text = rmerrors) %>%
dplyr::select(-X)
dens1Means <- dens1 %>%
#dplyr::filter(nExtantDis > 0) %>%
group_by(transmission, colonySize, colonyNumber) %>%
summarise(success = sum(nExtantDis == 2), sampleSize = n(), pop = mean(pop)) %>%
ungroup %>%
cbind(., vary = 'colonySize', binom.confint(.$success, .$sampleSize, conf.level = 0.95, methods = "exact"))
# fit glms to each transmission value
colonySizeModel <- dens1 %>%
mutate(invasion = nExtantDis == 2 ) %>%
mutate(ValueChange = log2(colonySize / median(colonySize))) %>%
#filter(nExtantDis != 0) %>%
group_by(transmission) %>%
do(glm(invasion ~ ValueChange, data = ., family = 'binomial') %>% tidy(conf.int = TRUE))
colonySizePredictions <- dens1 %>%
mutate(invasion = nExtantDis == 2 ) %>%
mutate(ValueChange = colonySize / median(colonySize)) %>%
#filter(nExtantDis != 0) %>%
group_by(transmission) %>%
do(augment(glm(invasion ~ log2(ValueChange), data = ., family = 'binomial'),
newdata = data.frame(ValueChange = seq(min(.$ValueChange), max(.$ValueChange),
length.out = 1000)),
type.predict = 'response')) %>%
mutate(vary = 'colonySize')
# Constant density, altered colony number
dens2 <- read.csv('Data/Dens2Sims.csv') %>% dplyr::select(-X) %>% as.data.frame
dens2Means <- dens2 %>%
#dplyr::filter(nExtantDis > 0) %>%
group_by(transmission, colonySize, colonyNumber) %>%
summarise(success = sum(nExtantDis == 2), sampleSize = n(), pop = mean(pop)) %>%
ungroup %>%
cbind(., vary = 'colonyNumber', binom.confint(.$success, .$sampleSize, conf.level = 0.95, methods = "exact"))
# Fit glms to each transmission value
colonyNumberModel <- dens2 %>%
mutate(invasion = nExtantDis == 2 ) %>%
mutate(ValueChange = log2(colonyNumber / median(colonyNumber))) %>%
#filter(nExtantDis != 0) %>%
group_by(transmission) %>%
do(glm(invasion ~ ValueChange, data = ., family = 'binomial') %>% tidy(conf.int = TRUE))
colonyNumberPredictions <- dens2 %>%
mutate(invasion = nExtantDis == 2 ) %>%
mutate(ValueChange = colonyNumber / median(colonyNumber)) %>%
#filter(nExtantDis != 0) %>%
group_by(transmission) %>%
do(augment(glm(invasion ~ log2(ValueChange), data = ., family = 'binomial'),
newdata = data.frame(ValueChange = seq(min(.$ValueChange), max(.$ValueChange),
length.out = 1000)),
type.predict = 'response')) %>%
mutate(vary = 'colonyNumber')
# Constant population, altered area
pop <- read.csv('Data/PopSims.csv') %>% dplyr::select(-X) %>% as.data.frame
popMeans <- pop %>%
#dplyr::filter(nExtantDis > 0) %>%
group_by(transmission, dens) %>%
summarise(success = sum(nExtantDis == 2), sampleSize = n()) %>%
ungroup %>%
cbind(., binom.confint(.$success, .$sampleSize, conf.level = 0.95, methods = "exact"))
# fit glms to each transmission value
areaModel <- pop %>%
mutate(invasion = nExtantDis == 2 ) %>%
mutate(ValueChange = log2(dens / median(dens))) %>%
#filter(nExtantDis != 0) %>%
group_by(transmission) %>%
do(glm(invasion ~ ValueChange, data = ., family = 'binomial') %>% tidy(conf.int = TRUE))
areaPredictions <- pop %>%
mutate(invasion = nExtantDis == 2 ) %>%
mutate(ValueChange = dens / median(dens)) %>%
#filter(nExtantDis != 0) %>%
group_by(transmission) %>%
do(augment(glm(invasion ~ log2(ValueChange), data = ., family = 'binomial'),
newdata = data.frame(ValueChange = seq(min(.$ValueChange), max(.$ValueChange),
length.out = 1000)),
type.predict = 'response')) %>%
mutate(vary = 'Density')
%%end.rcode
%%begin.rcode descriptive
meanDefault <- rbind(dens1, dens2, pop) %>%
filter(colonyNumber == 20, colonySize == 400, dens == 0.8) %>%
group_by(transmission) %>%
summarise(mean = mean(nExtantDis == 2))
transTest <- rbind(dens1, dens2, pop) %>%
filter(colonyNumber == 20, colonySize == 400, dens == 0.8) %>%
mutate(invasion = nExtantDis == 2) %>%
glm(invasion ~ transmission, data = .) %>%
tidy
nAllExtinct <- rbind(dens1, dens2, pop) %>%
filter(nExtantDis == 0) %>%
nrow
whichTransAllExtinct <- rbind(dens1, dens2, pop) %>%
filter(nExtantDis == 0) %>%
group_by(transmission) %>%
summarise(n = n())
transExtinctTest <- rbind(dens1, dens2, pop) %>%
mutate(doubleExtinct = nExtantDis == 0) %>%
glm(doubleExtinct ~ transmission, data = .) %>%
tidy
smallAllExtinct <- rbind(dens1, dens2, pop) %>%
filter(nExtantDis == 0, colonySize == 100) %>%
summarise(n = n())
fewAllExtinct <- rbind(dens1, dens2, pop) %>%
filter(nExtantDis == 0, colonyNumber == 5) %>%
summarise(n = n())
%%end.rcode
%%begin.rcode plotKcapt
plotKcapt <- '
Change in average metapopulation network degree ($\\bar{k}$) with increasing geographic range size.
Bars show the median, boxes show the interquartile range, vertical lines show the range and grey dots indicate outlier values.
Notches indicate the 95\\% confidence interval of the median.
All simulations had 20 groups, meaning 19 is the maximum value of $\\bar{k}$.
'
plotKtitle <- 'Change in average network degree with increasing geographic range size'
%%end.rcode
%%begin.rcode plotK, fig.cap = plotKcapt, fig.scap = plotKtitle, out.width = '0.4\\textwidth', cache = FALSE, plot.height = 2.3, fig.show = 'hide'
ggplot(dens1, aes(x = factor(area), y = meanK, colour = 'a', fill = 'a')) +
geom_boxplot(outlier.size = 1, size = 0.3, outlier.colour = grey(0.3),
notch = TRUE, width = 0.4, notchwidth = 0.6) +
scale_colour_manual(values = pokepal('vileplume')[4]) +
scale_fill_manual(values = pokepal('vileplume')[7]) +
stat_summary(geom = "crossbar", width = 0.2, fatten = 2,
fun.data = function(x){ return(c(y = median(x), ymin = median(x), ymax = median(x))) }) +
theme(legend.position = 'none', panel.grid.major.x = element_blank()) +
scale_x_discrete(labels = c('2500', '5000', '10000', '20000', '40000')) +
xlab(expression(paste('Area ', (km^2)))) +
ylab(expression(paste('Mean degree, ', italic(bar(k))))) +
ylim(0, 20)
%%end.rcode
%%begin.rcode transMeansCapt
transMeansCapt <- '
Comparison of the effect of host population size on probability of invasion when population size is altered by changing group size or number of groups.
Relationships are shown separately for each transmission value, $\\beta$.
It can be seen that changes in group size give a much greater increase in invasion probability than changes in group number.
Note that this is the same data as figure~\\ref{fig:plotValueChangeMeans} but with the $x$-axis scaled by population size, rather than relative parameter change.
'
transMeansTitle <- 'Comparison of the probability of the affect of group size and number of groups on probability of invasion'
%%end.rcode
%%begin.rcode plotTransMeans, fig.cap = transMeansCapt, fig.scap = transMeansTitle, out.width = '0.4\\textwidth', fig.show = TRUE, cache = FALSE, fig.height = 4, fig.show = 'hide'
# Convert to percentage change in density, colonysize or colony number.
d2 <- rbind(dens1Means %>%
mutate(ValueChange = colonySize/median(colonySize), vary = 'colonySize') %>%
dplyr::select(pop, transmission, mean, lower, upper, vary),
dens2Means %>%
mutate(ValueChange = colonyNumber/median(colonyNumber), vary = 'colonyNumber') %>%
dplyr::select(pop, transmission, mean, lower, upper, vary)
)
d2$vary <- factor(d2$vary, levels = unique(d2$vary)[c(2, 3, 1)])
d2$transmission <- factor(d2$transmission, labels = c('beta == 0.1', '0.2', '0.3'))
# Join predictions
colonySizePredictions2 <- dens1 %>%
mutate(invasion = nExtantDis == 2 ) %>%
#filter(nExtantDis != 0) %>%
group_by(transmission) %>%
do(augment(glm(invasion ~ pop, data = ., family = 'binomial'),
newdata = data.frame(pop = seq(min(.$pop), max(.$pop),
length.out = 1000)),
type.predict = 'response')) %>%
mutate(vary = 'colonySize')
colonyNumberPredictions2 <- dens2 %>%
mutate(invasion = nExtantDis == 2 ) %>%
#filter(nExtantDis != 0) %>%
group_by(transmission) %>%
do(augment(glm(invasion ~ pop, data = ., family = 'binomial'),
newdata = data.frame(pop = seq(min(.$pop), max(.$pop),
length.out = 1000)),
type.predict = 'response')) %>%
mutate(vary = 'colonyNumber')
percChangePreds2 <- rbind(colonySizePredictions2, colonyNumberPredictions2)
percChangePreds2$transmission <- factor(percChangePreds2$transmission, labels = c('beta == 0.1', '0.2', '0.3'))
ggplot(d2, aes(x = pop, y = mean, colour = vary)) +
geom_line(data = percChangePreds2, aes(x = pop, y = .fitted, colour = vary)) +
geom_point() +
geom_errorbar(aes(ymin = lower, ymax = upper),
width=.2) +
ylab('Prob. Invasion') +
xlab('Population size') +
ylim(0, 1) +
scale_colour_manual(name = "Population-level trait",
labels = c('Number of groups', 'Group size'),
values = pokepal('Swampert', spread = 3)[2:1]) +
scale_y_continuous(breaks = c(0, 0.5, 1), labels = c('0.0', '0.5', '1.0')) +
scale_x_continuous(limits = c(0, 32000),
breaks = c(0, 1e4, 2e4, 3e4),
label = c('0', '10000', '20000', '30000')) +
facet_grid(transmission ~ ., labeller = label_parsed) +
theme(legend.position = 'bottom', legend.direction = 'vertical')
%%end.rcode
\subsection*{Statistical analysis}
For each set of simulations, we fitted binomial GLMs in R \cite{R} with the proportion of invasions of Pathogen~2 as the response variable.
To enable comparison between GLMs we divided the explanatory variables by their default values and $\log_2$ transformed.
The explanatory variables for all three sets of simulations therefore became evenly spaced between -2 and 2.
To investigate whether an increase in host population size created a stronger increase in probability of pathogen invasion than an equal increase in host density we compared the size (and 95\% confidence intervals) of the regression coefficients of host density (\emph{i}) to group size (\emph{ii}) and number of groups (\emph{iii}).
To examine whether an increase in group size creates a stronger increase in invasion probability than a proportionally equal increase in number of groups we compared regression coefficients of group size (\emph{ii}) to number of groups (\emph{iii}).
%In \rinline{nAllExtinct} out of 4500 simulations, both pathogens went extinct (electronic supplementary material, tables~S2--4).
%Of these simulations, 29 were in set \emph{ii} and eight were in set \emph{iii}.
%All \rinline{nAllExtinct} simulations had either the smallest group size (\rinline{smallAllExtinct} simulations in set \emph{ii} with $n$ = 100,) or the fewest number of groups (eight simulations in set \emph{iii} with $m = 5$).
%However, the number of simulations in which both pathogens went extinct did not significantly depend on transmission rate (GLM: coefficient = \rinline{transExtinctTest$estimate[2]}, $p$ = \rinline{transExtinctTest$p.value[2]}).
%Results from these simulations were retained in the statistical analysis as they still represented the case where Pathogen~2 did not invade and persist.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section*{Results}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%begin.rcode valueChangeMeansCapt
valueChangeMeansCapt <- '
Comparison of the effect of population-level traits on probability of invasion.
Population-level traits are group size (green lines, squares), number of groups (blue lines, circles) and host density (yellow lines, triangles).
The $x$-axis shows the change ($\\times$0.25, 0.5, 1, 2 and 4) in each of these traits relative to the default value.
Default values are: number of groups = 20, group size = 400 and host density = 0.8 animals per km\\textsuperscript{2}.
Each point is the mean of 100 simulations and bars are 95\\% confidence intervals.
Each curve was obtained by fitting a binomial GLM.
Relationships are shown separately for each transmission value, $\\beta$.
'
valueChangeMeansTitle <- 'Comparison of the effect of group size, number of groups and host density on probability of invasion'
%%end.rcode
%%begin.rcode plotValueChangeMeans, fig.cap = valueChangeMeansCapt, fig.scap = valueChangeMeansTitle, out.width = '0.5\\textwidth', cache = FALSE, fig.height = 6
# Convert to percentage change in density, colonysize or colony number.
d <- rbind(popMeans %>%
mutate(ValueChange = dens/median(dens), vary = 'Density') %>%
dplyr::select(ValueChange, transmission, mean, lower, upper, vary),
dens1Means %>%
mutate(ValueChange = colonySize/median(colonySize), vary = 'colonySize') %>%
dplyr::select(ValueChange, transmission, mean, lower, upper, vary),
dens2Means %>%
mutate(ValueChange = colonyNumber/median(colonyNumber), vary = 'colonyNumber') %>%
dplyr::select(ValueChange, transmission, mean, lower, upper, vary)
)
d$vary <- factor(d$vary, levels = unique(d$vary)[c(2, 3, 1)])
d$transmission <- factor(d$transmission, labels = c('beta == 0.1', '0.2', '0.3'))
# Join predictions
percChangePreds <- rbind(colonySizePredictions, colonyNumberPredictions, areaPredictions)
percChangePreds$vary <- factor(percChangePreds$vary, levels = levels(d$vary))
percChangePreds$transmission <- factor(percChangePreds$transmission, labels = c('beta == 0.1', '0.2', '0.3'))
ggplot(d, aes(x = ValueChange, y = mean, colour = vary, shape = vary)) +
geom_line(data = percChangePreds, aes(x = ValueChange, y = .fitted, colour = vary)) +
geom_errorbar(aes(ymin = lower, ymax = upper),
width = .04,
position = position_dodge(width = 0.04)) +
geom_point(size = 2.1, position = position_dodge(width = 0.04)) +
ylab('Prob. Invasion') +
xlab('Relative change') +
scale_colour_poke(name = 'Population-level trait',
labels = c( 'Group size', 'Number of groups', 'Host density'),
pokemon = 'oddish',
spread = 3) +
scale_shape_manual(name = 'Population-level trait',
labels = c( 'Group size', 'Number of groups', 'Host density'),
values = 15:17) +
scale_y_continuous(breaks = c(0, 0.5, 1),
labels = c('0.0', '0.5', '1.0'),
limits = c(0, 1)) +
scale_x_continuous(breaks = c(0.25, 0.5, 1, 2, 4),
labels = c(0.25, 0.5, 1, 2, 4),
trans = 'log2') +
facet_grid(transmission ~ ., labeller = label_parsed) +
theme(legend.position = 'bottom', legend.direction = 'vertical')
%%end.rcode
\subsection*{Population size and host density}
The estimated GLM coefficients were always larger for simulations where population size was varied (sets \emph{ii} and \emph{iii}) than when host density (set \emph{i}) was varied (table~\ref{t:regrCoefs}, electronic supplementary material figure~S3).
Increasing population size, either by increasing group size or number of groups, increased the probability of invasion (figure~\ref{fig:plotValueChangeMeans}).
The positive relationship between group size and invasion was strong and significant at all transmission rates, while the relationship between number of groups and invasion was weaker but still significant.
In contrast, varying host density did not significantly alter invasion probability except for when $\beta = 0.3$ where there was a significant decrease in invasion probability with increased host density (GLM: coefficient = $\rinline{areaModel$estimate[6]}$, $p$ = \rinline{areaModel$p.value[6]}).
The 95\% confidence intervals for the coefficients of group size did not overlap with those for the coefficients of host density at any value of $\beta$ while the 95\% confidence intervals for coefficients of number of groups only overlapped with those for host density at $\beta = 0.2$.
\subsection*{Group size and number of groups}