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

Fom MANE overview, link out to gene overview #368

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -4,6 +4,7 @@
- Check that provided d4 files when running queries using `/coverage/d4/genes/summary` endpoint are valid, with test
- General report with coverage over the entire genome when no genes or genes panels are provided
- A MANE coverage report, showing coverage and coverage completeness only on MANE transcripts for the provided list of genes
- Link out from MANE overview to gene overview
### Changed
- Do not use stored cases/samples any more and run stats exclusively on d4 files paths provided by the user in real time
- How parameters are passed to starlette.templating since it was raising a deprecation warning.
Expand Down
5 changes: 3 additions & 2 deletions src/chanjo2/endpoints/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,14 @@ async def demo_mane_overview(
@router.post("/mane_overview", response_class=HTMLResponse)
async def mane_overview(
request: Request,
build=Annotated[Builds, Form(Builds.build_38)],
samples=Annotated[str, Form(...)],
interval_type=Annotated[IntervalType, Form(IntervalType.TRANSCRIPTS)],
completeness_thresholds=Annotated[Optional[str], Form(None)],
ensembl_gene_ids=Annotated[Optional[str], Form(None)],
hgnc_gene_ids=Annotated[Optional[str], Form(None)],
hgnc_gene_symbols=Annotated[Optional[str], Form(None)],
case_display_name=Annotated[Optional[str], Form(None)],
panel_name=Annotated[Optional[str], Form("Custom panel")],
default_level=Annotated[Optional[int], Form(DEFAULT_COVERAGE_LEVEL)],
db: Session = Depends(get_session),
):
"""Returns coverage overview stats for a group of samples over MANE transcripts of a list of genes."""
Expand Down
1 change: 1 addition & 0 deletions src/chanjo2/meta/handle_report_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def get_mane_overview_coverage_stats(query: ReportQuery, session: Session) -> Di
or query.hgnc_gene_symbols
or query.ensembl_gene_ids,
"interval_type": query.interval_type.value,
"default_level": query.default_level,
"completeness_thresholds": query.completeness_thresholds,
"samples": [_serialize_sample(sample) for sample in query.samples],
"panel_name": query.panel_name,
Expand Down
33 changes: 32 additions & 1 deletion src/chanjo2/templates/mane-overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ <h2 class="accordion-header" id="flush-headingOne">
<!-- hidden fields passed from previous query -->
<form name="customizeForm" action="{{url_for('mane_overview')}}" method="post">
<input type="hidden" name="build" value="GRCh38"/>
<input type="hidden" name="default_level" id="defaultLevel" value="{{extras.default_level}}"/>
Copy link
Member Author

Choose a reason for hiding this comment

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

Default level is not used in the MANE overview report, but in the gene overview, and this is a way to pass along the value

<input type="hidden" name="completeness_thresholds" value="{{extras.completeness_thresholds|join(',')}}"/>
<input type="hidden" name="interval_type" value="transcripts"/>
<input type="hidden" name="samples" value="{{extras.samples|safe}}"/>

Expand Down Expand Up @@ -59,12 +61,21 @@ <h2>MANE Transcripts coverage report</h2>
<p>Based on gene panel: <strong>{{ extras.panel_name }}</strong></p>
{% endif %}
<br>
<form id="maneStatsForm" action="{{url_for('gene_overview')}}" method="post">
<input type="hidden" name="build" value="GRCh38"/>
<input type="hidden" name="default_level" id="defaultLevel" value="{{extras.default_level}}"/>
<input type="hidden" name="completeness_thresholds" value="{{extras.completeness_thresholds|join(',')}}"/>
<input type="hidden" name="interval_type" value="transcripts"/>
<input type="hidden" name="samples" value="{{extras.samples|safe}}"/>

{% for gene_id, samples_stats in mane_coverage_stats|sort(attribute='0') %}
<tr>
<td class="row">
<div class="panel-default">
<div class="panel-heading">
<strong>Gene {{ gene_id or samples_stats.gene.hgnc_id }}</strong>
<strong>Gene <a href="#" onclick="getGeneStatsPage({{samples_stats.gene.hgnc_id}});">
{{ gene_id or samples_stats.gene.hgnc_id }}
</a></strong>
{% if samples_stats.transcript.mane_select %}
<span class="badge">MANE Select: {{samples_stats.transcript.mane_select}}</span>
{% endif %}
Expand Down Expand Up @@ -102,6 +113,7 @@ <h2>MANE Transcripts coverage report</h2>
{% else %}
No MANE transcripts found in database for the provided gene list.
{% endfor %}
</form>
{% endmacro %}

{% block title %}
Expand All @@ -112,3 +124,22 @@ <h2>MANE Transcripts coverage report</h2>
{{report_filters() }}
{{ mane_stats_macro() }}
{% endblock %}

{% block js_code %}
{{ super() }}
<script>
let theForm = document.getElementById("maneStatsForm");
function getGeneStatsPage(hgncId)
{
var geneInput = document.createElement("input");
geneInput.setAttribute("type", "hidden");
geneInput.setAttribute("name", "hgnc_gene_id");
geneInput.setAttribute("value", hgncId);
theForm.appendChild(geneInput);
theForm.setAttribute("target", "_blank");
theForm.setAttribute("rel", "noopener");
theForm.submit();
}
</script>
{% endblock %}

Loading