{'fraction_non_alphanumeric': 0.028015971722196765, 'fraction_numerical': 0.003927472671335995, 'mean_word_length': 4.358821466152227, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Using Genetic Data to Build Intuition about Population History

Genetic data are now routinely used to study the history of population size, subdivision, and gene flow. A variety of formal statistical methods is available for testing hypotheses and fitting models to data. Yet it is often unclear which hypotheses are worth testing, which models worth fitting. There is a need for less formal methods that can be used in exploratory analysis of genetic data. One approach to this problem uses *nucleotide site patterns*, which provide a simple summary of the pattern in genetic data. This article shows how to use them in exploratory data analysis.


Nucleotide site patterns
Nucleotide site patterns are often used in computer programs designed to infer population history from genetic data [9][10][11]13]. This article however is not concerned with computer programs. The goal here is to see what can be learned about population history simply by looking at the data. This introductory section will introduce site patterns and explain how they relate to history.
The left panel of Fig. 1 shows the relationship between three populations. I use capital letters to refer to populations: X is African, Y is Eurasian, and N is Neanderthal. Later on we will encounter D, which refers to Denisovans, an archaic population related to Neanderthals [8]. Combinations of letters refer to ancestral populations: XY is ancestral to X and Y , XYN is ancestral to XY and N , and so on. The right panel of Fig. 1 shows the gene genealogy of a tiny sample consisting of three random nucleotides, one from X, one from Y , and one from N . All three are drawn from the same position within the genome. In practice we work with larger samples, involving multiple individuals and millions of nucleotide sites, but this tiny sample makes the principles easier to explain. I will call such samples "haploid," because the sample from each population consists of a single nucleotide.
Haploid samples also provide a real advantage. When we trace larger samples backwards into the past, it occasionally happens that two lineages coalesce at their common ancestor to form a single ancestral lineage. This happens faster in small populations than in large ones, so the process is sensitive to population size. With a haploid sample, no coalescent events are possible until we reach an ancestral population that contains the ancestors of two or more of our modern samples. Consequently, recent changes in population size have no effect, and we need not incorporate them into our model. This makes it easier to study the distant past. Figure 1 shows the gene genealogy of one hypothetical haploid sample, which is represented by the red and the gray lines. For this sample, the lineages from X and Y coalesce in population XY . Suppose that a mutation occurred somewhere on the red segment of the genealogy. A mutation generates a new allelic state, which we will call derived or mutant to distinguish it from the ancestral state that came before. If a mutation occurred on the red segment, we would observe the derived    XY is ancestral to X and Y , and XYN is ancestral to XY and N . At the bottom of the right panel, "0" indicates the ancestral allele and "1" the derived (or mutant) allele. A mutation on the solid red segment would generate the xy site pattern. In this example, the closest relatives (X and Y ) uniquely share the derived allele.
allele in the samples from X and Y and the ancestral allele in that from N . I will call this outcome the "xy site pattern," using lower case to distinguish site patterns from populations. Before we can recognize site patterns in the data, we must first determine which allele is ancestral and which is derived. Figure 2 shows how this is done. Figure 3 shows site pattern frequencies of two modern human populations (X, Africa, and Y , Europe), and two archaic ones (N , Neanderthal, and D, Denisovan). In these data, the horizontal axis shows the relative frequency of each site pattern among the nucleotide sites in the genome, after excluding sites that fail quality control criteria, or for which the ancestral and derived alleles cannot be identified. The frequencies are plotted as open circles. Within each circle, the thing that looks like a dot is actually a horizontal line representing the 95% confidence interval. These intervals are very narrow, because these frequencies are estimated with high precision. This precision is possible because there is so much data in the nuclear genome.

Data
Some of the pattern in these data is obvious. There are a lot of singletons (x, y, n, and d), and two of the doubletons (xy and nd ) are more common than the others. Of the two common doubletons, xy is more common than nd. Other parts of the pattern are subtle: the less-common doubletons are similar in frequency, but yn is a little more common, and this difference is larger than the (barely-perceptible) confidence intervals.
To interpret these patterns, the trick is to reason as we did in Fig. 1 above. There, a mutation anywhere on the red segment of the gene genealogy would generate the xy site pattern. Anything that tended to lengthen this segment would inflate the frequency of this site pattern, because mutations are more likely to occur on long segments than on short ones. In the section that follows, we reason from population history to gene genealogies in order to understand the frequencies of site patterns.  The right-most sample in each graph is from an "outgroup"-a population that is distantly related to others. If C were ancestral, it would take two mutations (shown as bold dots) to produce the pattern in the data. Only one mutation is needed if T is ancestral. Because mutations are rare, a model that requires only one mutation is a better bet than one requiring two. We therefore infer that T is ancestral and C is derived.    The right panel assumes the two separation times are the same but that the effective size of population ND is larger than that of XY.
3 Relating population history to site pattern frequencies

When the gene genealogy agrees with the population tree
It is useful to start with a model that lacks gene flow. Such models often shed light on large-scale patterns, even if they miss the subtleties. Figure 4 shows two versions of such a model, each of which assumes that the two modern human populations (X and Y ) are closely related, and so are the two archaic ones (N and D). Because there is no gene flow in these models, the network of populations has the shape of a tree. Within each population tree, I have drawn a gene genealogy, and in each genealogy the branching order is the same as that of the population tree. As we will see below, other branching orders also occur. However, this one is likely to be common, and if so it will explain the major features in the data. In both sides of Fig. 4, a mutation on the blue segment would generate site pattern xy, whereas a mutation on the red segment would generate nd. These are the two common doubletons in Fig. 3. It makes sense that these patterns should be common, because X (Africa) and Y (Europe) are close relatives, as are N (Neanderthal) and D (Denisovan). Close relatives tend to share ancestors, and mutations in these shared ancestors inflate the frequencies of xy and nd. This is the verbal intuition behind the graphs in Fig. 4. The data imply that the two modern populations are close relatives as are the two archaic ones.
But why is xy more common than nd ? In Fig. 4, site pattern xy will arise only if a mutation occurs on the blue branch. This is more likely to happen if the blue branch is long than if it is short. Thus, the excess of xy over nd implies that, on average across the genome, the blue branch is longer than the red one. Why should these branches tend to differ in length?
The left and right panels of Fig. 4 illustrate two possible reasons. In the left panel, the separation between X and Y is more recent than that between N and D. For this reason, X and Y share a longer history of common ancestry than do N and D. Consequently, the blue branch is longer than the red one, and site pattern xy is more common than nd, just as we see in the data. This is reassuring and probably also correct, but I have smuggled in a hidden assumption. As we trace the lineages from X and from Y backwards in time, they eventually arrive in population XY. Similarly, the lineages from N and D arrive in population ND, which is ancestral to N and D. In either case, as we trace the two lineages farther back in time, they eventually coalesce into a single parental lineage. In the previous paragraph, I assumed that this process takes the same length of time within populations XY and ND. This is not necessarily so.
Gene genealogies tend to be deeper in large populations than in small ones. Why? Because two random individuals are more likely to be close relatives in a small population. Close relatives are connected by short genealogies and distant relatives by deep ones. In the right panel of Fig. 4, population ND is much larger than XY, and it takes a long time for the N and D lineages to coalesce after they arrive in ND. In other words, they are connected by a deep genealogy. For this reason, the red branch is much shorter than the blue one. This is a second hypothesis that might explain the excess of xy over nd in the data.
It is not easy to choose between these alternatives, and this difficulty plagues formal statistical methods as well as the exploratory ones discussed here. In spite of this difficulty, we do have estimates, and these indicate that Neanderthals and Denisovans separated much earlier than did Africans and Europeans [8]. Furthermore, my colleagues and I have estimated that the population ancestral to Neanderthals and Denisovans was very small [11,13]. Thus, neither of the assumptions made in the right panel of Fig. 4 is likely to be correct. The excess of xy over nd probably reflects a recent separation of X and Y rather than large size in population ND.

When the gene genealogy disagrees
Having explained several large-scale features in the data, let us focus now on a finer scale. It will be useful for a little longer to ignore the effect of gene flow. This will provide a base line against which effects of gene flow will become visible.
In this section, we concentrate on counterintuitive sites patterns-ones in which the derived allele is shared not by samples from closely-related populations, but by distant relatives. Consider for example the two histories shown in Fig. 5. In these examples, the lineages sampled in X and Y happen-just by chance-not to coalesce in population XY . They persist (going backwards in time) as distinct lineages throughout this segment of population history until they reach population XYN and are joined by the lineage sampled from N . At this point, we have three lineages within the larger population. I will assume that this population is not geographically subdivided. In this case, the three lineages are equally likely to coalesce in any order: either ((X, Y ), N ), ((X, N ), Y ), or (X, (Y, N )). The two counterintuitive orders, which are illustrated in Fig. 5, generate site patterns xn and yn. The process that leads to these counterintuitive patterns is called incomplete lineage sorting [5].
Incomplete lineage sorting generates site patterns xy, xn, and yn with equal frequency. However, xy is also generated by coalescent events within population XY, as illustrated in Fig. 1. Thus, in the absence of admixture, we expect xn and yn to be equally common, but neither of these should be as common as xy.
Returning now to the data in Fig. 3, note that xd is about equal in frequency to yd. These are counterintuitive site patterns in which the derived allele is shared by samples from distantly-related populations. If these site patterns were produced by incomplete lineage sorting, they should be equal in frequency, as indeed they seem to be.
On the other hand, the frequencies of yn and xn are not equal. Although the difference is not large in absolute terms, it is (as noted above) much larger than the confidence intervals. To understand what this might mean, we need to discuss the effect of gene flow between populations.         Figure 6 shows the result of gene flow from the Neanderthal population (N ) into the Eurasian one (Y ). This form of gene flow inflates the frequencies of the x and yn site patterns. In the figure, the blue branch is longer on the right than on the left, and this increases the frequency of x. The red branch on the right provides a mechanism (in addition to incomplete lineage sorting) that can generate yn. Both patterns can arise without gene flow, but they are more common when Neanderthals contribute DNA to Europeans. These effects are not likely to be large. If only a small fraction of the lineages in Y derive via gene flow from N , then the histories of most nucleotide sites will be as described in Figs. 1, 4, and 5. In a complete genome from Y , only a small fraction of the nucleotide sites will derive from N . Consequently, the frequencies of site patterns yn and x will be inflated only slightly. This is exactly the pattern seen in Fig. 3: yn is more common than xn, and x is more common than y. Although neither effect is large, both are larger than the confidence intervals. This pattern      is the signature of Neanderthal gene flow into Europeans [1].

The effect of gene flow
Finally, note that the d site pattern is substantially more common than the other singletons. This suggests that the Denisovan fossil is younger than the Altai Neanderthal. However, a detailed analysis of this hypothesis [12] led to the absurd conclusion that the Denisovan fossil was only 4000 years old-a date that is tens of thousands of years too young. Something was clearly missing from our model. Several authors had suggested that Denisovans received gene flow from a "superarchaic" population, which was distantly related to all other humans, archaic as well as modern [2,6,7,14,15]. If this hypothesis were correct, what effect might this have on site pattern frequencies? Figure 7 provides an answer. Mutations on the red branch in this figure would inflate the frequency of site pattern d. Mutations on the blue branch would inflate xyn. Refer back to Fig. 3 and you will see that not only is d more common than the other singletons, xyn is more common than the other tripletons. This is the signature of superarchaic admixture into Denisovans [13].

Conclusions
This article has tested no hypotheses. Neither has it used any formal method to fit models to data. Yet we have learned a lot simply by looking at the data-by using it to build intuition about what models to fit and what hypotheses to test. Our exploratory analysis suggests that (a) modern Europeans and Africans are closely related, (b) so were Neanderthals and Denisovans, (c) the separation between Europeans and Africans was more recent than that between Neanderthals and Denisovans, (d) Neanderthals contributed DNA to Europeans, and (d) superarchaics contributed DNA to Denisovans. None of these findings are new, but it is useful to see that they can all be inferred simply by looking at the data.