I learned that Tajima's D compares the sum of nucleotide diversities for each pair of genomes to the expected nucleotide diversity of that population. After a selective sweep, the population is more homogeneous and so mutations that do occur are rare ones, meaning theta_T < theta_W and D<0. This made me think that one Tajima's D is calculated for an entire population.
However, I've also seen that you can calculate a Tajima's D for each individual in a population. My guess is that this individual statistic compares d_ij, where d is the pairwise difference b/w individuals i and j, to the population's Tajima's D?
Additionally, I've read that Tajima's D can be defined for individual genes, and also that: genes in the lower 5% tail of Tajima's D --> likely targets of selection. So how can Tajima's D be used to infer which genes are likely targets of selection? My guess is that Tajima's D is calculated on sliding windows along a genome.