samplevis.json 10.7 KB
Newer Older
jhoogenboom's avatar
jhoogenboom committed
1
2
3
4
5
{
  "width": 600,
  "height": 10,
  "data": [
    {
jhoogenboom's avatar
jhoogenboom committed
6
      "name": "raw",
jhoogenboom's avatar
jhoogenboom committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
      "values": "sample_data_file_contents_here",
      "format": {
        "type": "tsv",
        "parse": {
          "forward": "number",
          "total": "number",
          "total_noise": "number",
          "total_add": "number"
        }
      },
      "transform": [
        {
          "type": "formula",
          "field": "total_corr",
          "expr": "datum.total_noise? datum.total-datum.total_noise : datum.total"
        },
        {
          "type": "formula",
          "field": "total_add",
          "expr": "datum.total_add? datum.total_corr+datum.total_add : datum.total_corr"
        },
jhoogenboom's avatar
jhoogenboom committed
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
        {
          "type": "formula",
          "field": "amplitude",
          "expr": "max(abs(datum.total), abs(datum.total_add))"
        }
      ]
    },
    {
      "name": "maxima",
      "source": "raw",
      "transform": [
        {
          "type": "aggregate",
          "groupby": ["name"],
          "summarize": {"amplitude": "max"}
        }
      ]
    },
    {
      "name": "table",
      "source": "raw",
      "transform": [
        {
          "type": "lookup",
          "on": "maxima",
          "onKey": "name",
          "keys": ["name"],
          "as": ["aggr"],
          "default": {"max_amplitude": 0}
        },
        {
          "type": "formula",
          "field": "amplitude_threshold",
          "expr": "5"
        },
        {
          "type": "formula",
          "field": "amplitude_pct_threshold",
          "expr": "0.5"
        },
        {
          "type": "formula",
          "field": "amplitude_pct",
          "expr": "datum.aggr.max_amplitude? (datum.amplitude/datum.aggr.max_amplitude*100) : 100"
        },
jhoogenboom's avatar
jhoogenboom committed
73
74
        {
          "type": "filter",
jhoogenboom's avatar
jhoogenboom committed
75
          "test": "datum.amplitude > datum.amplitude_threshold && datum.amplitude_pct > datum.amplitude_pct_threshold"
jhoogenboom's avatar
jhoogenboom committed
76
        },
77
78
79
80
81
82
83
84
85
        {
          "type": "formula",
          "field": "filter_marker",
          "expr": "'.*'"
        },
        {
          "type": "filter",
          "test": "test('^' + datum.filter_marker + '$', datum.name)"
        },
jhoogenboom's avatar
jhoogenboom committed
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
        {
          "type": "formula",
          "field": "shared",
          "expr": "max(0, datum.total_corr)"
        },
        {
          "type": "formula",
          "field": "corr_shared",
          "expr": "min(datum.total, datum.total_add)"
        },
        {
          "type": "formula",
          "field": "corr_decreased",
          "expr": "max(datum.total, datum.corr_shared)"
        },
        {
          "type": "formula",
          "field": "corr_increased",
          "expr": "max(datum.corr_shared, datum.total_add)"
        },
        {
          "type": "formula",
          "field": "forwardpct",
          "expr": "100.0 / datum.total * datum.forward"
        },
        {
          "type": "sort",
          "by": ["name", "allele", "-total_add", "-total_corr", "-total"]
        }
      ]
    },
    {
118
      "name": "barcounts",
jhoogenboom's avatar
jhoogenboom committed
119
120
121
122
123
124
125
126
127
128
      "source": "table",
      "transform": [
        {
          "type": "aggregate",
          "groupby": ["name"],
          "summarize": {"*": "count"}
        }
      ]
    },
    {
129
130
      "name": "subgraphpadding",
      "source": "barcounts",
jhoogenboom's avatar
jhoogenboom committed
131
132
133
      "transform": [
        {
          "type": "cross",
134
          "with": "barcounts"
jhoogenboom's avatar
jhoogenboom committed
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
        },
        {
          "type": "filter",
          "test": "datum.b.name < datum.a.name"
        },
        {
          "type": "aggregate",
          "groupby": ["a.name"],
          "summarize": [{"field": "*", "ops": ["count"], "as": ["cumulpadding"]}]
        },
        {
          "type": "formula",
          "field": "name",
          "expr": "datum['a.name']"
        }
      ]
    },
    {
153
154
      "name": "subgraphoffsets",
      "source": "barcounts",
jhoogenboom's avatar
jhoogenboom committed
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
      "transform": [
        {
          "type": "cross",
          "with": "table"
        },
        {
          "type": "filter",
          "test": "datum.b.name < datum.a.name"
        },
        {
          "type": "aggregate",
          "groupby": ["a.name"],
          "summarize": [{"field": "*", "ops": ["count"], "as": ["cumulcount"]}]
        },
        {
          "type": "formula",
          "field": "name",
          "expr": "datum['a.name']"
        }
      ]
    },
    {
      "name": "yscale",
178
      "source": "barcounts",
jhoogenboom's avatar
jhoogenboom committed
179
180
      "transform": [
        {
jhoogenboom's avatar
jhoogenboom committed
181
          "type": "lookup",
182
          "on": "subgraphpadding",
jhoogenboom's avatar
jhoogenboom committed
183
184
185
          "onKey": "name",
          "keys": ["name"],
          "as": ["paddingobj"],
jhoogenboom's avatar
jhoogenboom committed
186
187
188
          "default": {"cumulpadding": 0}
        },
        {
jhoogenboom's avatar
jhoogenboom committed
189
          "type": "lookup",
190
          "on": "subgraphoffsets",
jhoogenboom's avatar
jhoogenboom committed
191
192
193
          "onKey": "name",
          "keys": ["name"],
          "as": ["offsetobj"],
jhoogenboom's avatar
jhoogenboom committed
194
195
196
197
          "default": {"cumulcount": 0}
        },
        {
          "type": "formula",
jhoogenboom's avatar
jhoogenboom committed
198
          "field": "barwidth",
jhoogenboom's avatar
jhoogenboom committed
199
200
201
202
          "expr": "15"
        },
        {
          "type": "formula",
203
          "field": "subgraphoffset",
jhoogenboom's avatar
jhoogenboom committed
204
205
206
207
208
          "expr": "70"
        },
        {
          "type": "formula",
          "field": "offset",
209
          "expr": "datum.barwidth*datum.offsetobj.cumulcount + datum.subgraphoffset*datum.paddingobj.cumulpadding"
jhoogenboom's avatar
jhoogenboom committed
210
211
212
213
        },
        {
          "type": "formula",
          "field": "end",
jhoogenboom's avatar
jhoogenboom committed
214
          "expr": "datum.offset + datum.barwidth*datum.count"
jhoogenboom's avatar
jhoogenboom committed
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
        }
      ]
    }
  ],
  "scales": [
    {
      "name": "c",
      "type": "ordinal",
      "range": ["#5e3c99", "#b2abd2", "#fdb863", "#e66101"],
      "domain": ["Shared base", "Correction removed", "Correction shared", "Correction added"]
    }
  ],
  "marks": [
    {
      "type": "text",
      "from": {
        "data": "yscale"
      },
      "properties": {
        "enter": {
          "x": {"field": {"group": "width"}, "mult": 0.5},
          "y": {"field": "offset"},
          "fontWeight": {"value": "bold"},
          "text": {"field": "name"},
          "align": {"value": "center"},
          "baseline": {"value": "bottom"},
          "fill": {"value": "black"}
        }
      }
    },
    {
      "type": "group",
      "from": {
        "data": "table",
        "transform": [
          {
            "type": "facet",
            "groupby": ["name"]
          },
          {
jhoogenboom's avatar
jhoogenboom committed
255
256
257
258
            "type": "lookup",
            "on": "yscale",
            "onKey": "name",
            "keys": ["name"],
259
            "as": ["subgraphscale"]
jhoogenboom's avatar
jhoogenboom committed
260
261
262
263
264
265
266
          }
        ]
      },
      "properties": {
        "enter": {
          "x": {"value": 0},
          "width": {"field": {"group": "width"}},
267
268
          "y": {"field": "subgraphscale.offset"},
          "y2": {"field": "subgraphscale.end"},
jhoogenboom's avatar
jhoogenboom committed
269
270
271
272
273
274
          "stroke": {"value": "#dddddd"}
        }
      },
      "scales": [
        {
          "name": "x",
275
          "type": "linear",
jhoogenboom's avatar
jhoogenboom committed
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
          "range": "width",
          "domain": {"field": ["total", "total_corr", "total_add"]}
        },
        {
          "name": "y",
          "type": "ordinal",
          "range": "height",
          "domain": {"field": "allele"}
        }
      ],
      "axes": [
        {
          "type": "x",
          "scale": "x",
          "grid": true,
          "layer": "back",
          "title": "Number of reads",
          "properties": {
            "labels": {
              "align": {"value": "right"},
              "baseline": {"value": "middle"},
              "dy": {"value": 3},
              "angle": {"value": -25}
            },
            "title": {
              "dy": {"value": 5}
            }
          }
        },
        {
          "type": "y",
          "scale": "y"
        }
      ],
      "legends": [
        {
          "fill": "c",
          "properties": {
            "symbols": {
              "size": {"value": 100},
              "stroke": {"value": "transparent"},
              "fillOpacity": {"value": 0.8}
            }
          }
        }
      ],
      "marks": [
        {
          "type": "rect",
          "properties": {
            "enter": {
              "x": {"scale": "x", "value": 0},
              "x2": {"scale": "x", "field": "shared"},
              "y": {"scale": "y", "field": "allele", "offset": 1},
              "height": {"scale": "y", "band": true, "offset": -2},
              "fill": {"scale": "c", "value": "Shared base"},
              "fillOpacity": {"value": 0.8}
            }
          }
        },
        {
          "type": "rect",
          "properties": {
            "enter": {
              "x": {"scale": "x", "field": "corr_shared"},
              "x2": {"scale": "x", "field": "corr_decreased"},
              "y": {"scale": "y", "field": "allele", "offset": 1},
              "height": {"scale": "y", "band": true, "offset": -2},
              "fill": {"scale": "c", "value": "Correction removed"},
              "fillOpacity": {"value": 0.8}
            }
          }
        },
        {
          "type": "rect",
          "properties": {
            "enter": {
              "x": {"scale": "x", "field": "total_corr"},
              "x2": {"scale": "x", "field": "corr_shared"},
              "y": {"scale": "y", "field": "allele", "offset": 1},
              "height": {"scale": "y", "band": true, "offset": -2},
              "fill": {"scale": "c", "value": "Correction shared"},
              "fillOpacity": {"value": 0.8}
            }
          }
        },
        {
          "type": "rect",
          "properties": {
            "enter": {
              "x": {"scale": "x", "field": "corr_shared"},
              "x2": {"scale": "x", "field": "corr_increased"},
              "y": {"scale": "y", "field": "allele", "offset": 1},
              "height": {"scale": "y", "band": true, "offset": -2},
              "fill": {"scale": "c", "value": "Correction added"},
              "fillOpacity": {"value": 0.8}
            }
          }
        },
        {
          "type": "group",
          "from": {
            "transform": [{"type": "facet", "groupby": ["allele"]}]
          },
          "properties": {
            "enter": {
              "x": {"value": 0},
              "width": {"field": {"group": "width"}},
              "y": {"scale": "y", "field": "key", "offset": 1},
              "height": {"scale": "y", "band": true, "offset": -2}
            }
          },
          "scales": [
            {
              "name": "balance",
              "range": "height",
              "nice": false,
              "domain": [0, 100]
            }
          ],
          "marks": [
            {
              "type": "rect",
              "properties": {
                "enter": {
                  "x": {"scale": "x", "value": 0},
                  "x2": {"scale": "x", "field": "total"},
                  "y": {"scale": "balance", "field": "forwardpct", "offset": -0.5},
                  "y2": {"scale": "balance", "field": "forwardpct", "offset": 0.5},
                  "fill": {"value": "black"}
                }
              }
            }
          ]
        }
      ]
    }
  ]
}