Skip to content

Commit

Permalink
Skipped refs when ref_dp is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Shettland committed Jul 1, 2024
1 parent f990ed8 commit 62aedf0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions bin/ivar_variants_to_vcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,15 @@ def get_ref_rowset(self, row_set):
for each variant position.
"""
ref_row_set = row_set.copy()
#ref_row_set["REF_DP"] = ref_row_set["FILENAME"].str.split(":").str[2]
ref_row_set["ALT"] = ref_row_set["REF"]
#np.where(ref_row_set["REF_DP"] == "0", row_set["ALT"], row_set["REF"]
ref_row_set["ALT_CODON"] = ref_row_set["REF_CODON"]
filecol = ref_row_set["FILENAME"].values.tolist()
ref_filecol = []
for row in filecol:
split_vals = row.split(":")
#if split_vals[2] != 0:
split_vals[8] = str(round(1 - float(split_vals[8]), 3))
split_vals[5] = split_vals[2]
ref_filecol.append(":".join(split_vals))
Expand Down Expand Up @@ -508,14 +511,21 @@ def merge_ref_alt(self, consec_rows):
clean_rows_list (list(pd.DataFrame)): Filtered list with viable combinations
"""
# Compare variants AF with REF and group those with more similarity

merged_ref_rows = self.get_ref_rowset(consec_rows.copy())
merged_ref_rows["AF"] = merged_ref_rows["FILENAME"].str.split(":").str[8]
ref_rows = merged_ref_rows[
merged_ref_rows["REF_CODON"] == merged_ref_rows["ALT_CODON"]
].reset_index(drop=True)
alt_rows = merged_ref_rows[
merged_ref_rows["REF_CODON"] != merged_ref_rows["ALT_CODON"]
].reset_index(drop=True)
ref_rows = merged_ref_rows[
merged_ref_rows["REF_CODON"] == merged_ref_rows["ALT_CODON"]
].reset_index(drop=True)
ref_rows["REF_DP"] = ref_rows["FILENAME"].str.split(":").str[2]
for col in ["AF", "ALT", "ALT_CODON", "FILENAME"]:
ref_rows[col] = np.where(
ref_rows["REF_DP"] == "0", alt_rows[col], ref_rows[col]
)
ref_rows = ref_rows.drop("REF_DP", axis=1)
ref_dict = {
x: {"AF": float(y), "set": "ref"}
for x, y in ref_rows["AF"].to_dict().items()
Expand Down

0 comments on commit 62aedf0

Please sign in to comment.