profilevis.json 9.4 KB
Newer Older
1 2 3
{
  "width": 600,
  "height": 10,
4 5 6 7 8 9 10
  "signals": [
    {
      "name": "filter_threshold",
      "init": 0.5
    },
    {
      "name": "filter_marker",
11 12 13 14 15 16
      "init": ""
    },
    {
      "name": "marker_regex",
      "init": {"expr": "regexp('(?:' + replace(replace(replace(filter_marker, /^ *(.*?) *$/, '$1'), /(^| )=(.*?)(?= |$)/g, '$1^$2$$'), / +/g, ')|(?:') + ')')"},
      "expr": "regexp('(?:' + replace(replace(replace(filter_marker, /^ *(.*?) *$/, '$1'), /(^| )=(.*?)(?= |$)/g, '$1^$2$$'), / +/g, ')|(?:') + ')')"
17 18 19 20 21 22 23 24 25 26 27 28 29 30
    },
    {
      "name": "barwidth",
      "init": 15
    },
    {
      "name": "subgraphoffset",
      "init": 70
    },
    {
      "name": "low",
      "init": 0
    }
  ],
31 32
  "data": [
    {
jhoogenboom's avatar
jhoogenboom committed
33
      "name": "table",
34 35 36 37 38 39 40
      "values": "VALUES HERE",
      "format": {
        "type": "tsv",
        "parse": {
          "fmean": "number",
          "rmean": "number"
        }
jhoogenboom's avatar
jhoogenboom committed
41
      },
42
      "transform": [
jhoogenboom's avatar
jhoogenboom committed
43 44
        {
          "type": "filter",
45
          "test": "datum.allele != datum.sequence && max(datum.fmean, datum.rmean) >= filter_threshold && test(marker_regex, datum.marker)"
46 47 48 49
        },
        {
          "type": "formula",
          "field": "fmean",
50
          "expr": "max(datum.fmean, low)"
51 52 53 54
        },
        {
          "type": "formula",
          "field": "rmean",
55
          "expr": "max(datum.rmean, low)"
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
        },
        {
          "type": "formula",
          "field": "flabel",
          "expr": "indexof(''+round(datum.fmean*10)/10, '.') == -1? ((round(datum.fmean*10)/10) + '.0') : slice((round(datum.fmean*10)/10)+'0', 0, indexof((round(datum.fmean*10)/10) + '.', '.')+2)"
        },
        {
          "type": "formula",
          "field": "rlabel",
          "expr": "indexof(''+round(datum.rmean*10)/10, '.') == -1? ((round(datum.rmean*10)/10) + '.0') : slice((round(datum.rmean*10)/10)+'0', 0, indexof((round(datum.rmean*10)/10) + '.', '.')+2)"
        },
        {
          "type": "formula",
          "field": "name",
          "expr": "datum.marker + ' ' + datum.allele"
        },
        {
          "type": "sort",
          "by": ["name", "sequence"]
Hoogenboom, Jerry's avatar
Hoogenboom, Jerry committed
75 76 77
        },
        {
          "type": "rank"
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
        }
      ]
    },
    {
      "name": "barcounts",
      "source": "table",
      "transform": [
        {
          "type": "aggregate",
          "groupby": ["name"],
          "summarize": {"*": "count"}
        }
      ]
    },
    {
      "name": "subgraphpadding",
      "source": "barcounts",
      "transform": [
        {
          "type": "cross",
98 99
          "diagonal": false,
          "filter": "datum.b.name < datum.a.name"
100 101 102 103
        },
        {
          "type": "formula",
          "field": "name",
jhoogenboom's avatar
jhoogenboom committed
104 105 106 107 108 109
          "expr": "datum.a.name"
        },
        {
          "type": "aggregate",
          "groupby": ["name"],
          "summarize": [{"field": "*", "ops": ["count"], "as": ["cumulpadding"]}]
110 111 112 113 114 115 116 117 118
        }
      ]
    },
    {
      "name": "subgraphoffsets",
      "source": "barcounts",
      "transform": [
        {
          "type": "cross",
119 120
          "with": "table",
          "filter": "datum.b.name < datum.a.name"
121 122 123 124
        },
        {
          "type": "formula",
          "field": "name",
jhoogenboom's avatar
jhoogenboom committed
125 126 127 128 129 130
          "expr": "datum.a.name"
        },
        {
          "type": "aggregate",
          "groupby": ["name"],
          "summarize": [{"field": "*", "ops": ["count"], "as": ["cumulcount"]}]
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
        }
      ]
    },
    {
      "name": "yscale",
      "source": "barcounts",
      "transform": [
        {
          "type": "lookup",
          "on": "subgraphpadding",
          "onKey": "name",
          "keys": ["name"],
          "as": ["paddingobj"],
          "default": {"cumulpadding": 0}
        },
        {
          "type": "lookup",
          "on": "subgraphoffsets",
          "onKey": "name",
          "keys": ["name"],
          "as": ["offsetobj"],
          "default": {"cumulcount": 0}
        },
        {
          "type": "formula",
          "field": "offset",
157
          "expr": "2*barwidth*datum.offsetobj.cumulcount + subgraphoffset*datum.paddingobj.cumulpadding"
158 159 160 161
        },
        {
          "type": "formula",
          "field": "end",
162
          "expr": "datum.offset + 2*barwidth*datum.count"
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
        }
      ]
    }
  ],
  "scales": [
    {
      "name": "c",
      "type": "ordinal",
      "range": ["#5e3c99", "#e66101"],
      "domain": ["Forward reads", "Reverse reads"]
    }
  ],
  "marks": [
    {
      "type": "text",
      "from": {
        "data": "yscale"
      },
      "properties": {
182
        "update": {
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
          "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"]
          },
          {
            "type": "lookup",
            "on": "yscale",
            "onKey": "name",
            "keys": ["name"],
            "as": ["subgraphscale"]
          }
        ]
      },
      "properties": {
212
        "update": {
213 214 215 216 217 218 219 220 221 222 223 224 225
          "x": {"value": 0},
          "width": {"field": {"group": "width"}},
          "y": {"field": "subgraphscale.offset"},
          "y2": {"field": "subgraphscale.end"},
          "stroke": {"value": "#dddddd"}
        }
      },
      "scales": [
        {
          "name": "x",
          "type": "linear",
          "nice": true,
          "range": "width",
226 227
          "domainMin": {"signal": "low"},
          "domainMax": {"data": "table", "field": ["fmean", "rmean"]}
228 229 230 231 232
        },
        {
          "name": "y",
          "type": "ordinal",
          "range": "height",
Hoogenboom, Jerry's avatar
Hoogenboom, Jerry committed
233
          "domain": {"field": "sequence", "sort": {"field": "rank", "op": "min"}}
234 235 236 237 238 239 240 241
        }
      ],
      "axes": [
        {
          "type": "x",
          "scale": "x",
          "grid": true,
          "layer": "back",
242
          "title": "Noise ratio (%)"
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
        },
        {
          "type": "y",
          "scale": "y"
        }
      ],
      "legends": [
        {
          "fill": "c",
          "properties": {
            "symbols": {
              "size": {"value": 100},
              "stroke": {"value": "transparent"},
              "fillOpacity": {"value": 0.8}
            }
          }
        }
      ],
      "marks": [
        {
          "type": "group",
          "from": {
            "transform": [
              {
                "type": "facet",
                "groupby": ["sequence"]
              }
            ]
          },
          "properties": {
273
            "update": {
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
              "x": {"value": 0},
              "y": {"scale": "y", "field": "key", "offset": 1},
              "width": {"field": {"group": "width"}},
              "height": {"scale": "y", "band": true, "offset": -2}
            }
          },
          "scales": [
            {
              "name": "bars",
              "type": "ordinal",
              "range": "height",
              "domain": ["Forward reads", "Reverse reads"]
            },
            {
              "name": "labels",
              "type": "ordinal",
              "range": "height",
              "points": "true",
              "padding": 1,
              "domain": ["Forward reads", "Reverse reads"]
            }
          ],
          "marks": [
            {
              "type": "rect",
              "properties": {
300 301
                "update": {
                  "x": {"scale": "x", "signal": "low"},
302 303 304 305 306 307 308 309 310 311 312
                  "x2": {"scale": "x", "field": "fmean"},
                  "y": {"scale": "bars", "value": "Forward reads"},
                  "height": {"scale": "bars", "band": true},
                  "fill": {"scale": "c", "value": "Forward reads"},
                  "fillOpacity": {"value": 0.8}
                }
              }
            },
            {
              "type": "text",
              "properties": {
313
                "update": {
314 315 316 317 318 319 320 321 322 323 324 325 326
                  "x": {"scale": "x", "field": "fmean", "offset": 5},
                  "y": {"scale": "labels", "value": "Forward reads"},
                  "fontWeight": {"value": "bold"},
                  "text": {"field": "flabel"},
                  "align": {"value": "left"},
                  "baseline": {"value": "middle"},
                  "fill": {"value": "#000000"}
                }
              }
            },
            {
              "type": "rect",
              "properties": {
327 328
                "update": {
                  "x": {"scale": "x", "signal": "low"},
329 330 331 332 333 334 335 336 337 338 339
                  "x2": {"scale": "x", "field": "rmean"},
                  "y": {"scale": "bars", "value": "Reverse reads"},
                  "height": {"scale": "bars", "band": true},
                  "fill": {"scale": "c", "value": "Reverse reads"},
                  "fillOpacity": {"value": 0.8}
                }
              }
            },
            {
              "type": "text",
              "properties": {
340
                "update": {
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
                  "x": {"scale": "x", "field": "rmean", "offset": 5},
                  "y": {"scale": "labels", "value": "Reverse reads"},
                  "fontWeight": {"value": "bold"},
                  "text": {"field": "rlabel"},
                  "align": {"value": "left"},
                  "baseline": {"value": "middle"},
                  "fill": {"value": "#000000"}
                }
              }
            }
          ]
        }
      ]
    }
  ]
}