Skip to content

Instantly share code, notes, and snippets.

@koelling
Created July 13, 2017 13:02
Show Gist options
  • Save koelling/bb44162f4586a0f27433d0c60c650520 to your computer and use it in GitHub Desktop.
Save koelling/bb44162f4586a0f27433d0c60c650520 to your computer and use it in GitHub Desktop.
popA = 1
popB = 2
samplesA = [sample for sample in tree_sequence.get_samples() if tree_sequence.get_population(sample) == popA]
samplesB = [sample for sample in tree_sequence.get_samples() if tree_sequence.get_population(sample) == popB]
piA = tree_sequence.get_pairwise_diversity(samples = samplesA)
piB = tree_sequence.get_pairwise_diversity(samples = samplesB)
piAB = tree_sequence.get_pairwise_diversity(samples = samplesA + samplesB)
print(piA, piB, piAB)
#56465.569079715795 56413.38735640868 57020.29606185412
pi_between = piAB
pi_within = piA
F_ST = (pi_between - pi_within) / pi_between
print(F_ST)
#0.009728588247535055
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment