Repository navigation
Expand file tree
/
Copy pathexample_qc.html
More file actions
210 lines (186 loc) · 8.14 KB
/
Copy pathexample_qc.html
File metadata and controls
210 lines (186 loc) · 8.14 KB
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
<html lang="en">
<head>
<meta http-equiv="Content-Security-Policy" content="script-src 'unsafe-inline' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@0.7.0;">
<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/chartjs-plugin-datalabels@0.7.0"></script>
<title>Labelcheck report</title>
</head>
<body>
<div class="container">
<h3 class="title is-3">Labelcheck report</h3>
<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>
</div>
</body>
<script>
function dset(label, data, bgcol, bordercol) {
return {label: label, data: data,
backgroundColor: bgcol,
borderColor: bordercol, borderWidth: 1};
}
function horizBar(filenames, datasets, annotation, stepsize=false, annotate_value=false, annotate_icon=false) {
const xlab = annotation ? '% labeled' : 'Amount labeled';
plot = {
type: 'horizontalBar',
data: {
labels: filenames,
datasets: datasets,
},
options: {
scales: {
xAxes: [{
scaleLabel: {display: true, labelString: xlab},
stacked: true,
ticks: {
stepSize: stepsize,
},
}],
yAxes: [{
stacked: true,
ticks: {
beginAtZero: true,
}
}]
}
}
};
plot.plugins = [ChartDataLabels];
plot.options.plugins = {
datalabels: {
labels: {
inBar: {
align: 'end', formatter: function(val, context) {
var ix = context.dataIndex;
if (context.datasetIndex === annotation[ix][0]) {
return annotation[ix][1];
} else { return '';}
}
},
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 = {'psm': {'labeled': [775, 795, 774, 782], 'nonlabeled': [5, 11, 5, 19]}, 'pep': {'labeled': [355, 346, 364, 358], 'nonlabeled': [4, 9, 4, 15]}};
const filenames = ['20190101_setA_LC_01', '20190101_setA_LC_02', '20190101_setA_LC_03', '20190101_setA_LC_04'];
const channel_order = ['126', '127N', '127C', '128N', '128C', '129N', '129C', '130N', '130C', '131'];
const samples = ['sample1', 'sample3', 'sample2', 'sampleD'];
const isodata = {'126': [1529971.6968564356, 6537.488514285715, 6135.408201017812, 3328.629404314721], '127N': [1198.0388141089109, 4782.207910169492, 14.352091603053436, 842029.3028172589], '127C': [133199.45719554456, 1318581.4773607748, 22.07441603053435, 11207.687385786801], '128N': [0.2666658415841584, 1478.5425384987893, 27.330648854961833, 67203.8443857868], '128C': [348.3503673267327, 105769.36589346247, 28.418297709923664, 328.78793223350254], '129N': [19.09072277227723, 0.0, 0.25999236641221374, 141.78967538071066], '129C': [15.39638292079208, 141.83685569007264, 2.0399737913486002, 5.103044416243655], '130N': [0.0, 81.55449467312349, 26824.756556234097, 16.98000507614213], '130C': [0.0, 0.0, 139.033193129771, 5.219619289340102], '131': [33.32301608910891, 16281.701338983052, 884142.5308905853, 3683.6631269035533]};
let inputchannels = ['126', '126', '127N', '127N'];
let labdsets = {
'psm': {percent: [], annot: []},
'pep': {percent: [], annot: []},
'iso': {means: [], annot: {bar: [], icon: []}},
};
let lab;
let nonlab;
Object.entries(labeleddata).forEach(function(feats) {
lab = feats[1].labeled.map(function(val, ix) { return Math.round(val / (val + feats[1].nonlabeled[ix]) * 10000)/100 });
nonlab = feats[1].nonlabeled.map(function(val, ix) { return Math.round(val / (val + feats[1].labeled[ix]) * 10000)/100 });
labdsets[feats[0]].percent.push(dset('Labeled', lab, cols('labeled', 0.2), cols('labeled', 1)));
labdsets[feats[0]].percent.push(dset('Non-labeled', nonlab, cols('nonlabeled', 0.2), cols('nonlabeled', 1)));
labdsets[feats[0]].annot = feats[1].labeled.map(function(x, ix) {
let text = [];
if (inputchannels.length) {text.push(inputchannels[ix]); }
if (samples.length) {text.push(samples[ix]); }
text.push(`Total: ${x}`);
return [0, text.join(', ')];
});
});
const bgcols = cyclecol(0.2);
const bordercols = cyclecol(1);
// Create isobaric data matrix, transpose and calculate the max values in it per file
// Add text labels
let fnch;
let fnsam;
let isomx = Object.entries(isodata).sort((x, y )=> x[0].replace('N', 'A') > y[0].replace('N', 'A'))
if (inputchannels.length) {
fnch = Object.fromEntries(filenames.map((fn, ix) => [fn, inputchannels[ix]]));
}
if (inputchannels.length && samples.length) {
fnsam = Object.fromEntries(filenames.map((fn, ix) => [fn, samples[ix]]));
}
//transpose to array [[channel-values-of-first-file], [...second-file], ...]
const isotp = isomx[0][1].map((col, ix) => isomx.map(row => row[1][ix]));
isotp.forEach(function(fn_iso, fnix) {
const chmax_ix = fn_iso.indexOf(Math.max(...fn_iso));
const fn = filenames[fnix];
let text = [];
if (samples.length) {text.push(`Sample: ${fnsam[fn]}`); }
if (inputchannels.length) {text.push(`Channel: ${fnch[fn]}`); }
text.push(`Max. intensity in: ${isomx[chmax_ix][0]}`);
labdsets.iso.annot.bar.push([chmax_ix, text.join(', ')]);
if (inputchannels.length) {
labdsets.iso.annot.icon.push([inputchannels.length - 1, isomx[chmax_ix][0] === inputchannels[fnix] ? '\uf00c': '\uf00d']);
} else {
labdsets.iso.annot.icon = false;
}
});
labdsets.iso.means = isomx.map((chval, ix) => dset(chval[0], isodata[chval[0]], bgcols[ix], bordercols[ix]));
graphheight = 25 + 20 * labeleddata.psm.labeled.length;
var psmcv = document.getElementById('psms_labeled');
psmcv.height = graphheight;
var psmctx = psmcv.getContext('2d');
var psmchart = new Chart(psmctx, horizBar(filenames, labdsets.psm.percent, labdsets.psm.annot, 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(filenames, labdsets.pep.percent, labdsets.pep.annot, 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(filenames, labdsets.iso.means, labdsets.iso.annot.bar, false, false, labdsets.iso.annot.icon));
</script>
</html>