Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
486 lines (445 loc) · 18.6 KB
/
Copy pathindex.html
File metadata and controls
486 lines (445 loc) · 18.6 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DANDI Archive Summary</title>
<link rel="icon" type="image/x-icon" href="https://raw.githubusercontent.com/dandi/dandi-archive/master/web/public/favicon.ico">
<script src="https://cdn.plot.ly/plotly-2.35.2.min.js"></script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-QLDZD3SJ3Y"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-QLDZD3SJ3Y');
</script>
<style>
body {
font-family: sans-serif;
background: #fff;
margin: 24px 32px;
color: #222;
}
h1 {
font-size: 22px;
font-weight: 600;
margin-bottom: 12px;
color: #1a1a1a;
}
main {
max-width: 1300px;
margin: 0 auto;
}
#plot { width: 100%; }
</style>
</head>
<body>
<header style="border-bottom: 1px solid #000; padding: 10px 32px; margin: -24px -32px 24px; display: flex; align-items: center;">
<a href="https://dandiarchive.org/" target="_blank" rel="noopener">
<img src="https://raw.githubusercontent.com/dandi/dandi-archive/master/web/src/assets/logo.svg" alt="DANDI Archive" style="height: 40px; display: block;">
</a>
</header>
<main>
<h1 id="page-title">DANDI Archive Summary</h1>
<div id="plot"></div>
</main>
<script>
const csvFiles = [
'./timeseries.csv',
'./sizes.csv',
'./subjects.csv',
'./species.csv',
'./modalities.csv',
];
// Image for plot A (inlined as a data URL so it is kept in SVG/PNG downloads)
const toDataURL = url => fetch(url)
.then(r => r.blob())
.then(blob => new Promise(resolve => {
const reader = new FileReader();
reader.onload = () => resolve(reader.result);
reader.readAsDataURL(blob);
}));
const panelAReady = toDataURL('img/panel-a.svg');
Promise.all(csvFiles.map(f => fetch(f)))
.then(responses => {
const lastMod = responses[0].headers.get('Last-Modified');
if (lastMod) {
const d = new Date(lastMod);
if (!isNaN(d)) {
const months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
const label = `${months[d.getUTCMonth()]} ${d.getUTCDate()}, ${d.getUTCFullYear()}`;
const title = `DANDI Archive Summary (${label})`;
document.getElementById('page-title').textContent = title;
document.title = title;
}
}
return Promise.all([...responses.map(r => r.text()), panelAReady]);
})
.then(([tsText, sizesText, subjectsText, speciesText, modalitiesText, panelASource]) => {
// ---- parse CSV ----
function parseCSV(text) {
const lines = text.trim().split('\n');
const headers = lines[0].split(',').map(h => h.trim());
return lines.slice(1).map(line => {
const vals = line.split(',');
const obj = {};
headers.forEach((h, i) => { obj[h] = (vals[i] || '').trim(); });
return obj;
});
}
const OPEN_COLOR = '#0072B2';
const EMB_COLOR = '#E69F00';
const OPEN_FILL = 'rgba(0,114,178,0.40)';
const EMB_FILL = 'rgba(230,159,0,0.40)';
// ---- helpers ----
function buildHistogram(rows) {
const byBin = new Map();
rows.forEach(r => {
const left = parseFloat(r.bin_left);
const right = parseFloat(r.bin_right);
const count = parseInt(r.count, 10) || 0;
if (!byBin.has(left)) byBin.set(left, { center: (left + right) / 2, width: right - left, open: 0, emb: 0 });
const bin = byBin.get(left);
if (r.access === 'OPEN') bin.open += count;
else if (r.access === 'EMBARGOED') bin.emb += count;
});
const sorted = [...byBin.entries()].sort(([a], [b]) => a - b).map(([, v]) => v);
return {
centers: sorted.map(b => b.center),
widths: sorted.map(b => b.width),
open: sorted.map(b => b.open),
emb: sorted.map(b => b.emb),
};
}
function buildAccessCounts(rows, keyCol) {
const open = {}, emb = {};
rows.forEach(r => {
const k = r[keyCol];
if (!k || k === 'nan') return;
const count = parseInt(r.count, 10) || 0;
if (r.access === 'OPEN') open[k] = (open[k] || 0) + count;
else if (r.access === 'EMBARGOED') emb[k] = (emb[k] || 0) + count;
});
return { open, emb };
}
// ---- shared axis styling ----
const axBase = {
showline: true, linecolor: '#000000', linewidth: 0.8,
ticks: 'outside', ticklen: 4, tickwidth: 0.8, tickcolor: '#000000',
showgrid: false, zeroline: false, mirror: false,
tickfont: { size: 13 },
};
const yBase = {
...axBase,
showgrid: true,
gridcolor: '#E6E6E6', gridwidth: 0.5, griddash: 'solid',
};
// ---- Plot B & C: build cumulative series from the monthly time series ----
const tsRows = parseCSV(tsText);
const periods = [...new Set(tsRows.map(r => r.period))].sort();
const byPeriod = {};
periods.forEach(p => { byPeriod[p] = { OPEN: { n: 0, size: 0 }, EMBARGOED: { n: 0, size: 0 } }; });
tsRows.forEach(r => {
byPeriod[r.period][r.access] = {
n: parseFloat(r.number_added) || 0,
size: parseFloat(r.size_added) || 0,
};
});
const allDates = periods.map(p => p + '-01');
const lineStyle = { width: 1.5, shape: 'linear' };
const lastDate = allDates[allDates.length - 1];
const cumOpenCount = [], cumEmbCount = [], cumTotalCount = [];
const cumOpenSize = [], cumEmbSize = [], cumTotalSize = [];
let openN = 0, embN = 0, openS = 0, embS = 0;
periods.forEach(p => {
openN += byPeriod[p].OPEN.n;
embN += byPeriod[p].EMBARGOED.n;
openS += byPeriod[p].OPEN.size / 1e15;
embS += byPeriod[p].EMBARGOED.size / 1e15;
cumOpenCount.push(openN);
cumEmbCount.push(embN);
cumTotalCount.push(openN + embN);
cumOpenSize.push(openS);
cumEmbSize.push(embS);
cumTotalSize.push(openS + embS);
});
// ---- Plot B: cumulative datasets (open on bottom, embargoed stacked on top) ----
const traceB_open = { type:'scatter', mode:'lines', name:'Open access', x: allDates, y: cumOpenCount, line: { ...lineStyle, color: OPEN_COLOR }, fill: 'tozeroy', fillcolor: OPEN_FILL, xaxis:'x', yaxis:'y', showlegend:true, legend:'legend', hovertemplate:'%{x|%b %Y}: %{y}<extra></extra>' };
const traceB_emb = { type:'scatter', mode:'lines', name:'Embargoed access', x: allDates, y: cumTotalCount, line: { ...lineStyle, color: EMB_COLOR }, fill: 'tonexty', fillcolor: EMB_FILL, xaxis:'x', yaxis:'y', showlegend:true, legend:'legend', customdata: cumEmbCount, hovertemplate:'%{x|%b %Y}: %{customdata}<extra></extra>' };
const traceC_open = { type:'scatter', mode:'lines', name:'Open access', x: allDates, y: cumOpenSize, line: { ...lineStyle, color: OPEN_COLOR }, fill: 'tozeroy', fillcolor: OPEN_FILL, xaxis:'x2', yaxis:'y2', showlegend:true, legend:'legend2', hovertemplate:'%{x|%b %Y}: %{y:.2f}<extra></extra>' };
const traceC_emb = { type:'scatter', mode:'lines', name:'Embargoed access', x: allDates, y: cumTotalSize, line: { ...lineStyle, color: EMB_COLOR }, fill: 'tonexty', fillcolor: EMB_FILL, xaxis:'x2', yaxis:'y2', showlegend:true, legend:'legend2', customdata: cumEmbSize, hovertemplate:'%{x|%b %Y}: %{customdata:.2f}<extra></extra>' };
// ---- Plot D: size distribution ----
const sizeHist = buildHistogram(parseCSV(sizesText));
const HIST_BAR_FRACTION = 0.80;
const sizeBarWidths = sizeHist.widths.map(w => w * HIST_BAR_FRACTION);
// open on bottom, embargoed stacked on top (manual stack via `base` so the
// global barmode can be 'group' for plots F and G)
const sizeBarOffsets = sizeBarWidths.map(w => -w / 2);
const traceD_open = { type:'bar', name:'Open access', x: sizeHist.centers, y: sizeHist.open, width: sizeBarWidths, offset: sizeBarOffsets, marker:{ color: OPEN_COLOR }, xaxis:'x3', yaxis:'y3', showlegend:true, legend:'legend3', hovertemplate:'%{y}<extra></extra>' };
const traceD_emb = { type:'bar', name:'Embargoed access', x: sizeHist.centers, y: sizeHist.emb, base: sizeHist.open, width: sizeBarWidths, offset: sizeBarOffsets, marker:{ color: EMB_COLOR }, xaxis:'x3', yaxis:'y3', showlegend:true, legend:'legend3', hovertemplate:'%{y}<extra></extra>' };
// ---- Plot E: subjects distribution ----
const subjHist = buildHistogram(parseCSV(subjectsText));
const subjBarWidths = subjHist.widths.map(w => w * HIST_BAR_FRACTION);
const subjBarOffsets = subjBarWidths.map(w => -w / 2);
const traceE_open = { type:'bar', name:'Open access', x: subjHist.centers, y: subjHist.open, width: subjBarWidths, offset: subjBarOffsets, marker:{ color: OPEN_COLOR }, xaxis:'x4', yaxis:'y4', showlegend:true, legend:'legend4', hovertemplate:'%{y}<extra></extra>' };
const traceE_emb = { type:'bar', name:'Embargoed access', x: subjHist.centers, y: subjHist.emb, base: subjHist.open, width: subjBarWidths, offset: subjBarOffsets, marker:{ color: EMB_COLOR }, xaxis:'x4', yaxis:'y4', showlegend:true, legend:'legend4', hovertemplate:'%{y}<extra></extra>' };
// Shared y-axis range for D and E
const cdDtick = 50;
const cdRawMax = Math.max(
...sizeHist.centers.map((_, i) => sizeHist.open[i] + sizeHist.emb[i]),
...subjHist.centers.map((_, i) => subjHist.open[i] + subjHist.emb[i]),
);
const cdMax = Math.ceil(cdRawMax / cdDtick) * cdDtick;
// ---- Plot F: species bar chart ----
const { open: openSp, emb: embSp } = buildAccessCounts(parseCSV(speciesText), 'species');
const allSp = new Set([...Object.keys(openSp), ...Object.keys(embSp)]);
const spTotals = {};
allSp.forEach(s => { spTotals[s] = (openSp[s]||0) + (embSp[s]||0); });
// Group species with fewer than MIN_SPECIES_COUNT datasets into "Other"
const MIN_SPECIES_COUNT = 5;
const spMain = [...allSp].filter(s => spTotals[s] >= MIN_SPECIES_COUNT);
const spOther = [...allSp].filter(s => spTotals[s] < MIN_SPECIES_COUNT);
const spSorted = spMain.sort((a, b) => spTotals[b] - spTotals[a]);
if (spOther.length > 0) {
openSp['Other'] = spOther.reduce((s, k) => s + (openSp[k]||0), 0);
embSp['Other'] = spOther.reduce((s, k) => s + (embSp[k]||0), 0);
spTotals['Other'] = openSp['Other'] + embSp['Other'];
spSorted.push('Other');
}
// horizontal grouped bars; categories reversed so the largest is at the top
const spPlot = [...spSorted].reverse();
const traceF_emb = {
type: 'bar', orientation: 'h', name: 'Embargoed access',
y: spPlot, x: spPlot.map(s => embSp[s]||0),
marker: { color: EMB_COLOR },
xaxis: 'x5', yaxis: 'y5', showlegend: true, legend: 'legend5',
hovertemplate: '%{x}<extra></extra>',
};
const traceF_open = {
type: 'bar', orientation: 'h', name: 'Open access',
y: spPlot, x: spPlot.map(s => openSp[s]||0),
marker: { color: OPEN_COLOR },
xaxis: 'x5', yaxis: 'y5', showlegend: true, legend: 'legend5',
hovertemplate: '%{x}<extra></extra>',
};
// ---- Plot G: modality bar chart ----
const modalityNames = {
extracellularephys: 'Extracellular<br>ephys',
intracellularephys: 'Intracellular<br>ephys',
opticalphysiology: 'Optical<br>physiology',
behavior: 'Behavior',
eyetracking: 'Eye tracking',
optogenetics: 'Optogenetics',
fiberphotometry: 'Fiber<br>photometry',
microscopy: 'Microscopy',
};
const modKeys = Object.keys(modalityNames);
const { open: openMod, emb: embMod } = buildAccessCounts(parseCSV(modalitiesText), 'modality');
modKeys.forEach(m => {
openMod[m] = openMod[m] || 0;
embMod[m] = embMod[m] || 0;
});
const modTotal = {};
modKeys.forEach(m => { modTotal[m] = (openMod[m]||0) + (embMod[m]||0); });
const modSorted = [...modKeys].sort((a, b) => modTotal[b] - modTotal[a]);
const modPlot = [...modSorted].reverse();
const modPlotLabels = modPlot.map(m => modalityNames[m]);
const traceG_emb = {
type: 'bar', orientation: 'h', name: 'Embargoed access',
y: modPlotLabels, x: modPlot.map(m => embMod[m]||0),
marker: { color: EMB_COLOR },
xaxis: 'x6', yaxis: 'y6', showlegend: true, legend: 'legend6',
hovertemplate: '%{x}<extra></extra>',
};
const traceG_open = {
type: 'bar', orientation: 'h', name: 'Open access',
y: modPlotLabels, x: modPlot.map(m => openMod[m]||0),
marker: { color: OPEN_COLOR },
xaxis: 'x6', yaxis: 'y6', showlegend: true, legend: 'legend6',
hovertemplate: '%{x}<extra></extra>',
};
// Shared y-axis range for F and G
const spMax = Math.max(...spSorted.map(s => (openSp[s]||0) + (embSp[s]||0)));
const modMax = Math.max(...modSorted.map(m => modTotal[m]));
const efRawMax = Math.max(spMax, modMax);
const efDtick = 100;
const efMax = Math.ceil(efRawMax / efDtick) * efDtick;
// ---- Plot A: data sources ----
const panelAImage = {
source: panelASource,
xref: 'paper', yref: 'paper',
x: -0.04, y: 1.0,
sizex: 1.04, sizey: 0.2,
xanchor: 'left', yanchor: 'top',
sizing: 'contain', layer: 'above',
};
// ---- layout ----
const layout = {
barmode: 'group',
bargap: 0.3,
paper_bgcolor: '#fff',
plot_bgcolor: '#fff',
font: { family: 'sans-serif', size: 12, color: '#000000' },
height: 1600,
margin: { t: 50, b: 80, l: 100, r: 20 },
images: [panelAImage],
// per-subplot legends (embargoed listed above open, matching the stacks)
legend: { x: 0.01, y: 0.742, xanchor: 'left', yanchor: 'top', traceorder: 'reversed', font: { size: 13 } },
legend2: { x: 0.59, y: 0.742, xanchor: 'left', yanchor: 'top', traceorder: 'reversed', font: { size: 13 } },
legend3: { x: 0.44, y: 0.466, xanchor: 'right', yanchor: 'top', traceorder: 'reversed', font: { size: 13 } },
legend4: { x: 1.00, y: 0.466, xanchor: 'right', yanchor: 'top', traceorder: 'reversed', font: { size: 13 } },
legend5: { x: 0.44, y: 0.01, xanchor: 'right', yanchor: 'bottom', traceorder: 'reversed', font: { size: 13 } },
legend6: { x: 1.00, y: 0.01, xanchor: 'right', yanchor: 'bottom', traceorder: 'reversed', font: { size: 13 } },
annotations: [
{ text: '<b>A</b>', xref:'paper', yref:'paper', x:-0.05, y:1.03, showarrow:false, font:{size:20} },
{ text: '<b>B</b>', xref:'paper', yref:'paper', x:-0.05, y:0.772, showarrow:false, font:{size:20} },
{ text: '<b>C</b>', xref:'paper', yref:'paper', x:0.53, y:0.772, showarrow:false, font:{size:20} },
{ text: '<b>D</b>', xref:'paper', yref:'paper', x:-0.05, y:0.496, showarrow:false, font:{size:20} },
{ text: '<b>E</b>', xref:'paper', yref:'paper', x:0.53, y:0.496, showarrow:false, font:{size:20} },
{ text: '<b>F</b>', xref:'paper', yref:'paper', x:-0.05, y:0.22, showarrow:false, font:{size:20} },
{ text: '<b>G</b>', xref:'paper', yref:'paper', x:0.53, y:0.22, showarrow:false, font:{size:20} },
],
// B - cumulative datasets
xaxis: {
...axBase,
domain: [0.0, 0.44], anchor: 'y',
type: 'date',
tick0: '2020-01-01', dtick: 'M12', tickformat: '%Y',
range: ['2020-01-01', lastDate],
title: { text: 'Date', font: { size: 16 } },
},
yaxis: {
...yBase,
domain: [0.552, 0.742], anchor: 'x',
rangemode: 'tozero',
title: { text: 'Datasets (#)', font: { size: 16 } },
},
// C - cumulative size
xaxis2: {
...axBase,
domain: [0.58, 1.0], anchor: 'y2',
type: 'date',
tick0: '2020-01-01', dtick: 'M12', tickformat: '%Y',
range: ['2020-01-01', lastDate],
title: { text: 'Date', font: { size: 16 } },
},
yaxis2: {
...yBase,
domain: [0.552, 0.742], anchor: 'x2',
rangemode: 'tozero',
title: { text: 'Size (PB)', font: { size: 16 } },
},
// D - size distribution
xaxis3: {
...axBase,
domain: [0.0, 0.44], anchor: 'y3',
tickmode: 'array',
tickvals: [3, 6, 9, 12, 15],
ticktext: ['KB', 'MB', 'GB', 'TB', 'PB'],
range: [2, 16],
title: { text: 'Dataset size', font: { size: 16 } },
},
yaxis3: {
...yBase,
domain: [0.276, 0.466], anchor: 'x3',
title: { text: 'Datasets (#)', font: { size: 16 } },
range: [0, cdMax], dtick: cdDtick,
},
// E - subjects distribution
xaxis4: {
...axBase,
domain: [0.58, 1.0], anchor: 'y4',
tickmode: 'array',
tickvals: [0, 1, 2, 3],
ticktext: ['1', '10', '100', '1000'],
range: [0, 4],
title: { text: 'Number of subjects', font: { size: 16 } },
},
yaxis4: {
...yBase,
domain: [0.276, 0.466], anchor: 'x4',
title: { text: 'Datasets (#)', font: { size: 16 } },
range: [0, cdMax], dtick: cdDtick,
},
// F - species (horizontal bars)
xaxis5: {
...yBase,
domain: [0.0, 0.44], anchor: 'y5',
title: { text: 'Datasets (#)', font: { size: 16 } },
range: [0, efMax], dtick: efDtick,
},
yaxis5: {
...axBase,
domain: [0.0, 0.19], anchor: 'x5',
},
// G - modality (horizontal bars)
xaxis6: {
...yBase,
domain: [0.58, 1.0], anchor: 'y6',
title: { text: 'Datasets (#)', font: { size: 16 } },
range: [0, efMax], dtick: efDtick,
},
yaxis6: {
...axBase,
domain: [0.0, 0.19], anchor: 'x6',
},
};
const traces = [
traceB_open, traceB_emb,
traceC_open, traceC_emb,
traceD_open, traceD_emb,
traceE_open, traceE_emb,
traceF_emb, traceF_open,
traceG_emb, traceG_open,
];
const downloadIcon = {
width: 500,
height: 500,
path: 'M250,370 L80,210 L170,210 L170,60 L330,60 L330,210 L420,210 Z M60,420 L440,420 L440,470 L60,470 Z',
};
Plotly.newPlot('plot', traces, layout, {
responsive: true,
displayModeBar: true,
modeBarButtonsToRemove: ['toImage'],
modeBarButtonsToAdd: [
{
name: 'Download SVG',
icon: downloadIcon,
click: gd => Plotly.downloadImage(gd, { format: 'svg', filename: 'dandi_archive_summary' }),
},
{
name: 'Download PNG',
icon: Plotly.Icons.camera,
click: gd => Plotly.downloadImage(gd, { format: 'png', filename: 'dandi_archive_summary' }),
},
],
}).then(gd => {
// The embargoed traces in B-E are drawn stacked on top of the open traces,
// so when 'Open access' is toggled off via the legend they would float at
// their stacked height. Re-anchor them to the x-axis whenever that happens.
const stackSync = [
{ open: traces.indexOf(traceB_open), emb: traces.indexOf(traceB_emb), attr: 'y', shown: cumTotalCount, hidden: cumEmbCount },
{ open: traces.indexOf(traceC_open), emb: traces.indexOf(traceC_emb), attr: 'y', shown: cumTotalSize, hidden: cumEmbSize },
{ open: traces.indexOf(traceD_open), emb: traces.indexOf(traceD_emb), attr: 'base', shown: sizeHist.open, hidden: 0 },
{ open: traces.indexOf(traceE_open), emb: traces.indexOf(traceE_emb), attr: 'base', shown: subjHist.open, hidden: 0 },
];
let syncing = false;
gd.on('plotly_restyle', () => {
if (syncing) return;
const updates = [];
stackSync.forEach(p => {
const v = gd.data[p.open].visible;
const openVisible = v === undefined || v === true;
const want = openVisible ? p.shown : p.hidden;
if (gd.data[p.emb][p.attr] !== want) updates.push([{ [p.attr]: [want] }, [p.emb]]);
});
if (!updates.length) return;
syncing = true;
Promise.all(updates.map(([u, t]) => Plotly.restyle(gd, u, t))).then(() => { syncing = false; });
});
});
}); // end fetch .then
</script>
</body>
</html>