allelevis.json 3.63 KB
Newer Older
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
{
  "width": 500,
  "height": 500,
  "data": [
    {
      "name": "raw",
      "values": "VALUES HERE",
      "format": {
        "type": "tsv"
      },
      "transform": [
        {
          "type": "formula",
          "field": "samplemarker",
          "expr": "datum.sample + datum.marker"
        },
        {
          "type": "formula",
          "field": "markerallele",
          "expr": "datum.marker + datum.allele"
        },
        {
          "type": "formula",
          "field": "samplemarkerallele",
          "expr": "datum.samplemarker + datum.allele"
        }
      ]
    },
    {
      "name": "homozygotes",
      "source": "raw",
      "transform": [
        {
          "type": "aggregate",
          "groupby": ["samplemarker"],
          "summarize": {"allele": "distinct"}
        },
        {
          "type": "filter",
          "test": "datum.distinct_allele == 1"
        },
        {
          "type": "lookup",
          "on": "raw",
          "onKey": "samplemarker",
          "keys": ["samplemarker"],
          "as": ["alleleobj"]
        },
        {
          "type": "formula",
          "field": "markerallele",
          "expr": "datum.alleleobj.markerallele"
        },
        {
          "type": "aggregate",
          "groupby": ["markerallele"],
          "summarize": {"*": "count"}
        }
      ]
    },
    {
      "name": "nodes",
      "source": "raw",
      "transform": [
        {
          "type": "aggregate",
          "groupby": ["marker", "allele"],
          "summarize": {"*": "count"}
        },
        {
          "type": "formula",
          "field": "markerallele",
          "expr": "datum.marker + datum.allele"
        },
        {
          "type": "lookup",
          "on": "homozygotes",
          "onKey": "markerallele",
          "keys": ["markerallele"],
          "as": ["homcountobj"],
          "default": {"count": 0}
        },
        {
          "type": "formula",
          "field": "homCount",
          "expr": "datum.homcountobj.count"
        }
      ]
    },
    {
      "name": "edges",
      "source": "nodes",
      "transform": [
        {
          "type": "cross",
          "with": "raw",
          "output": {"left": "source", "right": "samples"}
        },
        {
          "type": "filter",
          "test": "datum.source.markerallele == datum.samples.markerallele"
        },
        {
          "type": "cross",
          "with": "nodes",
          "output": {"left": "a", "right": "target"}
        },
        {
          "type": "filter",
          "test": "datum.a.source.marker == datum.target.marker && datum.a.source.allele < datum.target.allele"
        },
        {
          "type": "formula",
          "field": "samplemarkerallele",
          "expr": "datum.a.samples.sample + datum.target.marker + datum.target.allele"
        },
        {
          "type": "lookup",
          "on": "raw",
          "onKey": "samplemarkerallele",
          "keys": ["samplemarkerallele"],
          "as": ["targetsample"],
          "default": {"sample": "NOTFOUND"}
        },
        {
          "type": "filter",
          "test": "datum.targetsample.sample != 'NOTFOUND'"
        },
        {
          "type": "formula",
          "field": "source",
          "expr": "datum.a.source._id"
        },
        {
          "type": "formula",
          "field": "target",
          "expr": "datum.target._id"
        },
        {
          "type": "formula",
          "field": "sampletag",
          "expr": "datum.targetsample.sample"
        },
        {
          "type": "aggregate",
          "groupby": ["source", "target"],
          "summarize": {"*": "count"}
        }
      ]
    }
  ]
}