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

Report ccv score/temperature on case report #5173

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ About changelog [here](https://keepachangelog.com/en/1.0.0/)

## [unreleased]
### Added
- CCV score / temperature on case reports
- ACMG SNV classification form also accessible from SV variant page
- Simplify updating of the PanelApp Green panel from all source types in the command line interactive session
### Changed
Expand Down
23 changes: 23 additions & 0 deletions scout/server/blueprints/cases/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
institute_and_case,
)
from scout.utils.acmg import get_acmg_temperature
from scout.utils.ccv import get_ccv_temperature

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -632,6 +633,26 @@ def add_bayesian_acmg_classification(variant_obj: dict):
variant_obj["bayesian_acmg"] = get_acmg_temperature(terms)


def add_bayesian_ccv_classification(variant_obj: dict):
"""Append info to display the CCV VUS Bayesian score / temperature.
Criteria have a term and a modifier field on the db document
that are joined together in a string to conform to a regular
CCV term format. A set of such terms are passed on for evaluation
to the same function as the CCV classification form uses.
"""
variant_ccv_classifications = list(
store.get_ccv_evaluations_case_specific(document_id=variant_obj["_id"])
)
if variant_ccv_classifications:
terms = set()
for criterium in variant_ccv_classifications[0].get("ccv_criteria", []):
term = criterium.get("term")
if criterium.get("modifier"):
term += f"_{criterium.get('modifier')}"
terms.add(term)
variant_obj["bayesian_ccv"] = get_ccv_temperature(terms)


def case_report_variants(store: MongoAdapter, case_obj: dict, institute_obj: dict, data: dict):
"""Gather evaluated variants info to include in case report."""

Expand All @@ -646,6 +667,7 @@ def case_report_variants(store: MongoAdapter, case_obj: dict, institute_obj: dic
if case_key == "partial_causatives":
var_obj["phenotypes"] = case_obj["partial_causatives"][var_id]
add_bayesian_acmg_classification(var_obj)
add_bayesian_ccv_classification(var_obj)
evaluated_variants_by_type[eval_category].append(
_get_decorated_var(var_obj=var_obj, institute_obj=institute_obj, case_obj=case_obj)
)
Expand Down Expand Up @@ -687,6 +709,7 @@ def _append_evaluated_variant_by_type(
if variant_key in var_obj and var_obj[variant_key] is not None:

add_bayesian_acmg_classification(var_obj)
add_bayesian_ccv_classification(var_obj)

evaluated_variants_by_type[eval_category].append(
_get_decorated_var(var_obj=var_obj, institute_obj=institute_obj, case_obj=case_obj)
Expand Down
15 changes: 11 additions & 4 deletions scout/server/blueprints/cases/templates/cases/case_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ <h4>Scout case analysis report</h4> - created on:&nbsp;<strong>{{report_created_
</tr>
</table>
<table id="panel-table" class="table table-sm" style="background-color: transparent">
<thead>
<thead style="text-align:center;">
<tr>
<th>Rank</th>
<th>Score</th>
Expand All @@ -674,7 +674,7 @@ <h4>Scout case analysis report</h4> - created on:&nbsp;<strong>{{report_created_
{% endif %}
</tr>
</thead>
<tbody>
<tbody style="text-align:center;">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, the alignment in general isn't super consistent on the report, but to me a couple of table lines in the bulk there with suddenly centered numbers stands out a bit, where it would look quite good on its own. If you had good reason, keep it - it seems to align somewhat with some other columns in the same card - but otherwise seems easier to keep them all defaulting left.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason is that I personally think it looks better, but I don't have a problem changing it back

<tr>
<td>{{variant.variant_rank}}</td>
<td>{{variant.rank_score}}</td>
Expand Down Expand Up @@ -715,7 +715,7 @@ <h4>Scout case analysis report</h4> - created on:&nbsp;<strong>{{report_created_
{% endif %}
<td>
{% if variant.acmg_classification %}
<span class="badge rounded-pill bg-{{variant.acmg_classification['color'] if variant.acmg_classification['color'] else 'secondary'}}" title="{{variant.acmg_classification['code']}}">{{variant.acmg_classification['code'] }}</span>
<span class="badge rounded-pill bg-{{variant.acmg_classification['color'] if variant.acmg_classification['color'] else 'secondary'}}" title="{{variant.acmg_classification['label']}}">{{variant.acmg_classification['label'] }}</span>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

{% else %}
-
{% endif %}
Expand All @@ -730,10 +730,17 @@ <h4>Scout case analysis report</h4> - created on:&nbsp;<strong>{{report_created_
{% if cancer %}
<td>
{% if variant.ccv_classification %}
<span class="badge rounded-pill bg-{{variant.ccv_classification['color'] if variant.ccv_classification['color'] else 'secondary'}}" title="{{variant.ccv_classification['code']}}">{{variant.ccv_classification['code'] }}</span>
<span class="badge rounded-pill bg-{{variant.ccv_classification['color'] if variant.ccv_classification['color'] else 'secondary'}}" title="{{variant.ccv_classification['label']}}">{{variant.ccv_classification['label'] }}</span>
{% else %}
-
{% endif %}
{% if variant.bayesian_ccv %}
<span class="badge rounded-pill bg-{{variant.bayesian_ccv.temperature_class}}">Score {{variant.bayesian_ccv.points|string}} <span class='fa {{variant.bayesian_ccv.temperature_icon}}'></span>
{% if variant.bayesian_ccv.point_classification == "VUS" %}
{{variant.bayesian_ccv.temperature}}
{% endif %}
</span>
{% endif %}
</td>
{% endif %}
</tr>
Expand Down
10 changes: 1 addition & 9 deletions scout/utils/ccv.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,7 @@ def get_ccv_temperature(ccv_terms: set) -> Optional[dict]:
}

if not ccv_terms:
points = 0
point_classification = "uncertain_significance"
return {
"points": points,
"temperature": TEMPERATURE_STRINGS[points].get("label"),
"temperature_class": TEMPERATURE_STRINGS[points].get("color"),
"temperature_icon": TEMPERATURE_STRINGS[points].get("icon"),
"point_classification": CCV_COMPLETE_MAP[point_classification].get("short"),
}
return {}

points = get_ccv_points(ccv_terms)

Expand Down
Loading