DOI: 10.5061/dryad.18931zd5j
title: Code from: Costs of parasite generalism revealed by abundance patterns across mammalian hosts

description: Most parasites are able to infect several host species, yet generalism is
 anticipated to be a costly strategy. Parasite abundance provides
 an important indicator of fitness because it is promoted by longevity and
 fecundity, which are correlated with a parasite’s basic reproductive
 number. Using a global database of parasitic helminths of terrestrial
 mammals, we show that the abundance of parasitic helminths is
 phylogenetically structured across helminth species. High parasite
 abundance can be achieved through three separate components: infecting
 abundant host species, having a high infection success (prevalence), or
 achieving high parasite abundance within host individuals (infection
 intensity). Both phylogenetically specialist and generalist strategies can
 reach high abundances, but through different strategies. Specialist
 parasites achieve higher abundance than generalists on their principal
 host species but rely on host relatedness to infect multiple species. For
 generalist parasites, geographic overlap with, and diet similarity to
 principal host species are better predictors of parasite abundance. This
 study characterizes constraints on parasite host range and provides novel
 context to evaluate the potential for parasites to establish in new host
 species.
description: The underlying data is the Global Mammal Parasite Database,
 specifically v 2.0: http://dx.doi.org/10.1002/ecy.1799 It has been processed using a series of scripts in R (actually Rmd) which are archived in this repository
description: # Code from: Costs of parasite generalism revealed by abundance patterns
 across mammalian hosts
 [https://doi.org/10.5061/dryad.18931zd5j](https://doi.org/10.5061/dryad.18931zd5j) These code and data files reproduce analyses in the above-named manuscript. Code files are enumerated and named below. In this README, each code file additionally contains a bullet point list of what it does. Each bullet point begins with a key verb (Reads, Sources, Loads, Saves, Creates). With the exception of "Creates", these verbs refer to typical R functions ("load", "read_csv", etc.). "Creates" typically refers to the creation of a figure or statistic(s), but occasionally to a data product used on the fly or for inspection. Further details can be obtained from annotated code chunks within the files. Some code chunks can take a long time to run. In these cases, we supply an alternate code chunk (immediately following) that loads the data product as an R data file (.Rda). All required Rda files are included.  1\. dataPrep * reads in GMPD ("gmpd_main.csv") * reads in PanTHERIA ("PanTHERIA_1-0_WR05_Aug2008.txt") * reads in mammal phylogeny ("WR_2005_ST.txt") * GMPD metadata available here: [https://esajournals.onlinelibrary.wiley.com/doi/full/10.1002/ecy.1799](https://esajournals.onlinelibrary.wiley.com/doi/full/10.1002/ecy.1799) * PanTHERIA metadata available here: [https://esajournals.onlinelibrary.wiley.com/doi/10.1890/08-1494.1](https://esajournals.onlinelibrary.wiley.com/doi/10.1890/08-1494.1) * Mammal phylogeny available here: [https://doi.org/10.1038/nature05634](https://doi.org/10.1038/nature05634) * creates check that no HP combos refer to intermediate (ungulate) hosts * creates theta * creates nri (i.e. "get_nri.Rda", which is loaded in other files) 2\. g1 * sources dataPrep * creates figS1 3\. compCorr * sources dataPrep * creates figS2 [correlations of abund/components] 4\. makeTaxTreePara * sources dataPrep * saves get_txInfo * saves get_taxTree 5\. abundPhylo * sources dataPrep * creates abund * loads get_txInfo * creates abouheif.moran test * reads "PhyloRetained2.csv", a hand-typed text file that designates which parasite species from the taxonomic analysis are retained in the phylogenetic analysis (used to annotate fig1) * creates fig1 6\. predGlobAbund * reads "GMPD_main.csv" (see 1. for metadata) * reads ecoregions (described in, and available via, [https://doi.org/10.1641/0006-3568(2001)051\[0933:TEOTWA\]2.0.CO;2](https://doi.org/10.1641/0006-3568\(2001\)051[0933:TEOTWA]2.0.CO;2)) via file "wwf_terr_ecos.shp" (note these standard ESRI shapefiles require supporting files with same name and extensions dbf, htm, lyr, prj, sbn, sbx, shp.xml, shx * sources dataPrep * saves get_nEcos * creates abund [also done in abundPhylo] * loads get_txInfo * creates fig2 * creates pgls stat test [globAbun~nEco+nHost+z] 7\. bestHost * sources dataPrep * creates best * saves get_bestHost * loads get_taxTree * creates fig3 * creates figS3 * creates pgls stat tests [best~z] 8\. fitnessDecay * sources dataPrep * loads get_txInfo * creates figS4 * creates pgls stat test [evenness~z] 9\. dietSim * sources dataPrep * reads EltonTraits (metadata available at: [https://esajournals.onlinelibrary.wiley.com/doi/10.1890/13-1917.1](https://esajournals.onlinelibrary.wiley.com/doi/10.1890/13-1917.1)) via "EltonTraits.csv" * saves get_dietSim 10\. geogOverlap * sources dataPrep * reads IUCN layers (metadata available at: [https://www.iucnredlist.org/resources/spatial-data-download](https://www.iucnredlist.org/resources/spatial-data-download)) * creates areaOverlap for species pairs * saves get_Olaps * loads get_Olaps 11\. bodyMassSim * sources dataPrep * reads Pantheria (see 1. for metadata) * saves get_delBM * saves get_delBMLog 12\. abundOverHostSet * sources dataPrep * reads in mammal phylogeny (see 1. for details) * loads get_dietSim * loads get_Olaps * loads get_delBM * loads get_delBMLog * creates pdw (i.e. saves as "get_pdw.Rda") * creates pdw.best.worst.pi (i.e. saves as "get_pdwBestWorstPi.Rda") * creates fig4 * creates lm stat tests [delZpi~pd|olap|diet|bm] 13\. phylogenetic_abundPhylo * sources dataPrep * reads phyloRetained (list of parasite species typed manually that are retained from taxonomic analysis in the phylogenetic analysis) * reads ultrametric.newick (Regular Newick file format of parasite phylogenetic tree explained in supplementary material) 14\. phylogenetic_predGlobAbundance * sources dataPrep * reads wwf_terr_ecos.shp * reads ultrametric.newick (Regular Newick file format of parasite phylogenetic tree explained in supplementary material) * creates fig S6 15\. phylogenetic_bestHost * sources dataPrep * reads ultrametric.newick (Regular Newick file format of parasite phylogenetic tree explained in supplementary material) * creates figs S7 & S8 16\. phylogenetic_fitnessDecay * sources dataPrep * reads ultrametric.newick (Regular Newick file format of parasite phylogenetic tree explained in supplementary material) * creates fig S9