Skip to content

Commit

Permalink
Fix reference allele frequency calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmig committed Oct 3, 2023
1 parent e5d77c1 commit e48cc62
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions workflow/scripts/weighted_distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ def get_frequencies_in_position(site_df: pd.DataFrame, pos: int, reference: Seq)
for alt in site_df["ALT"]:
frequencies[alt] = float(site_df.loc[site_df["ALT"] == alt, "ALT_FREQ"].iloc[0])
# Obtain frequency for reference allele
ref = 1 - sum(frequencies.values())
frequencies[reference[pos-1]] += ref
reference_frequency = 1 - sum(frequencies.values())
reference_allele = reference[pos-1]
if reference_allele in frequencies.keys():
frequencies[reference_allele] += reference_frequency
else:
frequencies[reference_allele] = reference_frequency
return tuple(frequencies[alt] for alt in site_df["ALT"].unique())


Expand Down

0 comments on commit e48cc62

Please sign in to comment.