Skip to content

Commit

Permalink
Merge branch 'release/0.1.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
abought committed Dec 17, 2019
2 parents 3545254 + 69c8400 commit 1657f52
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/carbon
lts/erbium
3 changes: 2 additions & 1 deletion assets/js/pages/gwas_region.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ function makePlot(template_vars) {
{
lz_sources: getBasicSources(assoc_sources),
lz_layout: getBasicLayout(state, panels, { responsive_resize: false }),
study_names: [template_vars.label]
study_names: [template_vars.label],
top_hits_url: template_vars.top_hits_url,
}, template_vars,
{
genome_build: template_vars.build,
Expand Down
1 change: 0 additions & 1 deletion assets/js/pages/gwas_summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ function createTopHitsTable(selector, data, region_url) {
data = data.filter(v => !!v.peak)
.map(item => {
// FIXME: Synthetic field; feed a marker into pheweb loader code for better tables in the future
// TODO: Get pheweb "nearest gene" annotations working (and make build agnostic)
item.marker = `${item.chrom}: ${item.pos.toLocaleString()}`;
return item;
});
Expand Down
79 changes: 63 additions & 16 deletions assets/vue/gwas_region.vue
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
<script>
// Custom interactivity attached to the "GWAS Region/LocusZoom plot" page
import BatchSpec from 'locuszoom-tabix/src/components/BatchSpec.vue';
import BatchScroller from 'locuszoom-tabix/src/components/BatchScroller.vue';
import PlotPanes from 'locuszoom-tabix/src/components/PlotPanes.vue';
import RegionPicker from 'locuszoom-tabix/src/components/RegionPicker.vue';
const MAX_REGION_SIZE = 1000000;
export default {
name: 'gwas_region',
props: [
'build', 'chr', 'start', 'end',
'lz_layout',
'lz_sources',
'study_names',
'top_hits_url'
],
data() {
return {
// make constant available
max_region_size: MAX_REGION_SIZE,
message: '',
message_class: '',
// Allow initial state to be passed in, but then mutated as user navigates
c_chr: this.chr,
c_start: this.start,
c_end: this.end
c_end: this.end,
// Controls for "batch view" mode
batch_mode_active: false,
batch_mode_regions: [],
};
},
methods: {
activateBatchMode(regions) {
this.batch_mode_active = true;
this.batch_mode_regions = regions;
},
showMessage(message, style = 'text-danger') {
this.message = message;
this.message_class = style;
Expand All @@ -35,23 +48,59 @@
this.c_start = region.start;
this.c_end = region.end;
},
fetchTopHits() {
// Used for batch mode "get top hits" button
// Fetch pre-computed top loci, in sorted order, and return list of [ {chr, start, end} ] entries
return fetch(this.top_hits_url)
.then(resp => {
if (resp.ok) {
return resp.json();
}
throw new Error('Could not retrieve results');
}).then(json => {
// Convert the list of peaks (top hits) into manageable nearby regions (target +/- 250k)
return json.unbinned_variants.filter(variant => !!variant.peak)
.sort((a, b) => b.neg_log_pvalue - a.neg_log_pvalue)
.map(variant => ({
chr: variant.chrom,
start: +variant.pos - 250000,
end: +variant.pos + 250000
}));
});
}
},
components: { PlotPanes, RegionPicker }
components: { BatchSpec, BatchScroller, PlotPanes, RegionPicker }
}
</script>

<template>
<div>
<div class="row">
<div class="col-md-8"></div>
<div class="col-md-4">
<region-picker
@ready="updateRegion"
@fail="showMessage"
class="float-right"
:build="build"
:max_range="500000"
search_url="https://portaldev.sph.umich.edu/api/v1/annotation/omnisearch/"/>
<div class="row" v-if="!batch_mode_active">
<div class="col-md-4"></div>
<div class="col-md-8">
<div class="d-flex justify-content-end">
<region-picker
@ready="updateRegion"
@fail="showMessage"
class="float-right"
:build="build"
:max_range="max_region_size"
search_url="https://portaldev.sph.umich.edu/api/v1/annotation/omnisearch/"/>
<batch-spec class="ml-1"
:max_range="max_region_size"
@ready="activateBatchMode">
<template #preset-button="{updateRegions}">
<button class="btn btn-warning" @click="updateRegions(fetchTopHits())">Get top hits</button>
</template>
</batch-spec>
</div>
</div>
</div>
<div class="row" v-else>
<div class="col-md-12">
<batch-scroller :regions="batch_mode_regions"
@navigate="updateRegion"
@cancel="batch_mode_active = false"/>
</div>
</div>
<div class="row" v-if="message">
Expand All @@ -64,10 +113,8 @@
:assoc_layout="lz_layout" :assoc_sources="lz_sources"
:study_names="study_names" :has_credible_sets="true"
:build="build"
:chr="c_chr" :start="c_start" :end="c_end" />
:chr="c_chr" :start="c_start" :end="c_end"/>
</div>
</div>
</div>
</template>

<style scoped></style>
4 changes: 4 additions & 0 deletions locuszoom_plotting_service/gwas/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ def get_context_data(self, **kwargs):
reverse('apiv1:gwas-region', kwargs={'slug': gwas.slug}),
token
),
'top_hits_url': add_token(
reverse('gwas:manhattan-json', kwargs={'slug': gwas.slug}),
token,
),
'label': gwas.label,
'build': gwas.build,
# Default region for bare URLs is the top hit in the study
Expand Down
7 changes: 5 additions & 2 deletions locuszoom_plotting_service/taskapp/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from django.db.models import signals
from django.db import transaction
from django.dispatch import receiver
from django.urls import reverse
from django.utils import timezone

from zorp import (
Expand Down Expand Up @@ -156,8 +157,9 @@ def mark_success(self, fileset_id):
metadata.save()

# TODO: Render this as a nicer-looking template
log_url = reverse('gwas:gwas-ingest-log', kwargs={'slug': metadata.slug})
send_mail('[locuszoom] Upload succeeded',
f'Your upload is done processing. Please visit https://{settings.LZ_OFFICIAL_DOMAIN}{metadata.get_absolute_url()} to see the Manhattan plot and begin exploring regions of your data.', # noqa
f'Your upload is done processing. Please visit https://{settings.LZ_OFFICIAL_DOMAIN}{metadata.get_absolute_url()} to see the Manhattan plot and begin exploring regions of your data.\nBe sure to review the ingest logs for any warnings: https://{settings.LZ_OFFICIAL_DOMAIN}{log_url}', # noqa
'[email protected]',
[metadata.owner.email])

Expand All @@ -176,8 +178,9 @@ def mark_failure(self, fileset_id):
instance.save()

metadata = instance.metadata
log_url = reverse('gwas:gwas-ingest-log', kwargs={'slug': metadata.slug})
send_mail('[locuszoom] Upload failed',
f'Your upload failed to process. Please visit https://{settings.LZ_OFFICIAL_DOMAIN}{metadata.get_absolute_url()} to see the error logs.', # noqa
f'Your upload failed to process. Please review the ingest logs for warnings and error messages: https://{settings.LZ_OFFICIAL_DOMAIN}{log_url}\nOr visit the upload page to change settings: https://{settings.LZ_OFFICIAL_DOMAIN}{metadata.get_absolute_url()}', # noqa
'[email protected]',
[metadata.owner.email])

Expand Down
19 changes: 8 additions & 11 deletions locuszoom_plotting_service/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@

<link rel="icon" href="{% static 'images/favicons/favicon.ico' %}">

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css"
integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link href="{% static 'css/site.css' %}" rel="stylesheet">
{% block css %}{% endblock %}
</head>
Expand Down Expand Up @@ -131,15 +131,12 @@
</footer>

{# Javascript: global template code, plus custom items per page #}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"
integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T"
crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" crossorigin="anonymous"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" crossorigin="anonymous"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" crossorigin="anonymous"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"></script>
{% block javascript %}{% endblock javascript %}
</body>
</html>
Expand Down
3 changes: 3 additions & 0 deletions locuszoom_plotting_service/templates/gwas/gwas_region.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<span class="text-muted">Uploaded by: {{ gwas.owner.display_name }}, {{ gwas.created | date }}</span>
{% if gwas.is_public %}<span class="badge badge-info">Public</span> {% else %}<span class="badge badge-warning">Private</span>{% endif %}
{% if gwas.pmid %}<a href="https://www.ncbi.nlm.nih.gov/pubmed/{{gwas.pmid}}" target="_blank" class="badge badge-dark">PubMed</a>{% endif %}
{% if gwas.owner == request.user %}(<a href="{% url 'gwas:edit' gwas.slug %}">edit</a>)
{% if not gwas.is_public %}(<a href="{% url 'gwas:share' gwas.slug %}">share</a>){% endif %}
{% endif %}
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"d3": "3.5.16",
"d3-tip": "0.9.0",
"gwas-credible-sets": "^0.1.0",
"locuszoom": "0.10.0-beta.2",
"locuszoom-tabix": "https://github.com/statgen/localzoom#dbcc3e5",
"locuszoom": "0.10.0",
"locuszoom-tabix": "https://github.com/statgen/localzoom#918fd75",
"pako": "^1.0.8",
"underscore": "1.8.3",
"vue": "^2.6.10",
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3253,25 +3253,25 @@ locate-path@^3.0.0:
p-locate "^3.0.0"
path-exists "^3.0.0"

"locuszoom-tabix@https://github.com/statgen/localzoom#dbcc3e5":
version "0.4.0"
resolved "https://github.com/statgen/localzoom#dbcc3e59a2061903d831ca4f8d6874f271f2590f"
"locuszoom-tabix@https://github.com/statgen/localzoom#918fd75":
version "0.5.0"
resolved "https://github.com/statgen/localzoom#918fd7525f7e14c13dae60dc6f630188b1669c53"
dependencies:
"@sentry/browser" "^4.5.2"
bootstrap "^4.1.3"
bootstrap-vue "^2.0.0-rc.11"
gwas-credible-sets "^0.1.0"
locuszoom "0.10.0-beta.2"
locuszoom "0.10.0"
lodash "^4.17.11"
tabix-reader "https://github.com/abought/tabix-reader"
tabulator-tables "^4.1.4"
vue "^2.6.10"
vue-bootstrap-typeahead "^0.2.6"

[email protected]-beta.2:
version "0.10.0-beta.2"
resolved "https://registry.yarnpkg.com/locuszoom/-/locuszoom-0.10.0-beta.2.tgz#7c007c421ee3c1e39f9adab6612874761bb455c6"
integrity sha512-SkyquD7OCPJQcCrFoJxHBlA9/U9CNJb+EE1n+O/jnX5CqiFlPUHHrzi8KzBUPZ25DQHdtCHXM7YE+0imHTrYDg==
[email protected]:
version "0.10.0"
resolved "https://registry.yarnpkg.com/locuszoom/-/locuszoom-0.10.0.tgz#7dad2341af6e539f6bbf0878ec1753a521e7c647"
integrity sha512-v+g8YKHszmZL7/yJg5EDZhrGS3jlGoP/WTXM0WFjTUi8MrPCADaeutwx/FhkmZtbhtlb+khO+8EYItaaTGEMLg==
dependencies:
d3 "3.5.17"
promise-polyfill "^8.1.3"
Expand Down

0 comments on commit 1657f52

Please sign in to comment.