Skip to content

Commit

Permalink
update inbreeding formula
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaibao committed Apr 12, 2024
1 parent 52572d3 commit 98545d9
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions jcvi/apps/pedigree.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,8 @@ def inbreeding_coef(self, s: str) -> float:
"""
genotype = self[s]
ploidy = len(genotype)
pairs = ploidy * (ploidy - 1) // 2
counter = Counter(genotype)
collisions = 0
for count in counter.values():
collisions += count * (count - 1) // 2
return collisions / pairs
unique = len(set(genotype))
return 1 - unique / ploidy


def simulate_one_iteration(ped: Pedigree, ploidy: int) -> GenotypeCollection:
Expand Down

0 comments on commit 98545d9

Please sign in to comment.