The ABBA BABA statistics are used to detect and quantify an excess of shared derived alleles, which can be indicative of gene flow. Given three populations and an outgroup with the relationship (((P1, P2),P3) O), these statistics test for sharing of genetic variation between P3 and P2 but not with P1. The choice of P1 can therefore affect the results, as we shall see.
We will consider two simple statistics: D (Green et al. 2010, Durand et al. 2011) simply compares the counts of shared derived alleles between P2 and P3, wheras fd (Martin, Davey and Jiggins 2015) attempts to control for some of the biases of D, and is more suitable for sliding windows.