forked from glormph/nf-core-labelcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnonpooled_qc.html
226 lines (203 loc) · 8.87 KB
/
nonpooled_qc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<html lang="en">
<head>
<meta http-equiv="Content-Security-Policy" content="script-src 'unsafe-inline' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net/npm/[email protected];">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.2/css/bulma.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.bundle.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<title>Labelcheck report -- nonpooled</title>
</head>
<body>
<div class="container">
<h3 class="title is-3">Labelcheck report</h3>
<h4 class="subtitle is-4">nonpooled</h4>
<div class="columns">
<div class="column">
<h5 class="title is-5"># PSMs</h5>
<canvas id="psms_labeled" ></canvas>
</div>
<div class="column">
<h5 class="title is-5"># Peptides</h5>
<canvas id="peptides_labeled" ></canvas>
</div>
</div>
<h5 class="title is-5">Mean channel intensities</h5>
<canvas id="isomeans"></canvas>
<h5 class="title is-5">Missed cleavages</h5>
<canvas id="miscleavages"></canvas>
</div>
</body>
<script>
function dset(label, data, bgcol, bordercol) {
return {label: label, data: data,
backgroundColor: bgcol,
borderColor: bordercol, borderWidth: 1};
}
function horizBar(labels, datasets, annotation, xlab, stepsize=false, annotate_value=false, annotate_icon=false) {
plot = {
type: 'horizontalBar',
data: {
labels: labels,
datasets: datasets,
},
options: {
scales: {
xAxes: [{
scaleLabel: {display: true, labelString: xlab},
stacked: true,
ticks: {
stepSize: stepsize,
beginAtZero: true,
},
}],
yAxes: [{
stacked: true,
}]
}
}
};
plot.plugins = [ChartDataLabels];
plot.options.plugins = {
datalabels: {
labels: {
inBar: {
align: 'end', formatter: function(val, context) {
// value: {
// anchor: 'start',
// align: 'right',
// clamp: true,
// formatter: function(val, context) {
var ix = context.dataIndex;
// if (!annotate_value || context.datasetIndex !== 0) {
if (context.datasetIndex === annotation[ix][0]) {
return annotation[ix][1];
} else {
return '';
}
}
// } else if (percents && annotate_value) {
// return `${val.toFixed(1)}%`;
// } else { return `${val.toFixed()}`; }
//}
},
icon: {
font: {family: 'FontAwesome', size:20,},
anchor: 'start',
align: 'right',
formatter: function(val, context) {
var ix = context.dataIndex;
if (!annotate_icon || context.datasetIndex !== 0) {
return '';
} else { return annotate_icon[ix][1]; }
}
},
value: {
anchor: 'start',
align: 'right',
formatter: function(val, context) {
var ix = context.dataIndex;
if (!annotate_value || context.datasetIndex !== 0) {
return '';
} else { return `${val}%`; }
}
},
}
}
}
return plot;
}
function cyclecol(gamma) {
return [`rgba(255, 99, 132, ${gamma})`, // red
`rgba(54, 162, 235, ${gamma})`, // blue
`rgba(255, 178, 102, ${gamma})`, // orange
`rgba(204, 153, 255, ${gamma})`, // purple
`rgba(204, 204, 0, ${gamma})`, // yellow
`rgba(255, 204, 255, ${gamma})`,
`rgba(102, 204, 0, ${gamma})`, // green
`rgba(255, 102, 255, ${gamma})`, // magenta
`rgba(192, 192, 192, ${gamma})`, // grey
`rgba(51, 255, 255, ${gamma})`, // lightblue
`rgba(153, 0, 76, ${gamma})`, // dark magenta
`rgba(204, 102, 0, ${gamma})`, // orangebrown
];
}
function cols(label, gamma) {
return {'labeled': cyclecol(gamma)[0], 'nonlabeled': cyclecol(gamma)[1],}[label]
}
Chart.plugins.unregister(ChartDataLabels);
const labeleddata = {'psms': {'labeled': [59, 70], 'nonlabeled': [1, 1]}, 'peps': {'labeled': [51, 65], 'nonlabeled': [1, 1]}};
const filenames = ['xc-cll-f10_500.mzML', 'xc-cll-f10_2_500.mzML'];
const inputchannels = ['126', '130C'];
const samples = [];
const isodata = {'medians': [{'126': 102429.4, '127N': 108495.15, '127C': 115958.20000000001, '128N': 113345.5, '128C': 110473.4, '129N': 134873.84999999998, '129C': 115019.0, '130N': 142079.85, '130C': 72706.055, '131': 130526.6}, {'126': 129796.3, '127N': 154303.2, '127C': 168207.1, '128N': 151224.7, '128C': 150512.4, '129N': 182496.2, '129C': 170977.4, '130N': 193837.40000000002, '130C': 109589.45, '131': 185456.2}], 'missingvals': [{'126': 0.0, '127N': 0.0, '127C': 0.0, '128N': 0.0, '128C': 0.0, '129N': 0.0, '129C': 0.0, '130N': 0.0, '130C': 0.0, '131': 0.0}, {'126': 0.0, '127N': 1.4084507042253522, '127C': 0.0, '128N': 0.0, '128C': 0.0, '129N': 0.0, '129C': 0.0, '130N': 1.4084507042253522, '130C': 1.4084507042253522, '131': 0.0}], 'miscleav': [{'0': 76.66666666666667, '1': 23.333333333333332, '2': 0.0}, {'0': 84.50704225352112, '1': 15.492957746478872, '2': 0.0}], 'pass': [59, 70], 'fail': [1, 1]};
const missdata = [];
const miscleavs = [...Array(2).keys()];
const fn_ch = filenames.map((fn, ix) => `${fn}_${inputchannels[ix]}`)
let labdsets = {
'psms': {percent: [], annot: []},
'peps': {percent: [], annot: []},
'iso': {means: [], annot: {bar: [], icon: []}},
'missed': {percent: [], annot: []},
};
// LABEL EFFICIENCY
let lab;
let nonlab;
Object.entries(labeleddata).forEach(([ftype, feats]) => {
lab = feats.labeled.map(function(val, ix) { return Math.round(val / (val + feats.nonlabeled[ix]) * 10000)/100 });
nonlab = feats.nonlabeled.map(function(val, ix) { return Math.round(val / (val + feats.labeled[ix]) * 10000)/100 });
labdsets[ftype].percent.push(dset('Labeled', lab, cols('labeled', 0.2), cols('labeled', 1)));
labdsets[ftype].percent.push(dset('Non-labeled', nonlab, cols('nonlabeled', 0.2), cols('nonlabeled', 1)));
labdsets[ftype].annot = feats.labeled.map(function(x, ix) {
let text = [];
if (inputchannels.length) {text.push(inputchannels[ix]); }
if (samples.length) {text.push(samples[ix]); }
text.push(`Total passing: ${x}`);
return [0, text.join(', ')];
});
});
const bgcols = cyclecol(0.2);
const bordercols = cyclecol(1);
// ISOBARIC CHANNEL INTENSITIES
Object.keys(isodata.medians[0])
.sort((a, b) => a[0].replace('N', 'A') > b[0].replace('N', 'A'))
.forEach((ch, chix) => {
let ch_data = [];
filenames.forEach((fn, fnix) => {
ch_data.push(isodata.medians[fnix][ch]);
});
labdsets.iso.means.push(dset(ch, ch_data, bgcols[chix], bordercols[chix]));
});
filenames.forEach((fn, fnix) => {
const fn_chvals = Object.entries(isodata.medians[fnix])
const fnvals = fn_chvals.map(x => x[1])
const chmax_ix = fnvals.indexOf(Math.max(...fnvals));
labdsets.iso.annot.bar.push([0, `Max intensity in ${fn_chvals[chmax_ix]}`]);
labdsets.iso.annot.icon.push([inputchannels.length - 1, fn_chvals[chmax_ix][0] === inputchannels[fnix] ? '\uf00c': '\uf00d']);
});
// MISSED CLEAVAGE:
const mistotals = missdata.map(x => Object.values(x).reduce((x,y) => x + y));
// Show data for 0-2 missed cleavages
miscleavs.forEach(mc => {
labdsets.missed.percent.push(dset(mc, isodata.miscleav.map((x, ix) => mc in x ? x[mc] : 0), bgcols[mc], bordercols[mc]));
});
labdsets.missed.annot = isodata.miscleav.map((x, ix) => [0, `No missed cleavages: ${Math.round(x[0] * 100) / 100}% - Total PSMs: ${isodata.pass[ix] + isodata.fail[ix]}`]);
// PLOTS:
graphheight = 25 + 20 * labeleddata.psms.labeled.length;
var psmcv = document.getElementById('psms_labeled');
psmcv.height = graphheight;
var psmctx = psmcv.getContext('2d');
var psmchart = new Chart(psmctx, horizBar(fn_ch, labdsets.psms.percent, labdsets.psms.annot, '% labeled', stepsize=5, annotate_value=true));
var pepcv = document.getElementById('peptides_labeled');
pepcv.height = graphheight;
var pepctx = pepcv.getContext('2d');
var pepchart = new Chart(pepctx, horizBar(fn_ch, labdsets.peps.percent, labdsets.peps.annot, '% labeled', stepsize=5, annotate_value=true));
var isocv = document.getElementById('isomeans');
isocv.height = graphheight / 2;
var isoctx = isocv.getContext('2d');
var isochart = new Chart(isoctx, horizBar(fn_ch, labdsets.iso.means, labdsets.iso.annot.bar, 'Raw intensity', false, false, labdsets.iso.annot.icon));
var misscv = document.getElementById('miscleavages');
misscv.height = graphheight / 2;
var missctx = misscv.getContext('2d');
var misschart = new Chart(missctx, horizBar(fn_ch, labdsets.missed.percent, labdsets.missed.annot, '% missed cleavages', false, false))
</script>
</html>