From 98545d91072ab6e6809fb7b45d565daec5e4f753 Mon Sep 17 00:00:00 2001 From: Haibao Tang Date: Fri, 12 Apr 2024 10:47:02 -0700 Subject: [PATCH] update inbreeding formula --- jcvi/apps/pedigree.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/jcvi/apps/pedigree.py b/jcvi/apps/pedigree.py index d91f9f85..57ceaceb 100644 --- a/jcvi/apps/pedigree.py +++ b/jcvi/apps/pedigree.py @@ -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: