Skip to content

Commit

Permalink
Merge pull request #277 from NCI-CGR/correct_test_scripts
Browse files Browse the repository at this point in the history
Correct column name for analytic_exclusion
  • Loading branch information
carynwillis authored Apr 16, 2024
2 parents fd9d490 + f8800d9 commit 98d3afe
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/cgr_gwas_qc/workflow/scripts/sample_qc_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ def main(
)

add_qc_columns(
sample_qc, remove_contam, remove_rep_discordant,
sample_qc,
remove_contam,
remove_rep_discordant,
)
sample_qc["is_unexpected_replicate"] = (
sample_qc["is_unexpected_replicate"].replace("", False).fillna(False)
Expand Down Expand Up @@ -413,7 +415,8 @@ def _read_contam(file_name: Optional[Path], Sample_IDs: pd.Index) -> pd.DataFram

if file_name is None:
return pd.DataFrame(
index=Sample_IDs, columns=["Contamination_Rate", "is_contaminated"],
index=Sample_IDs,
columns=["Contamination_Rate", "is_contaminated"],
).astype({"Contamination_Rate": "float", "is_contaminated": "boolean"})

return (
Expand Down Expand Up @@ -456,12 +459,16 @@ def _read_intensity(file_name: Optional[Path], Sample_IDs: pd.Index) -> pd.Serie


def add_qc_columns(
sample_qc: pd.DataFrame, remove_contam: bool, remove_rep_discordant: bool,
sample_qc: pd.DataFrame,
remove_contam: bool,
remove_rep_discordant: bool,
) -> pd.DataFrame:
add_call_rate_flags(sample_qc)
_add_identifiler(sample_qc)
_add_analytic_exclusion(
sample_qc, remove_contam, remove_rep_discordant,
sample_qc,
remove_contam,
remove_rep_discordant,
)
_add_subject_representative(sample_qc)
_add_subject_dropped_from_study(sample_qc)
Expand Down Expand Up @@ -507,7 +514,9 @@ def reason_string(row: pd.Series) -> str:


def _add_analytic_exclusion(
sample_qc: pd.DataFrame, remove_contam: bool, remove_rep_discordant: bool,
sample_qc: pd.DataFrame,
remove_contam: bool,
remove_rep_discordant: bool,
) -> pd.DataFrame:
"""Adds a flag to remove samples based on provided conditions.
Expand All @@ -527,7 +536,7 @@ def _add_analytic_exclusion(
exclusion_criteria["is_contaminated"] = "Contamination"

if remove_rep_discordant:
exclusion_criteria["is_discordant_replicate"] = "Replicate Discordance"
exclusion_criteria["Expected Replicate Discordance"] = "Replicate Discordance"

sample_qc["analytic_exclusion"] = sample_qc.reindex(exclusion_criteria.keys(), axis=1).any(
axis=1
Expand Down

0 comments on commit 98d3afe

Please sign in to comment.