Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: updated html report to include recommendations and detected variants #19

Merged
merged 4 commits into from
Mar 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: only color table row with non wildtype haplotype in report
chels0 committed Feb 27, 2024

Verified

This commit was signed with the committer’s verified signature.
chels0 Chelsea Ramsin
commit 62ecd3ad9c61c8fa12e1375a86932737800c0ae7
15 changes: 7 additions & 8 deletions workflow/scripts/generate_pgx_report.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ def highlight_greaterthan(s, threshold, column):

def highlight_risk_genotype(s, column):
is_max = pd.Series(data=False, index=s.index)
is_max[column] = s[column].str.contains('-[^1]') is not True
is_max[column] = ~s[column].str.contains('-[^1]')
return [
'background-color: red ; font-weight: bold ; color: white'
if not is_max.any() else '' for v in is_max
@@ -73,18 +73,17 @@ def create_styled_clinical_recommendations(rekommendation):
rec = split_recommendation[2]
recommendation_restructured.append([gene, genotype, rec])

pandas_recc = pd.DataFrame(
recommendation_restructured,
columns=['Gen', 'Genotyp', 'Klinisk rekommendation'])
rec_df = pd.DataFrame(recommendation_restructured,
columns=['Gen', 'Genotyp', 'Klinisk rekommendation'])

if pandas_recc['Genotyp'].str.contains('-[^1]').any() is not True:
if ~rec_df['Genotyp'].str.contains('-[^1]').any():
warning_rec = ""
else:
warning_rec = "!"

styled_recc = pandas_recc.style.apply(highlight_risk_genotype,
column=['Genotyp'],
axis=1).hide(axis="index")
styled_recc = rec_df.style.apply(highlight_risk_genotype,
column=['Genotyp'],
axis=1).hide(axis="index")

return styled_recc, warning_rec

6 changes: 4 additions & 2 deletions workflow/scripts/get_clinical_recommendations.py
Original file line number Diff line number Diff line change
@@ -117,7 +117,8 @@ def get_recommendations(found_variants, haplotype_definitions,
with open(report, 'w') as writer:
for gene in genes:
if gene not in interaction_guidelines.values:
rec_per_gene = clinical_guidelines_present.loc[clinical_guidelines_present['Gen'] == gene]
rec_per_gene = clinical_guidelines_present.loc[
clinical_guidelines_present['Gen'] == gene]
haplotype_1 = rec_per_gene['Haplotyp 1'].values[0]
haplotype_2 = rec_per_gene['Haplotyp 2'].values[0]
genotype = f"{haplotype_1}/{haplotype_2}"
@@ -130,7 +131,8 @@ def get_recommendations(found_variants, haplotype_definitions,

writer.write(f"\n\n{gene1_interaction}-{gene2_interaction}")
writer.write(f"\nGenotype: {genotype_interaction}")
writer.write(f"\nKlinisk rekommendation: {recommendation_interaction}\n")
writer.write(
f"\nKlinisk rekommendation: {recommendation_interaction}\n")
writer.write(f"\n{analysed}")