Skip to content

Commit

Permalink
Gene isobaric plots added
Browse files Browse the repository at this point in the history
  • Loading branch information
glormph committed Sep 27, 2024
1 parent 88b2827 commit 86792dc
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/backend/mstulos/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
path('upload/done/', views.upload_done, name='upload_done'),
path('plotdata/peptides/', views.fetch_plotdata_peptides),
path('plotdata/psms/', views.fetch_plotdata_psms),
path('plotdata/genes/', views.fetch_plotdata_genes),
]

30 changes: 30 additions & 0 deletions src/backend/mstulos/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,36 @@ def frontpage(request):
return render(request, 'mstulos/front_pep.html', context=context)


@login_required
@require_POST
def fetch_plotdata_genes(request):
'''As fetch_plotdata_peptides, but with only isobaric values,
which is the only thing we store'''
data = json.loads(request.body.decode('utf-8'))
## Only the isobaric quant values
## First map the channel / sample / set names
channel_samples = {x: {} for x in data['expids']}
ctypes = m.Condition.Condtype
for cond in m.Condition.objects.filter(experiment_id__in=data['expids'], cond_type=ctypes.CHANNEL):
channel_samples[cond.pk] = {'name': cond.name, 'exp': cond.experiment_id}
for pc in cond.parent_conds.all():
ctype = ctypes(pc.cond_type).name
channel_samples[cond.pk][ctype] = pc.name

genemap = {x.pk: x.name for x in m.Gene.objects.filter(pk__in=data['gids'])}
# DB fetch isoquant peptides and put in list
iso = m.GeneIsoQuant.objects.filter(gene__pk__in=data['gids'],
channel__experiment__pk__in=data['expids']
).annotate(ch=F('channel')).values('ch', 'gene', 'value')

return JsonResponse({'conditions': {x.value: x.label for x in ctypes},
'chmap': channel_samples,
'experiments': {x.pk: x.analysis.name for x in m.Experiment.objects.filter(pk__in=data['expids'])},
'genemap': genemap,
'isobaric': [x for x in iso],
})


@login_required
@require_POST
def fetch_plotdata_peptides(request):
Expand Down
4 changes: 4 additions & 0 deletions src/frontend/mstulos/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { onMount } from 'svelte';
import Tablerow from './Tablerow.svelte';
import Plots from './Plots.svelte'
import GenePlots from './GenePlots.svelte'
import AggPlotsPep from './AggregatePlots.svelte'
import AggPlotsPSM from './AggregatePlotsPSM.svelte'
Expand Down Expand Up @@ -302,12 +303,15 @@ onMount(async() => {
<div>
<p class="is-size-5">Plot {nr_filtered_pep} peptide{nr_filtered_pep > 1 ? 's' : ''} over {nr_filtered_exp} experiment{nr_filtered_exp > 1 ? 's' : ''}</p>
<button class="button" on:click={e => switchPlot('peptides')}>Peptides</button>
<button class="button" on:click={e => switchPlot('genes')}>Gene</button>
<button class="button" on:click={e => switchPlot('aggregates_pep')}>Aggregated peptides</button>
<button class="button" on:click={e => switchPlot('aggregates_psm')}>Aggregated PSMs</button>
</div>

{#if showplots.peptides}
<Plots />
{:else if showplots.genes}
<GenePlots />
{:else if showplots.aggregates_pep}
<AggPlotsPep />
{:else if showplots.aggregates_psm}
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/mstulos/src/Plots.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { postJSON } from '../../datasets/src/funcJSON.js'
import * as Plot from '@observablehq/plot';
// data is already top lvl on the document so need no passing in here
let plots
let plots;
let errors = [];
async function fetchData() {
Expand Down

0 comments on commit 86792dc

Please sign in to comment.