## Introduction

In 2010, the signatories to the Convention on Biological Diversity (CBD) agreed to the twenty Aichi Biodiversity Targets for 2011–20201. Aichi Target 11 concerns the safeguarding of biodiversity, and sets the goal of placing 17% of terrestrial and inland water habitats into a system of protected areas (e.g. national parks and other reserves) that is ecologically representative, well-connected, equitably managed, and effective. The world has nearly achieved the areal goal, with 15% of global land area protected under national jurisdiction2,3,4. Contributing to this total, China, a CBD signatory, has placed 15% (1.43 million km2) of its own land area into a reserve system5,6.

Chinese’s reserve system demonstrates considerable institutional capacity for achieving Aichi Target 11. In western China, for example, the reserves cover most ecoregions, biodiversity priority areas, and natural vegetation types7. Landsat imagery shows that the reserves successfully prevent deforestation8. But in southern and eastern China, the reserves are not so ecologically representative9, many reserves are isolated7, there is little information on the impact of reserves on local human populations and, most importantly, we know little about whether the reserves are effective at protecting their biodiversity.

Measuring the effectiveness of protected areas is challenging. Worldwide, it has proven so difficult to assess directly whether protected areas are achieving positive biodiversity outcomes that a recent review deemed their efficacy ‘unknown’4. Indirect measures, such as evaluations of staffing and budget adequacy (‘input evaluation’4), or evaluations of biodiversity threats like pollution and human pressures (‘threat-reduction evaluation’4), are often used as proxies for conservation outcomes, especially where high-throughput technologies such as remote sensing can be employed2,4,10,11. However, indirect measures assume that management inputs and/or the reduction of known threats successfully result in positive biodiversity outcomes4, are unable to detect whether conservation outcomes differ across taxa, and cannot identify new threats.

In this study, we ask whether we can use environmental DNA (eDNA) to quantify vertebrate biodiversity on a scale large enough for use as a direct measure of protected-area conservation outcomes. We focus on vertebrates (mammals, birds, amphibians and squamates) because one of the most important threats to vertebrate populations in China is overexploitation12; this threat is undetectable using remote-sensing methods and is thus especially difficult to measure. Ideally, biodiversity assessments should achieve high spatial and taxonomic resolution. They should allow frequent updates over large areas so that changes in wildlife populations can be detected quickly, allowing causes to be inferred and potentially mitigated. Assessments should be able to be validated rigorously by independent stakeholders and neutral third parties such as courts, and the assessments should be direct – i.e. be based on species detections rather than proxies – both of which are necessary for dispute resolution and for directing and incentivizing effective management. Finally, biodiversity measures should be efficient and simple to understand for decision-makers and the public, contributing to political sustainability and legitimacy13,14,15.

Advances in technologies such as camera traps and bioacoustic recorders allow broad biodiversity monitoring on relatively large scales. Nevertheless, the costs of buying, deploying and monitoring such equipment still imposes some limit on the spatial resolution or extent of monitoring that is feasible. For example, Beaudrot et al.16 recently reported on multi-year camera-trap surveys of 511 populations of terrestrial mammals and birds in fifteen tropical-forest protected areas. But while their camera-trap sets covered between 140 and 320 km2 in each protected area, this represented only 1–2% of the largest parks in their dataset, reflecting the difficulty and expense of setting up and maintaining a camera-trap network to cover large, difficult-to-access areas, exacerbated by theft and vandalism in some settings17,18. Furthermore, both camera traps and acoustic recorders may systematically miss portions of vertebrate biodiversity. For example, amphibians, squamates, and many birds are not readily captured on camera traps; likewise many mammals, amphibians, and squamates may be missed via bioacoustic monitoring.

eDNA has the potential to complement camera traps and bioacoustic recorders19, while avoiding some issues of deployment logistics, loss of field equipment, and taxonomic biases. In this study, we focus on iDNA, which is a subset of eDNA20, as an emerging sample type for broad taxonomic and spatial biodiversity monitoring. iDNA is vertebrate DNA collected by invertebrate ‘samplers,’ including haematophagous parasites (leeches, mosquitoes, biting flies, ticks) and dung visitors (flies, dung beetles)21,22,23. iDNA methods are rapidly improving, with research focused on documenting the ranges of vertebrate species and their diseases that can be efficiently detected via iDNA24,25,26,27,28,29, comparisons with camera trapping and other survey methods30,31,32, and pipeline development33,34.

We report on the use of iDNA to estimate spatially resolved vertebrate occupancies on the scale of an entire protected area: the 677 km2 Ailaoshan reserve in Yunnan province, China (Fig. 1). After the reserve’s establishment in 1981, a 1984–85 survey generated a species list of 86 mammal, 323 bird, 39 (non-avian) reptile and 26 amphibian species/subspecies35. Investigators have since carried out one-off targeted surveys36,37,38 and individual-species studies39,40,41,42,43. A recent camera-trap study by the Yunnan Forestry Service44 detected 10 mammal species and 10 bird species, but was not comprehensive enough to serve as a general vertebrate biodiversity assessment, surveying just 2 of 172 patrol areas in the reserve. Thus, an updated synoptic survey of vertebrate biodiversity remains lacking and, consequently, the current statuses and population trends of vertebrates in the park are largely unknown.

Our study tests the feasibility of employing iDNA surveys within a real protected-area management setting. We had several reasons to explore leech-derived iDNA as a promising broad-scale monitoring technology. First, personnel collecting leeches require little specialised training. The Ailaoshan reserve is divided into 172 patrol areas, each visited monthly by park rangers from neighbouring villages. We contracted these rangers to collect terrestrial, haematophagous leeches during their rainy-season patrols. We were thus able to sample across the reserve in three months at relatively low cost. Second, leech sampling provides an efficient way to correct for imperfect detection, which may include false negatives (i.e. failure to detect species that are present at a site) and false positives (i.e. detecting or appearing to detect a species’ DNA when that species is absent). With leeches, false negatives can arise when, for example, a species was not fed upon by leeches at a site; leeches containing that species’ DNA were not captured from that site; or the species’ DNA was not successfully amplified and associated with the correct taxon. Sources of false positives may include leech movement between sites; sample contamination in the field or lab; and errors in sequencing or bioinformatic processing.

Statistical models can be used to account for imperfect detection. In this project, we analyzed our DNA sequencing results using hierarchical site-occupancy models45,46, which distinguish between the detection of a species’ DNA at a site, and the true presence or absence of the species, which is not directly observed. The goal of site-occupancy modelling is to infer where each species is truly present, by separately estimating the probability that a species is present at a site, and the probability that a species is detected if it is present45,47. Separating these probabilities relies on a replicated sampling design, with replicates taken in sufficiently close spatial and/or temporal proximity that the underlying distribution of species presences or absences may be treated as fixed. We achieved replicate samples per patrol area in just one patrol by issuing each ranger with multiple, small plastic bags, each containing small tubes with preservative, inducing subsets of leeches to be stored in separate bags23, which we processed separately.

A third advantage of leech-derived iDNA is the potential to yield inferences about a broad range of taxa, as leeches are known to feed on small and large mammals, birds, squamates, and amphibians, including arboreal species. This provides a taxonomic breadth that is not typically captured via methods such as camera traps or bioacoustic surveys27,28,48. DNA sequences can also potentially distinguish some visually cryptic species30 (although iDNA methods can also suffer from a lack of species-level resolution). Finally, leeches can yield PCR-amplifiable DNA for at least four months after their last blood meal49, improving the efficiency of leech iDNA by increasing the proportion of collected leeches that can yield information on their previous bloodmeal. On the other hand, leech iDNA persistence could also decrease the spatio-temporal resolution of vertebrate detections, since a long period between leech capture and the previous feed affords more opportunity for leeches or vertebrate hosts to have moved between sampling areas23.

In this study, we use metabarcoding50 to detect vertebrate species in the blood meals of wild leeches sampled from the Ailaoshan reserve in Yunnan Province, China. We use occupancy modelling to estimate the spatial distributions of the vertebrates throughout the reserve, and identify environmental factors correlated with those distributions. We find that leech-derived iDNA data can identify informative occupancy patterns for a wide range of vertebrates, including species that are less likely to be detected with camera traps and bioacoustic surveys. We conclude that iDNA may be a useful tool for quantifying vertebrate biodiversity, providing a direct measure of protected-area effectiveness and helping achieve conservation outcomes by informing improvements to management strategies.

## Results

### Sampling and metabarcoding

The Ailaoshan reserve runs northwest-to-southeast for around 125 km along a ridgeline (approx. 24.9° N 100.8° E to 24.0° N 101.5° E), averaging just 6 km wide along its length, with elevation between 422 and 3157 m, and annual precipitation between 1000 and 1860 mm depending on altitude51 (Fig. 1 and Supplementary Fig. 1a, b). Vegetation is subtropical, evergreen broadleaf forest, and the reserve is flanked by agricultural land on lower-elevation slopes in all directions. There are 261 villages within 5 km of the reserve52, with an estimated human population of >20,000.

A total of 30,468 leeches were collected during the rainy season, from July to September 2016, by 163 rangers across 172 ranger patrol areas. These constituted 893 replicate samples after collected leeches were partially pooled in the field or laboratory as described in the Methods section.

We extracted DNA from each replicate sample and PCR-amplified two mitochondrial markers: one from the 16S rRNA gene (MT-RNR2), and one from the 12S rRNA gene (MT-RNR1). We refer to these two markers as LSU and SSU, respectively, denoting the ribosomal large subunit and small subunit that these genes code for. (We do this to avoid confusion with the widely-used bacterial 16S gene, which is homologous to our 12S marker, rather than our 16S.) After bioinformatic processing of our sequence data, we estimated multispecies site-occupancy models for the LSU and SSU datasets using parameter-expanded data augmentation46,53 to accommodate imperfect detection and identify ecological patterns in our datasets.

### Vertebrate species

We identified 86 vertebrate species across the LSU and SSU datasets, in addition to humans. The LSU dataset included 59 species, and the SSU dataset contained 72 species. Although the LSU primers target mammals, both the LSU and SSU primers amplified amphibians, birds, mammals, and squamates, with the general-vertebrate SSU primers amplifying more bird species (Fig. 2a). Forty-five species were common to both datasets, including those identified by their distribution across replicate samples (Supplementary Fig. 2), leaving 14 species unique to LSU and 27 species unique to SSU. We could assign taxonomic names to species level for 58 of our 86 species (45 LSU, 50 SSU). Tables 1 and 2 list the top 20 species in each dataset by estimated occupancy.

With the supercommunity size of M = 200 that we used for our final occupancy models, estimated total species richness in Ailaoshan was 119 species in the LSU dataset and 113 species in the SSU dataset (Fig. 2b). Setting M = 150 produced similar results, while M = 100 clearly constrained the species richness estimates.

Domesticated species featured heavily in our data (Supplementary Data 1), consistent with observed grazing of these species in the reserve (DWY, pers. obs.). Domestic cattle (Bos taurus) were the most frequently detected taxon in both datasets, being detected in almost half of all patrol areas; domestic goats (Capra hircus) were also common, being detected in just under a third of patrol areas, and domestic sheep (Ovis aries) were detected in ca. 6% of patrol areas. The O. aries detections were concentrated in the reserve’s southeastern section (Xinping county), located near to Shiping town and the main breeding area of the dark-haired Shiping Qin sheep breed.

Several wild taxa detected in our survey are listed as Threatened or Near Threatened by the IUCN (Table 3). Among mammals, four species have IUCN Vulnerable status: Asiatic black bear (Ursus thibetanus), mainland serow (Capricornis milneedwardsii), sambar (Rusa unicolor), and stump-tailed macaque (Macaca arctoides). Among amphibians, the Yunnan spiny frog (Nanorana yunnanensis) and Chapa bug-eyed frog (Theloderma bicolor) are listed as Endangered, while the piebald spiny frog (Nanorana maculosa), Yunnan Asian frog (Nanorana unculuanus) and Jingdong toothed toad (Oreolalax jingdongensis) have Vulnerable status. Some of these taxa, especially the amphibians, were widespread in Ailaoshan (Table 3 and Supplementary Data 1), highlighting the value of this reserve for protecting these species.

Leech iDNA appeared more successful at detecting Ailaoshan’s mammals and amphibians than its birds and squamates, based on our comparison with species lists from the Kunming Institute of Zoology (Supplementary Data 2). Among mammals, 34 of the 127 species in Ailaoshan were detected, with nearly half the detections in the larger-bodied orders: Artiodactyla (8 of 11 species), Carnivora (7 of 18), and non-human primates (1 of 4). Of the smaller-bodied orders, we detected 14 of 41 Rodentia species (including two porcupine species, Atherurus macrourus and Hystrix brachyura), 2 of 24 Eulipotyphla species (shrews and allies), and no bats (0 of 25), rabbits (0 of 1), pangolins (0 of 1) or treeshrews (0 of 1). We also detected two unnamed species assigned to Rodentia. Among amphibians, 12 of the 25 frog species (order Anura) known from Ailaoshan were detected, and so were both of the salamander species (family Salamandridae). We detected 13 more anuran species that could not be assigned to species, including two assigned to the genus Kurixalus, which has not been reported from Ailaoshan but which has a distribution that overlaps Yunnan (Supplementary Data 3). Among squamates, we detected only 3 unnamed species, compared to 39 species known from Ailaoshan. One of our species was assigned only to Squamata, and the others to families Scincidae and Viperidae respectively. Finally, among birds, 12 of the 462 bird species known from Ailaoshan were detected, plus 10 more species that were assigned to genus or higher. Interestingly, of the 12 species identified to species level, five are in the ground-feeding and terrestrial Phasianidae (pheasants and allies), out of 14 species known from Ailaoshan, and the other seven are known to be part-time ground and understorey feeders. Given that our LSU and SSU primers both had high amplification success Bc for mammals and birds (see Laboratory Processing in the Methods section), we tentatively attribute the difference in detection rates to the leeches – which were predominantly collected by rangers at ground level – having been more likely to have parasitised frogs than non-ground-feeding birds.

The most common taxa had occupancy estimates of around 0.6 in the LSU dataset and 0.8 in the SSU dataset (Tables 1 and 2). Most taxa, however, were observed infrequently (median number of detections: 2 and 3 patrol areas in the LSU and SSU datasets, respectively). This was reflected in low occupancy and detection estimates for many taxa (Fig. 2c) (median fraction of sites occupied: 0.33 and 0.24 in LSU and SSU, respectively; median detection probability per 100 leeches: 0.02 and 0.08 in LSU and SSU, respectively).

### Species richness

Per patrol area, estimated median species richness was 32 in the LSU dataset and 27 in the SSU dataset, compared to observed median species richnesses of 3 and 4 species per patrol area respectively (Supplementary Fig. 3a, b). Per replicate, observed median species richness was 1 and 2 in the LSU and SSU datasets respectively, from a median of 3 and 4 replicates per patrol area in each dataset.

The substantial gap between observed and estimated species richness per patrol area in both datasets highlights the extent to which imperfect detection of vertebrate species may bias biodiversity estimates. Although estimated detection varied widely among species, most species had very low detection probabilities, especially in replicates containing few leeches (Fig. 3c–f). These results underscore the importance of correcting for false negatives when using iDNA to conduct biodiversity surveys.

Almost half of all patrol areas had no associated species observations, either because they were not sampled, or because samples were inadequately labelled (Fig. 3a, b; though note that this map does not display samples without location information, which were still used as data in our model). Our occupancy models impute missing data and therefore provided species-richness estimates for all patrol areas, both with and without observed values (Fig. 3c, d). Both datasets indicated that species richness is highest in the southern third of the Ailaoshan reserve.

At the community level, species were more likely to occur at higher elevation and (to a lesser extent) further from the reserve edge. This can be seen in two ways. Firstly, estimated species richness in the reserve increased with elevation (both datasets) and with distance to reserve edge (LSU dataset) (Fig. 3e, f). Secondly, community mean occupancy (Eqs. (11) and (12)) increased with elevation in both datasets, holding distance to reserve edge constant in the LSU dataset (Fig. 4a, e). On the other hand, community mean occupancy showed limited increase with distance to reserve edge in the LSU dataset, with elevation held constant (Fig. 4c).

There was good agreement on species richness between the LSU and SSU datasets. Observed species richness in the two datasets was positively correlated at the grain of individual replicates (Supplementary Fig. 4a) and of patrol areas (Supplementary Fig. 4c). Unsurprisingly, estimated species richness was also tightly and positively correlated between the two datasets (Supplementary Fig. 4e). Sampling effort increased species detections: replicates with more leeches tended to contain more species (Supplementary Fig. 4b), as did patrol areas with more replicates (Supplementary Fig. 4d). However, as expected, estimated species richness did not increase with sampling effort, because our model compensates for variation in leech quantity and replicate number (Supplementary Fig. 4f).

At the species level, the effects of elevation (both datasets) and distance to reserve edge (LSU only) varied in both direction and strength (Fig. 4b, d, f). Among mammals over 10 kg, domestic cow (B. taurus), domestic sheep (O. aries), domestic goat (C. hircus) and muntjak (Muntiacus vaginalis) showed decreasing occupancy probability with elevation (Supplementary Figs. 5 and 7). Lower elevation sites in turn tend to be closer to the reserve edge; however, as for community mean occupancy, the independent effect of distance to reserve edge was small (Supplementary Fig. 6). In contrast, species such as tufted deer (Elaphodus cephalophus), sambar (R. unicolor), serow (C. milneedwardsii), Asiatic black bear (U. thibetanus) and wild boar (Sus scrofa) showed increasing occupancy probability with elevation and were thus more likely to occur in higher-elevation forest toward the centre of the reserve (Supplementary Figs. 5 and 7).

Most species of mammal below 10 kg were also estimated to have greater occupancy in more central, higher-elevation forest, including the Asian red-cheeked squirrel (Dremomys rufigenis) and the shrew gymnure (Neotetracus sinensis) (Supplementary Figs. 5 and 7). Birds likewise tended to have higher occupancy in higher elevation sites. On the other hand, a few small-mammal species such as the Himalayan field rat (Rattus nitidus) fared better in reserve-edge, lower-elevation forest. Amphibians showed a mix of responses, with some species such as the Tonkin toad (Bufo pageoti; IUCN Near Threatened) and the Jingdong toothed toad (O. jingdongensis; IUCN Vulnerable) more common in less accessible areas at higher elevations, but others such as the fire-bellied toad (Bombina maxima) more common in reserve-edge, lower-elevation forest.

### Community composition

In both datasets, hierarchical clustering separated patrol areas into three groups, corresponding to low-, intermediate- and high-elevation sites (Fig. 5a, b and Supplementary Fig. 8). These groups of sites were highly congruent across the two datasets (Cramer’s V = 0.79, 95% confidence interval 0.73–0.85). The higher-elevation areas tend to be located in the interior of the reserve, especially in the south, and contain larger amounts of relatively inaccessible forest compared to lower-elevation areas (Supplementary Fig. 1a, i; mean ± s.d. distance to reserve edge 1540 m ± 850 m for top quartile of sites by elevation, compared to 830 m ± 390 m for the bottom quartile).

Communities in low-elevation patrol areas were strongly characterised by the presence of domestic cow (B. taurus), domestic goat (C. hircus), muntjak (M. vaginalis) and fire-bellied toad (B. maxima) (Fig. 6). These species were present in the majority of low-elevation sites, but less than half of the high-elevation sites. In contrast, the Tonkin toad (B. pageoti) and Jingdong toothed toad (O. jingdongensis) showed the reverse pattern: i.e. they were absent from most of the low-elevation sites, but present in most of the high-elevation patrol areas. Indeed, many amphibians and birds occupied a larger fraction of high-elevation sites than of low-elevation sites (Supplementary Figs. 9 and 10). Nonetheless, some species, such as the Yunnan Asian frog (N. unculuanus), showed similar site occupancy across low-, intermediate- and high-elevation sites (Fig. 6).

Comparing the variation in composition among sites across the two datasets revealed significant co-inertia (RV coefficient54 0.77, p ≤ 0.001), indicating that there was substantial shared signal in the two datasets. The Jaccard distances from the two datasets were also highly correlated (Pearson correlation r = 0.94, p = 0.001).

## Discussion

Here we demonstrate that metabarcoding of leech-derived iDNA permits large-scale, spatially-resolved estimation of vertebrate biodiversity. Our study is both the most granular and the broadest-scale biodiversity survey using iDNA to date. Leech surveys were conducted by untrained forest rangers for only 2–3 months and captured distribution information on mammals and amphibians, and to a lesser extent birds and squamates, across a topographically challenging, 677 km2 nature reserve (Fig. 1). Our results show that the Ailaoshan reserve provides protected space for vertebrate species of high conservation value, mostly in its core area. The results also highlight the vulnerability of the reserve to degradation arising from human activity (e.g. farming, livestock, and poaching) (Figs. 3 and 5). The study provides an iDNA vertebrate biodiversity baseline for Ailaoshan, and future iDNA surveys can test for changes in occupancy as a proxy for effectiveness16. More generally, our study functions as a progress report on the use of iDNA monitoring in real-world management settings, and highlights areas for improvement going forward.

### Vertebrate biodiversity in Ailaoshan

Our iDNA survey recovered 86 species of mammals, amphibians, birds and squamates, plus humans. Many were common wildlife species, or domesticated taxa such as cattle. The dataset also included many less common taxa that would have not been detected without targeted, taxon-specific traditional surveys, including 15 species recognised by the IUCN as Near Threatened or Threatened (Table 3).

Occupancy modelling indicated that vertebrate species richness was greatest in the higher-elevation interior of Ailaoshan. Our result likely reflects greater anthropogenic disturbance (e.g. hunting, disease transmitted from domestic animals to wildlife, and habitat alteration) in the lower, more-accessible parts of the park, causing local extinctions of many wildlife species at lower elevations. Alternatively, more mobile species may have shifted their home ranges from their previously-preferred lower-elevation areas to less suitable habitat to escape human encroachment19.

Elevation and distance to reserve edge were important predictors of vertebrate community richness and composition (Figs. 3e, f and 5a, b). Examining the distribution of individual taxa revealed that many species, especially birds and small mammals, had higher occupancy at higher elevation and in the reserve core area. These species include several that are IUCN Near-Threatened or Threatened species: stump-tailed macaque (Macaca arctoides), tufted deer (E. cephalophus), sambar (R. unicolor), serow (C. milneedwardsii) and Asiatic black bear (U. thibetanus). Some or all of these species are sensitive to habitat alteration along the reserve edge, poaching, competition with domestic animals (e.g. most ungulates), and/or may be prone to human-wildlife conflict (e.g. Asiatic black bear) in peripheral areas of the reserve, which are used heavily by livestock. In contrast, a few wild species, like the northern red muntjak (M. vaginalis), appear to have increased occupancy in reserve-edge areas.

### Using iDNA for biodiversity monitoring

Two key benefits of leech-iDNA surveys are (a) the ability to survey a wider range of vertebrate taxa and body sizes than is possible with other methods and (b) the feasibility of engaging large numbers of minimally-trained personnel for sampling and data collection. This results in time and cost savings, and makes regular broad-scale surveys more feasible. However, these benefits are partly offset by a greater laboratory workload (which could be mitigated by automation); challenges over the design of sampling incentives (see below); iDNA-specific sampling errors and biases; and the workload associated with bioinformatic processing and statistical modelling. We required 12 person-months to count the leeches, extract DNA, and run PCRs, and Novogene required one month to construct libraries and carry out sequencing. The consumables cost of DNA extraction, PCR, and sequencing was around RMB 210,000 (USD 30,000), with an additional RMB 80,000 (USD 12,000) for primers sufficient to run several surveys of this size.

#### Design of sampling incentives

Sampling with the assistance of forest rangers proved to be a feasible way to collect large numbers of leeches across the entire reserve. Rangers were hired locally from villages neighbouring the park. They did not report to a central location; instead, forestry officials brought boxes of hip packs to groups of rangers at locations around the park in June-July 2016, issued instructions verbally, and retrieved the packs after surveys ended in September. Provisioning the packs with tubes distributed over multiple self-sealing bags naturally enforced replicate sampling with minimal explanation23. This made it feasible for replicates from each patrol area to be collected at a single time point, removing the possibility that occupancy might change between temporal replicates30. However, for logistical reasons, collections from different patrol areas took place over a period of three months.

Collection of metadata, however, was less successful, as many samples had information on the collecting ranger but not the patrol area. In future sampling, metadata submission could be made a condition of payment, and a subset of senior rangers should be trained on metadata collection. A longer-term possibility is to outfit rangers with a GPS-enabled app on their cell phones for collecting coordinates of collection sites. On the other hand, our occupancy modelling framework deals well with moderate amounts of missing data, and we are wary of creating incentives to fabricate information. For instance, we decided against paying on a per-leech or per-tube basis, because this might incentivize rangers to collect outside the reserve. We found that a fixed payment, plus a small bonus for at least one leech collected, worked well, and we have since used this structure in other rounds of leech sampling. We expect to need to increase future payments.

#### Error and bias in iDNA sampling

There are several potential sources of error in our study. One is the time between a leech’s last feed and our sampling, which could be up to a few months49. While the retention of blood meal DNA facilitates detection of animals, it also means that detected DNA does not necessarily reflect occupancy at the time of leech surveys. Animal hosts may leave the patrol area between the feeding event and our sampling, and even leeches may disperse widely if carried on hosts such as birds that can travel long distances55, potentially blurring the spatio-temporal resolution of occupancy results. Our data show that the leeches we collected mostly feed on hosts that probably remain within one patrol area or, at most, move between adjacent areas (e.g. frogs), so our broad conclusions about the overall distributions of wild and domesticated species in Ailaoshan (Figs. 3 and 5) are unlikely to be seriously affected by this bias. Further, the collection of all replicate samples from a location within the three-month window limits the potential for leech or host movements to violate the site-occupancy model assumption that species occupancy remains constant across replicates (i.e. the ‘population closure’ assumption23,56). Nonetheless, the lag time restricts the suitability of leech iDNA for detecting very rapid change, e.g. occurring on the order of a few months23.

A second source of error could be systematic differences across patrol areas in leech communities, coupled with differing diet preferences among leech species. For instance, if leech species differ with elevation (which we did not include as a detection covariate), and high-elevation leech species tend to feed more on frogs and less on cattle, this would give the appearance of change in these species’ occupancy with elevation. The large number of leeches in our sample made it infeasible to identify them individually, but the geographic location of our field site and the uniform morphology of the leeches is consistent with all the leeches being in the genus Haemadipsa28, the taxonomy of which is poorly resolved. Haemadipsa are known to feed on a wide range of vertebrate species27,28, probably because they are opportunistic, sit-and-wait parasites, and studies suggest at most limited evidence for dietary differences24,28,30. Given this, we opted for a protocol that pooled leeches rather than attempting to take individual leech identity and diet into account, and we do not think it likely that differences in leech diet are likely to account for any of the major results in our study.

A third possible source of error is the choice of PCR primers and genetic markers, which may prevent some taxa from being detected even when their DNA is present, e.g. due to non-amplification at the PCR stage. We addressed this problem in part by using data from two marker genes. More than half of the species were detected by both markers, and high correlation in species richness and co-inertia of community composition between the datasets suggested that broad ecological inferences would not have been strongly affected had either marker been chosen by itself (Figs. 3 and 5). On the other hand, the primers clearly differed in their ability to amplify DNA from certain species. For example, we detected the stump-tailed macaque (M. arctoides) in the LSU dataset in three different patrol areas, with 2700, 170,066, and 245,477 reads. In contrast, there was no obvious SSU equivalent, with no OTUs (other than humans) assigned to the order Primates in the SSU dataset. Using additional primers would likely detect further taxa57, albeit with diminishing return on the additional sequencing costs. In the future, the use of nucleic-acid baits and/or metagenomic sequencing58, or the new CARMEN method that multiplexes CRISPR-Cas13 detection59, may replace PCR. Either approach could allow, for example, the use of the cytochrome c oxidase I (COI) barcode sequence, for which databases are more extensive60, while also allowing other genetic markers to be used for taxonomic groups that are not well distinguished by COI.

Finally, leech iDNA will naturally exclude taxa that are not well represented in leech blood meals. Studies have reported lower iDNA detection rates for many species compared to camera trapping, though iDNA appears to be better at detecting smaller-bodied species of mammal19,31,32,49,61 and, in our study, amphibians. With sufficiently large samples, taxa that are present infrequently may still be detected, and their low detection rates accounted for using site-occupancy modelling. Taxa that are never detected can still be modelled statistically (e.g. using data augmentation46,53), but they obviously cannot contribute data towards the model. When leech sampling is the rate-limiting step, such as in researcher-led studies, Abrams et al.30 recommend using leech-iDNA to supplement camera-trap data. For instance, Tilker et al.19 recently ran a camera-trap survey at 139 stations (17,393 trap-nights) over five protected areas in Vietnam and Laos, spanning 900 km2, and supplemented the camera data with iDNA from 2043 leeches from 93 of the stations. The camera-trap data were limited to 23 terrestrial mammal species, with squirrels and large rodents being the smallest organisms detected, and generally produced more species detections. However, leech iDNA provided the sole detections of marbled cat (Pardofelis marmorata), and doubled the detections of Owston’s civet (Chrotogale owstoni) and Asiatic black bear (U. thibetanus). On the other hand, broad ecological patterns may still be identified without necessarily detecting every species present in an area. For example, Gogarten et al. found that camera trapping and fly-derived iDNA detected largely non-overlapping communities (only 6% to 43% of species were found by both methods in any given location)61, but both methods tended to classify habitats similarly.

#### Multi-species site-occupancy modelling

Site occupancy modelling identified correlates of detection and occupancy at the level of the community as well as individual species. Most taxa were detected infrequently, and individually, they provided little insight into detection and occupancy rates, as it is difficult to distinguish low detection rates (i.e. crypsis) from low occupancy (i.e. rarity). However, by integrating these infrequent detections into community models of occupancy and detection, and sharing information across species and patrol areas, the entire dataset was able to produce a broad picture of vertebrate diversity across Ailaoshan. This modelling approach dealt well with missing data, demonstrating the usefulness of occupancy models in a Bayesian framework for dealing with the imperfect datasets that are to be expected with surveys across broad areas and relying on limited resources. On the other hand, the data-augmented models represented a substantial computational burden with our large dataset, with high memory requirements, long run times and much experimentation required to fit the models successfully.

While in this study we focused our modelling attention on correcting for false negatives, false positives are also possible, e.g. due to lab contamination or taxonomic misassignment. While false negatives are likely to be a more serious problem than false positives in our dataset, false positives may nonetheless cause serious bias in the estimation of biodiversity62. Hierarchical models may, in principle, also be used to correct for false positives, but in practice they have proven challenging to estimate without additional information about the false-positive detection process63. Recent advances in modelling false positives show promise (e.g. Griffin et al.64), but these approaches are not yet available for multi-species metabarcoding datasets.

As iDNA surveys are increasingly used for large-scale studies, an important study design consideration will be the degree to which leeches are pooled. Pooling reduces the cost and complexity of the collecting task, since putting leeches into individual tubes requires a larger collecting kit. (Leeches regurgitate into the preservative fluid, such that leeches collected into the same tube cannot be treated as independent replicates; separate tubes for individual leeches would be needed.) Pooling also reduces lab costs and workload. On the other hand, occupancy models such as the one employed here work best when provided with data from unpooled samples. Potentially valuable information about leech host preferences is also lost when samples are pooled: for example, if collected individually, leeches could be DNA-barcoded, and this information used as a detection covariate in occupancy modelling. Development of automated, high-throughput laboratory protocols (e.g. Ackerman et al.59) would help make individual sequencing of leeches more practical in large sample sets such as ours (i.e. >30,000 individuals). At the collection stage, a compromise could be to issue collectors with smaller collecting tubes than we used (e.g. 2 mL), in order to lower leech numbers per replicate but not necessarily to the level of individual leeches.

### iDNA: a promising biodiversity monitoring tool

As we prepare to replace the Aichi Biodiversity Targets with a new post-2020 framework, there has been a call to focus on directly evaluating conservation outcomes using biodiversity measures such as occupancy, abundance, and population trends4,65,66. However, many protected areas are under-resourced and under-staffed2, and biodiversity monitoring may be difficult to prioritise4. In this study, we show the feasibility of using iDNA metabarcoding as a cost-effective way to estimate spatially-resolved vertebrate occupancies across entire protected areas and with broad taxonomic coverage. Our work thus demonstrates the potential for iDNA to facilitate direct measurements of biodiversity conservation outcomes.

In addition to yielding occupancy estimates, our work can also guide future monitoring to identify underlying sources of environmental change, anthropogenic influences, and overall wildlife community dynamics. We recommend using our results to guide the design of targeted scat-collection, camera-trap, and bioacoustic monitoring surveys of Ailaoshan, both to independently test our results with species that are amenable to being recorded with these other methods (e.g. mammals, ground-dwelling birds), and to improve the accuracy of occupancy and detection estimates30. These monitoring methods could also be used to estimate population sizes and population trends for some species using an occupancy modelling framework67,68,69. We further propose that iDNA may be used to survey other dimensions of biodiversity, such as zoonotic disease. Recent work has demonstrated the exciting possibility of using leech-derived bloodmeals, sampled from the wild, to screen for both viruses and their vertebrate hosts29,70. The 2020 SARS-CoV-2 pandemic has underscored the urgency of better understanding zoonotic disease in wildlife reservoirs – a need that is likely to become even more pressing as global climate and land use changes continue71.

## Methods

This section provides an overview of methods. The Supplementary Information provides additional detailed descriptions of the leech collections, laboratory processing, bioinformatics pipeline, and site-occupancy modelling. Code for our bioinformatics pipeline is available at Ji72 and Yu73. Code for our site-occupancy modelling and analysis is available at Baker et al.74.

### Leech collections

Samples were collected during the rainy season, from July to September 2016, by park rangers from the Ailaoshan Forestry Bureau. The nature reserve is divided into 172 non-overlapping patrol areas defined by the Yunnan Forestry Survey and Planning Institute. These areas range in size from 0.5 to 12.5 km2 (mean 3.9 ± sd 2.5 km2), in part reflecting accessibility (smaller areas tend to be more rugged). These patrol areas pre-existed our study, and are used in the administration of the reserve. The reserve is divided into six parts, which are managed by six cities or autonomous counties (NanHua, ChuXiong, JingDong, ZhenYuan, ShuangBai, XinPing) which assign patrol areas to the villages within their jurisdiction based on proximity. The villages establish working groups to carry out work within the patrol areas. Thus, individual park rangers might change every year, but the patrol areas and the villages responsible for them are fixed.

Each ranger was supplied with several small bags containing tubes filled with RNAlater preservative. Rangers were asked to place any leeches they could collect opportunistically during their patrols (e.g. from the ground or clothing) into the tubes, in exchange for a one-off payment of RMB 300 ( ~USD 45) for participation, plus RMB 100 if they caught one or more leeches. Multiple leeches could be placed into each tube, but the small tube sizes generally required the rangers to use multiple tubes for their collections.

A total of 30,468 leeches were collected in 3 months by 163 rangers across all 172 patrol areas. When a bag of tubes contained <100 total leeches, we reduced our DNA-extraction workload by pooling leeches from all tubes in the same plastic bag and treating them as one replicate. However, when a bag contained ≥100 total leeches, we selectively pooled some of the tubes in that bag to create five approximately equally sized replicates from the bag, to avoid any replicates containing an excessive number of leeches. Eighty-one per cent of bags contained <100 leeches, and 78% of patrol areas consisted only of bags below the threshold. Each patrol area typically returned multiple replicates, in the form of multiple bags below the threshold and/or multiple tubes from the bags above the threshold. After this pooling, the mean number of leeches per replicate was 34 (range 1–98), for a total of 893 replicates across the entire collection.

### Environmental characteristics

We used ArcGIS Desktop 9.3 (Esri, Redlands, CA) and R v3.4.075 to calculate characteristics of each patrol area. We created 30 m raster layers for elevation, topographic position index (i.e. difference between each pixel and its surrounding pixels76), distance to nearest road, and distance to nearest stream. We then calculated the median of the raster values for each patrol area for use as predictors in our statistical modelling (Table 4 and Supplementary Fig. 1). We also calculated distance to the Ailaoshan reserve edge as the distance of each patrol-area centroid to the nearest nature-reserve edge.

### Laboratory processing

We extracted DNA from each replicate and then PCR-amplified two mitochondrial markers: one from the 16S rRNA gene (MT-RNR2; primers: 16Smam1 5′-CGGTTGGGGTGACCTCGGA-3′ and 16Smam2 5′-GCTGTTATCCCTAGGGTAACT-3′77), and the other from the 12S rRNA gene (MT-RNR1; primers: 5′-ACTGGGATTAGATACCCC-3′ and 5′-YRGAACAGGCTCCTCTAG-3′ modified from Riaz et al.78). We refer to these two markers as LSU (16S, 82–150 bp) and SSU (12S, 81–117 bp), respectively, referring to the ribosomal large subunit and small subunit that these genes code for. A third primer pair targeting the standard cytochrome c oxidase I marker79 was tested but not adopted, as it co-amplified leech DNA and consequently returned few vertebrate reads.

The LSU primers are designed to target mammals, and the SSU primers to amplify all vertebrates. We ran ecoPCR v0.580 with three allowed mismatches on the Tetrapoda in the MIDORI database81 to estimate expected amplification success, Bc, for our primers. Bc is the proportion of species in the reference database that can be amplified in silico. The 16Smam primers returned high Bc values for Mammalia (99.3%), as expected, and also for Aves (96.2%), a moderate value for Amphibia (79%), and a low value for species grouped under “Reptilia" in the MIDORI database (=Crocodylia + Sphenodontia + Squamata + Testudines) (39.9%). The 12S primers returned high Bc values ( > 98%) for Mammalia, Amphibia, and Aves, and a moderate Bc value (79.8%) for “Reptilia”. We therefore expected most or all Ailaoshan mammals, birds, and amphibians to be amplifiable by one or both primers, and a lower success rate for snakes and lizards.

Primers were ordered with sample-identifying tag sequences, and we used a twin-tagging strategy to identify and remove ‘tag jumping’ errors82 using the DAMe protocol83. From our 893 replicate tubes, we successfully PCR-amplified in triplicate 661 samples using our LSU primers and 745 samples using our SSU primers. Successful PCR amplifications were sent to Novogene (Beijing, China) for PCR-free library construction and 150 bp paired-end sequencing on an Illumina HiSeq X Ten.

Negative controls were included for each set of PCRs, and the PCR set was repeated, or ultimately abandoned, if agarose gels revealed contamination in the negative controls. We also sequenced the negative controls, because gels do not always detect very low levels of contamination. Sequences assigned to human, cow, dog, goat, pig, chicken and some wild species appeared in our sequenced negative controls, but with low PCR replication and at low read number. We used these negative controls to set DAMe filtering stringency in our bioinformatics pipeline (see next section and Supplementary Information) for all samples to levels that removed these contaminants: -y 2 for both markers (minimum number of PCRs out of 3 in which a unique read must be present), and -t 9 for LSU and -t 20 for SSU (minimum number of copies per PCR at which a unique read must appear). We also amplified and sequenced a set of positive controls containing DNA from two rodent species, Myodes glareolus and Apodemus flavicollis, along with negative controls that we verified to be contamination-free using agarose gel electrophoresis. M. glareolus and A. flavicollis have European and Western Asian distributions, and we did not detect either species in our leech samples.

### Bioinformatics pipeline

The three key features of our bioinformatics pipeline were the DAMe protocol83, which uses twin-tagging and three independent PCR replicates to identify and remove tag-jumped and erroneous reads, the use of two independent markers, which provides an independent check on taxonomic assignments (Supplementary Fig. 2), and the PROTAX statistical ‘wrapper’ for taxonomic assignment84,85, which reduces overconfidence in taxonomic assignment when reference databases are incomplete, as they always are. In this case, around half of the known Ailaoshan taxa were present in the reference databases (Supplementary Data 2). Mammals and amphibians were relatively well represented: 73% of mammals and 83% of amphibians were in the LSU database, respectively 70% and 67% in the SSU database. Birds and squamates were less well captured, with 42% of birds and 53% of squamates present in the LSU database, respectively 35% and 34% in the SSU database. For OTUs that do not have reference sequences, PROTAX assigns them to higher ranks and flags them as ‘unknowns,’ allowing us to assign those OTUs to morphospecies and potentially supply taxonomy based on other information such as correlations between the datasets as described here.

After DAMe filtering, we removed residual chimeras using VSEARCH v2.9.086, clustered sequences into preliminary operational taxonomic units (‘pre-OTUs’) using Swarm v2.087, and then used the R package LULU v0.1.088 to merge pre-OTUs with high similarity and distribution across samples. We then used PROTAX to assign taxonomy to representative sequences from the merged pre-OTUs33,84,85, in which we benefited from recent additions to the mitochondrial reference database for Southeast Asian mammals89. The full pipeline is described in detail in the Supplementary Information (Assigning taxonomy to preliminary operational taxonomic units and following sections). We shared taxonomic information between the LSU and SSU datasets by making use of correlations between the datasets. To do this, we calculated pairwise correlations of LSU and SSU pre-OTUs across the 619 replicates for which both markers had been amplified and visualised the correlations as a network (Supplementary Fig. 2). If an LSU and an SSU pre-OTU occurred in (mostly) the same subset of replicates and were assigned the same higher-level taxonomies, the two pre-OTUs were deemed likely to have been amplified from the same set of leeches feeding on the same species. We manually inspected the network diagram and assigned such correlated pre-OTU pairs the same taxonomy.

We eliminated any pre-OTUs to which we were unable to assign a taxonomy; these pre-OTUs only accounted for 0.9% and 0.2% of reads in the LSU and SSU datasets respectively, and most likely represent sequencing errors rather than novel taxa. Within the LSU and SSU datasets, we merged pre-OTUs that had been assigned the same taxonomies, thus generating a final set of operational taxonomic units (OTUs) for each dataset. Finally, we removed the OTU identified as Homo sapiens from both datasets prior to analysis. Although it would be informative to map the distribution of humans across the reserve, we expect that most of the DNA came from the rangers themselves, not from other humans using the reserve.

Our final OTUs are intended to be interpreted as species-level groups, even though some cannot yet be assigned taxonomic names to species level (most likely due to incomplete reference databases). Thus, for example, the two frog OTUs Kurixalus sp1 and Kurixalus sp2 in the LSU dataset should be interpreted as two distinct Kurixalus species. Likewise, the frog OTU Megophryidae sp3 in the LSU and SSU datasets should be interpreted as a single species within Megophryidae. We therefore refer to our final OTUs as species throughout this study.

After excluding humans, the final LSU and SSU datasets comprised 18,502,593 and 84,951,011 reads respectively. These reads represented a total of 59 species across 653 replicates and 126 patrol areas in the LSU dataset, and 72 species across 740 replicates and 127 patrol areas in the SSU dataset. To assess the degree to which our iDNA approach was able to capture the breadth of vertebrate biodiversity in the park, we compared the list of species that we detected against unpublished, working species lists maintained by researchers at the Kunming Institute of Zoology.

We also attached additional metadata to our species list: we attached International Union for Conservation of Nature (IUCN) data for individual species by using the R package rredlist v0.6.090 to search for scientific names assigned by PROTAX. For this purpose, we treated Capricornis milneedwardsii as synonymous with Capricornis sumatraensis, in line with recent research and the latest IUCN assessment91,92. For mammals, we used the PanTHERIA database93 to obtain data on adult body mass for each species; where species-level information was not available, we used the median adult body mass from the database for the lowest taxonomic group possible.

### Site-occupancy modelling

We estimated separate multispecies site-occupancy models for the LSU and SSU datasets using parameter-expanded data augmentation46,53. These models assume that the nLSU = 59 and nSSU = 72 species observed in each dataset are, respectively, subsets of larger communities of size NLSU and NSSU species that are present in the vicinity of Ailaoshan and vulnerable to capture (e.g. fed on by leeches and amplified by the LSU and SSU primers). Although NLSU and NSSU are unknown, these communities can be modelled by embedding them in a larger ‘supercommunity’ of fixed size M. We set M = 200 for our final model. Values from M = 150 up to M = 474 (the latter being the total species richness for mammals, birds, non-avian reptiles and amphibians in the 1984-85 survey of Ailaoshan35) produced similar estimates for NLSU and NSSU.

For each species in the supercommunity, our models explicitly capture (i) a ‘community process’ governing whether the species is in the Ailaoshan community or not; (ii) an ‘ecological process’ governing the presence or absence of the species in each patrol area, given that it is in the community; and (iii) an ‘observation process’ governing whether we detect the species’ DNA in each of our replicate samples, given that it is present in the patrol area. The community-, ecological- and observation processes for individual species are linked by imposing community-level parameters and priors as described below.

For the community process, each species i was assumed to be either a member of the Ailaoshan community or not. We denote this unobserved state with wi, which was assumed to be a Bernoulli random variable governed by the community membership parameter $${{{\Omega }}}_{{g}_{i}}$$, i.e. the probability that species i was in the Ailaoshan community:

$${w}_{i} \sim {{{{{{{\rm{Bernoulli}}}}}}}}({{{\Omega }}}_{{g}_{i}}).$$
(1)

For the community process, we separated the species into two natural groupings – homeothermic mammals and birds, and poikilothermic amphibians and squamates – and allowed them to have different probabilities of being in the Ailaoshan community. This is denoted by the subscript on the $${{{\Omega }}}_{{g}_{i}}$$ parameter, in which gi represents which of these two groupings species i belongs to. This approach reflected our expectation that these groupings would differ systematically in their community probabilities, and we employed the same grouping for parameters governing the ecological and detection processes (see below for further discussion).

For the ecological process, each species i was assumed to be either present or absent in each patrol area j, and we used zij to denote this unobserved ecological state. We assumed the zij to be constant across all replicates taken from patrol area j, consistent with the samples being taken at essentially the same point in time. Any species present were assumed to be members of the Ailaoshan community (i.e. wi = 1), so we modelled zij as a Bernoulli random variable governed by both wi and an occupancy parameter ψij, i.e. the probability that a species i in the community was present in patrol area j:

$${z}_{ij}| {w}_{i} \sim {{{{{{{\rm{Bernoulli}}}}}}}}({w}_{i}{\psi }_{ij}).$$
(2)

We modelled occupancy ψij as a function of elevation and distance from the reserve edge in the LSU dataset

$${{{{{{{\rm{logit}}}}}}}}({\psi }_{ij})={\beta }_{0i}+{\beta }_{1i}{{{{{{{{\rm{elevation}}}}}}}}}_{j}+{\beta }_{2i}{{{{{{{{\rm{reserve}}}}}}}}}_{j}$$
(3)

and as a function of elevation in the SSU dataset

$${{{{{{{\rm{logit}}}}}}}}({\psi }_{ij})={\beta }_{0i}+{\beta }_{1i}{{{{{{{{\rm{elevation}}}}}}}}}_{j}$$
(4)

where elevationj is the median elevation for patrol area j, and reservej is the distance from the centroid of patrol area j to the nature reserve edge. We chose these specifications by running a ‘full’ model for each dataset with all five environmental covariates, and retaining only those covariates for which the 95% Bayesian confidence interval on the slope coefficient excluded zero.

We modelled observation as a Bernoulli process assuming imperfect detection but no false positives:

$${y}_{ijk}| {z}_{ij} \sim {{{{{{{\rm{Bernoulli}}}}}}}}({z}_{ij}{p}_{ijk}),$$
(5)

where yijk is the observed data, i.e. detection or non-detection of species i’s DNA in replicate k from patrol area j.

We allowed the conditional detection probability pijk to vary as a function of the conditional detection probability for species i per 100 leeches, ri, and the number of leeches in the replicate, leechesjk:

$$\kern0.3pc {p}_{ijk}=1-{(1-{r}_{i})}^{{{{{{{{{\rm{leeches}}}}}}}}}_{jk}/100}$$
(6)
$${{{{{{{\rm{logit}}}}}}}}({r}_{i})={\gamma }_{0i}$$
(7)

We allowed ri, and its logit-scale equivalent γ0i, to vary among species to capture e.g. variation in leech feeding preferences among taxa. We used leechesjk/100 rather than leechesjk to avoid computational problems arising from rounding.

Note that the detection probability pijk is conditional on species i being present in patrol area j, and not on species i’s DNA being present in replicate k from that site. pijk therefore subsumes multiple sources of imperfect detection, including those that result in species i’s DNA being absent from the replicate (e.g. the leeches in replicate k did not feed on species i, or they did so long ago and the DNA has since been digested), as well as those that result in apparent non-detection of species i DNA when it is present (e.g. failure to PCR amplify sufficiently, PCR or sequencing errors, or problems arising during bioinformatic processing). The multiple PCRs that we performed for each replicate (see Laboratory processing above, and Supplementary Information) could in principle have been used to decompose pijk into (i) a per-replicate probability that species i’s DNA is present in the replicate when the species is present at the site, and (ii) a per-PCR probability that species i’s DNA is detected when it present in the replicate, by adding another hierarchical level to our model94,95,96,97. However, we instead chose to combine the results from the multiple PCRs using DAMe83 prior to modelling, since DAMe is specifically designed to detect and remove errors arising in PCR and sequencing, and offers filtering options specialised to this task that we found useful.

Finally, whereas Eqs. (1) through (7) define a site-occupancy model for species i alone, we united these species-specific models with a community model for both ecological and detection processes:

$${\beta }_{1i} \sim {{{{{{{\rm{N}}}}}}}}({\mu }_{{\beta }_{1}},{\sigma }_{{\beta }_{1}})$$
(8)
$${\beta }_{2i} \sim {{{{{{{\rm{N}}}}}}}}({\mu }_{{\beta }_{2}},{\sigma }_{{\beta }_{2}})\quad ({{{{\rm{for}}}}\;{{{\rm{the}}}}\;{{{\rm{LSU}}}}\;{{{\rm{model}}}}\;{{{\rm{only}}}}})$$
(9)
$$({\beta }_{0i},{\gamma }_{0i}) \sim {{{{{{{\rm{MVN}}}}}}}}\left([{\mu }_{{\beta }_{0}{g}_{i}},{\mu }_{{\gamma }_{0}{g}_{i}}],\left[\begin{array}{cc}{\sigma }_{{\beta }_{0}{g}_{i}}^{2}&\rho {\sigma }_{{\beta }_{0}{g}_{i}}{\sigma }_{{\gamma }_{0}{g}_{i}}\\ \rho {\sigma }_{{\beta }_{0}{g}_{i}}{\sigma }_{{\gamma }_{0}{g}_{i}}&{\sigma }_{{\gamma }_{0}{g}_{i}}^{2}\end{array}\right]\right)$$
(10)

where N() and MVN() denote normal and multivariate normal distributions. These distributions were characterised by community hyperparameters μ and σ, with separate distributions for each parameter as denoted by the first subscript. We used a multivariate normal prior for (β0i, γ0i) to allow non-zero covariance between species’ occupancy and detection probabilities, as we might expect if, for example, variation in abundance affects both probabilities46.

These community models allow rare species effectively to borrow information from more common ones, producing a better overall ensemble of parameter estimates, though at the cost of shrinkage on the individual parameters46,98,99. As for the community process described above, we separated the species into two groups – homeothermic mammals and birds, and poikilothermic amphibians and squamates – and allowed them to have different community distributions. This is denoted by the subscripts on the μ and σ community hyperparameters for the occupancy and detection intercepts, in which gi represents which of these two groupings species i belongs to. This approach reflected our expectation that these groupings would differ systematically in occupancy probabilities (e.g. due to different habitat preferences) and in detection probabilities (e.g. due to different encounter rates with leeches, or leech feeding preferences). Alternative groupings could also be justified on biological grounds: for example, separating mammals and birds on the basis that many of the mammals are terrestrial while many of the birds are arboreal; or grouping birds and squamates together to better reflect phylogeny. Such alternative groupings did not perform well in our datasets, as most birds and squamates were observed too infrequently to provide much information on these groups by themselves, but this aspect of the model would be worth revisiting in future work.

We estimated our models using a Bayesian framework with JAGS v4.3.0100. We used 5 chains of 100,000 generations, including a burn-in of 50,000. We retained all rounds (i.e. without thinning) for the posterior sample, except for where we needed to save the z matrix for beta diversity and cluster occupancy calculations (see Statistical analyses below); memory limitations prevented us from retaining all posterior samples for the z matrix, and we thinned tenfold in order to make these calculations feasible. The Supplementary Information provides details of the prior distributions used for the model parameters. From the model results we calculated posterior means and quantiles for all model parameters of interest, as well as estimated species richness for each patrol area, and number of sites occupied for each species.

### Statistics

#### Species richness

For each dataset, we obtained estimates of overall species richness for Ailaoshan directly from the model, by summing the wi. To assess our choice of M, we compared these overall species richness estimates for M = 100, 150 and 200.

After examining occupancy and detection estimates for each species, we used histograms to visualise the distribution of estimated species richness per patrol area (obtained for each patrol area j by summing the zij). We calculated median estimated species richness across the patrol areas for comparison with median observed species richness per patrol area and per replicate. We drew choropleths to visualise the spatial distribution of both observed and estimated species richness across the nature reserve.

We examined community mean occupancy and detection probabilities (see e.g. Section 11.7.2 in Kéry and Royle101) to help understand the effects of the site and sample covariates. For each species group g = 1, 2 (representing mammals/birds and amphibians/squamates, respectively), we calculated the posterior mean and 95% Bayesian confidence interval for community mean occupancy and detection as functions of the covariates:

$${\psi }_{g}({{{{{{{\rm{elevation}}}}}}}})=logi{t}^{-1}({\mu }_{{\beta }_{0}g}+{\mu }_{{\beta }_{1}}{{{{{{{\rm{elevation}}}}}}}})$$
(11)
$${\psi }_{g}({{{{{{{\rm{reserve}}}}}}}})=logi{t}^{-1}({\mu }_{{\beta }_{0}g}+{\mu }_{{\beta }_{2}}{{{{{{{\rm{reserve}}}}}}}})\quad ({{{{\rm{for}}}}\;{{{\rm{the}}}}\;{{{\rm{LSU}}}}\;{{{\rm{model}}}}\;{{{\rm{only}}}}})$$
(12)
$${p}_{g}({{{{{{{\rm{leeches}}}}}}}})=1-{(1-{{{{{{{{\rm{logit}}}}}}}}}^{-1}({\mu }_{{\gamma }_{0}g}))}^{{{{{{{{\rm{leeches}}}}}}}}/100}$$
(13)

This approach effectively holds distance from reserve edge at zero in ψg(elevation), and elevation at zero in ψg(reserve), corresponding to the mean values for these covariates in our data, since predictors were normalised prior to modelling. To visualise variation among species in occupancy and detection response to covariates, we repeated these calculations using each species’ estimates for β0, β1, β2 and γ0 in place of the community hyperparameters to obtain the posterior means for each species.

We compared three measures of species richness between the two datasets in order to assess the extent to which the two datasets agreed on variation in richness within Ailaoshan. First, the observed species richness in each replicate; second, the observed species richness in each patrol area; and third, the estimated species richness in each patrol area (i.e. the posterior mean number of species, calculated from zij). For each of these measures, we computed the Pearson correlation between the datasets and tested the correlation coefficient against zero with a t-test. We also used Poisson GLMs to examine the relationship between each of these species richness measures and sampling effort: we regressed observed species richness per replicate against the log-transformed number of leeches per replicate, and we regressed both the observed and estimated species richness per patrol area against the log-transformed number of replicates per patrol area, testing the significance of the slope coefficients with t-tests.

#### Community composition

We explored variation in vertebrate community composition among patrol areas using posterior mean Jaccard similarities calculated from the estimated occupancy states zij (see Dorazio53 and Kéry and Royle101 for other examples of this approach). We visualised the pairwise Jaccard distances (i.e. distance = (1 − similarity)) using non-metric multidimensional scaling ordinations, overlaying environmental covariates using the vegan::ordisurf function. We clustered patrol areas based on the Jaccard distances using Ward’s criterion (R function hclust(., method = “ward.D2”)). We used this clustering to split the patrol areas into three groups, which turned out to correspond to low-, intermediate-, and high-elevation sites. We used Cramer’s V to quantify the extent to which these clusters matched across the two datasets. We visualised the spatial variation in community composition within the reserve by drawing maps of Ailaoshan with patrol areas coloured by these three clusters. To help understand how vertebrate communities varied among the clusters, we used the posterior sample of the occupancy states zij to calculate posterior means and 95% Bayesian confidence intervals for the occupancy (i.e. fraction of patrol areas occupied) of each species in the low-, intermediate- and high-elevation site clusters.

To assess the extent to which the two datasets identified common patterns of variation in community composition across the patrol areas, we performed a co-inertia analysis on the matrices of predicted species in each patrol area in each dataset using ade4::coinertia in R. We used the RV coefficient54 to quantify coinertia, testing its significance with the permutation test in ade4::RV.rtest with 999 permutations. We also tested for correlation between the posterior mean Jaccard distances from the two datasets using a Mantel test with 999 permutations.

### Reporting summary

Further information on research design is available in the Nature Research Reporting Summary linked to this article.