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

Feature/panel summary, solves #40 #42

Merged
merged 5 commits into from
Jun 29, 2021
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
6 changes: 6 additions & 0 deletions ExonCov/templates/sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<thead>
<tr>
<th>Gene Panel</th>
<th>Summary</th>
<th>Size (bp)</th>
{% for type in measurement_types %}
<th>{{ measurement_types[type] }}</th>
Expand All @@ -60,6 +61,11 @@
{% for panel in panels %}
<tr>
<td><a href="{{ url_for('sample_panel', sample_id=sample.id, panel_id=panel) }}">{{ panels[panel]['name_version'] }}</a></td>
{% if panels[panel]['measurement_percentage15'] < panels[panel]['coverage_requirement_15'] %}
<td class="danger">Dekking {{ panels[panel]['name_version'] }} >15X = {{ panels[panel]['measurement_percentage15']|float|round(2) }}% ; QC failed.</td>
{% else %}
<td>Dekking {{ panels[panel]['name_version'] }} >15X = {{ panels[panel]['measurement_percentage15']|float|round(2) }}%.</td>
{% endif %}
<td>{{ panels[panel]['len'] }}</td>
{% for type in measurement_types %}
{{ render_panel_measurement_td(panels[panel][type], type, panels[panel]) }}
Expand Down
21 changes: 20 additions & 1 deletion ExonCov/templates/sample_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,26 @@
<dt>Type</dt><dd>{{ sample.type }}</dd>
<dt>Sequencing runs</dt><dd><ul class="list-inline">{% for run in sample.sequencing_runs %}<li>{{ run }}</li>{% endfor %}</ul></dd>
<dt>Panel</dt><dd>{{ panel.name_version }} </dd>
<dt>Minimal % 15x</dt><dd>{{ panel.coverage_requirement_15 }}</dd>
<dt>Minimal % 15x</dt><dd><p>{{ panel.coverage_requirement_15 }}</p></dd>
<dt>Summary</dt><dd>
{% if panel_summary['measurement_percentage15'] < panel.coverage_requirement_15 %}
<p>Dekking {{ panel.name_version }} >15X = {{ panel_summary['measurement_percentage15']|float|round(2) }}% ; <code>QC failed</code>.</p>
FiniDG marked this conversation as resolved.
Show resolved Hide resolved
{% else %}
<p>Dekking {{ panel.name_version }} >15X = {{ panel_summary['measurement_percentage15']|float|round(2) }}%.</p>
{% endif %}
{% if panel.core_genes %}
{% if panel_summary['core_genes'] %}
Core genen met 15x dekking < 100%: {{panel_summary['core_genes']}}.<br>
{% else %}
Core genen met 15x dekking < 100%: geen.<br>
{% endif %}
{% endif %}
{% if panel_summary['genes_15'] %}
Genen met 15x dekking < 95%: {{panel_summary['genes_15']}}.<br>
{% else %}
Genen met 15x dekking < 95%: geen.<br>
{% endif %}
</dd>
</dl>
</div>

Expand Down
18 changes: 17 additions & 1 deletion ExonCov/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,31 @@ def sample_panel(sample_id, panel_id):
.filter_by(sample_id=sample.id)
.options(joinedload(Transcript.exons, innerjoin=True))
.options(joinedload(Transcript.gene))
.order_by(TranscriptMeasurement.measurement_percentage15.asc())
.all()
)

# Setup panel summary
panel_summary = {
'measurement_percentage15': weighted_average(
[tm[1].measurement_percentage15 for tm in transcript_measurements],
[tm[1].len for tm in transcript_measurements]
),
'core_genes': ', '.join(
['{}({}) = {:.2f}%'.format(tm[0].gene, tm[0], tm[1].measurement_percentage15) for tm in transcript_measurements if tm[0].gene in panel.core_genes and tm[1].measurement_percentage15 < 100]
FiniDG marked this conversation as resolved.
Show resolved Hide resolved
),
'genes_15': ', '.join(
['{}({}) = {:.2f}%'.format(tm[0].gene, tm[0], tm[1].measurement_percentage15) for tm in transcript_measurements if tm[0].gene not in panel.core_genes and tm[1].measurement_percentage15 < 95]
)
}

return render_template(
'sample_panel.html',
sample=sample,
panel=panel,
transcript_measurements=transcript_measurements,
measurement_types=measurement_types
measurement_types=measurement_types,
panel_summary=panel_summary
)


Expand Down