Skip to content

Commit 28c6a9f

Browse files
committed
Gosling GFF viz
1 parent 0828282 commit 28c6a9f

File tree

1 file changed

+81
-89
lines changed

1 file changed

+81
-89
lines changed

src/components/Result/GoslingViz.js

Lines changed: 81 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function GoslingGenomeViz({ dataKey, showPlot, filter }) {
3333
}
3434
const spec = {
3535
"arrangement": "vertical",
36+
"spacing": 50,
3637
"views": getViews(data["data"])
3738
};
3839
console.log(spec);
@@ -47,68 +48,102 @@ function GoslingGenomeViz({ dataKey, showPlot, filter }) {
4748

4849

4950
const createGeneTrack = (data) => {
50-
const GeneTrackcreator = (data, strand) => {
51-
return {
52-
"data": {
53-
"values": data,
54-
"type": "json",
55-
"genomicFields": ["start", "end"]
56-
},
51+
52+
return [{
53+
"alignment": "overlay",
54+
"data": {
55+
"values": data,
56+
"type": "json",
57+
"genomicFields": ["start", "end"]
58+
},
59+
"row": { "field": "strand", "type": "nominal", "domain": ["+", "-"] },
60+
"mark": "rect",
61+
"x": { "field": "start", "type": "genomic", "axis": "none" },
62+
"xe": { "field": "end", "type": "genomic", "axis": "none" },
63+
"color": { "value": "grey" },
64+
"opacity": { "value": 0.4 },
65+
"size": { "value": 4 },
66+
"tracks": [{
67+
68+
"dataTransform": [
69+
{ "type": "filter", "field": "strand", "oneOf": "+" }
70+
],
71+
}, {
72+
5773
"dataTransform": [
58-
{ "type": "filter", "field": "strand", "oneOf": [strand] }
74+
{ "type": "filter", "field": "strand", "oneOf": "-" }
5975
],
60-
"mark": "rect",
61-
"row": { "field": "strand", "type": "nominal", "domain": ["+", "-"] },
62-
"x": { "field": "start", "type": "genomic", "axis": "top" },
63-
"xe": { "field": "end", "type": "genomic", "axis": "top" },
64-
"color": { "value": "grey" },
65-
"style": { "opacity": 0.2 },
66-
"size": { "value": 5 }
6776
}
68-
}
77+
]
78+
}]
6979

70-
return [GeneTrackcreator(data, "+"), GeneTrackcreator(data, "-")]
7180

7281
}
7382

74-
const createTSSTrack = (data) => {
75-
const TSSTrackcreator = (data, strand) => {
76-
return {
83+
const createTSSTrack = (data, strand, title = null) => {
84+
return [
85+
{
86+
"title": title,
87+
"alignment": "overlay",
7788
"data": {
7889
"values": data.filter(d => filter.includes(d["typeTSS"])),
7990
"type": "json",
80-
"genomicFields": ["superPos"]
91+
"genomicFields": ["superPos"],
8192
},
82-
"row": { "field": "superStrand", "type": "nominal", "domain": ["+", "-"] },
83-
"dataTransform": [
84-
{ "type": "filter", "field": "superStrand", "oneOf": strand }
85-
],
86-
"mark": strand === "+" ? "triangleRight" : "triangleLeft",
87-
"x": { "field": "superPos", "type": "genomic", "axis": "top" },
93+
// "row": { "field": "superStrand", "type": "nominal", "domain": ["+", "-"] },
94+
// "mark": "point",
95+
// "x": { "field": "superPos", "type": "genomic", "axis": "top" },
96+
8897
"color": {
8998
"field": "mainClass",
9099
"type": "nominal",
91100

92101
"domain": ["Primary", "Secondary", "Internal", "Antisense", "Orphan"],
93102
"range": ["#7585FF", "#FF8A85", "#FFC785", "#85FFD9", "#B285FF"],
94-
"legend": true
103+
"legend": strand === "+"
104+
},
105+
"tracks": [{
106+
"dataTransform": [
107+
{ "type": "filter", "field": "superStrand", "oneOf": [strand] }
108+
],
109+
"x": { "field": "superPos", "type": "genomic", "axis": strand === "+" ? "top" : "none" },
110+
"mark": strand === "+" ? "triangleRight" : "triangleLeft",
111+
"style": { "align": strand === "+" ? "left" : "right" },
112+
"size": { "value": 15 },
95113
},
96-
"style": { "align": strand === "+" ? "right" : "left" },
97-
"size": { "value": 15 }
114+
{
115+
"data": {
116+
"values": data.filter(d => filter.includes(d["typeTSS"])),
117+
"type": "json",
118+
"genomicFields": ["superPos"],
119+
"binSize": 10,
120+
},
121+
"dataTransform": [
122+
{ "type": "filter", "field": "superStrand", "oneOf": [strand] }
123+
],
124+
"x": { "field": "superPos", "type": "genomic", "aggregate": "bin", "axis": "none" },
125+
"xe": { "field": "superPos", "type": "genomic" },
126+
// "size": { "value": 10 },
127+
"y": {
128+
"field": "mainClass", "type": "nominal", "axis": "none",
129+
"domain": ["Primary", "Secondary", "Internal", "Antisense", "Orphan"],
130+
"range": [50, 50, 50, 50, 50],
131+
"aggregate": "count"
132+
133+
},
134+
"mark": "bar",
135+
// "y": { "type": "quantitative", "axis": "none" },
136+
}]
98137
}
99-
}
100-
101-
return [
102-
TSSTrackcreator(data, "-"),
103-
TSSTrackcreator(data, "+")
104138

105139
]
106140
}
107141

108-
const createTracks = (data) => {
142+
const createTracks = (data, title) => {
109143
let geneTracks = createGeneTrack(data["superGFF"]);
110-
let TSSTracks = createTSSTrack(data["TSS"]);
111-
return geneTracks.concat(TSSTracks);
144+
let TSSTracks_plus = createTSSTrack(data["TSS"], "+", title);
145+
let TSSTracks_minus = createTSSTrack(data["TSS"], "-");
146+
return TSSTracks_plus.concat(geneTracks).concat(TSSTracks_minus);
112147

113148
}
114149

@@ -117,67 +152,24 @@ function GoslingGenomeViz({ dataKey, showPlot, filter }) {
117152
console.log(data);
118153
for (let genome of Object.keys(data)) {
119154
views.push({
120-
"alignment": "overlay",
155+
"alignment": "stack",
121156
"title": genome,
122157
"assembly": [["", data[genome]["maxValue"]]],
123-
124-
"tracks": createTracks(data[genome])
158+
"spacing": 0,
159+
"layout": "linear",
160+
"tracks": createTracks(data[genome], genome,)
125161
})
126162
}
127163
return views;
128164

129165
}
130166

131-
return <div className={showPlot ? '' : 'hidden'}>
132-
{spec && <GoslingComponent spec={spec} />}
133-
</div>;
167+
return spec && <GoslingComponent spec={spec} />
168+
169+
134170

135171
}
136172

137-
// "alignment": "overlay",
138-
// "title": "Position of TSSs",
139-
// "assembly": [["", 250000]],
140-
// "data": {
141-
// "values": data,
142-
// "type": "json",
143-
// "genomicFields": ["pos"]
144-
// },
145-
// "row": { "field": "strand", "type": "nominal", "domain": ["+", "-"] },
146-
// "color": {
147-
// "field": "mainClass",
148-
// "type": "nominal",
149-
// "domain": ["primary", "secondary", "internal", "antisense", "orphan"],
150-
// "range": ["#7585FF", "#FF8A85", "#FFC785", "#85FFD9", "#B285FF"],
151-
// "legend": true
152-
// },
153-
// "visibility": [
154-
// {
155-
// "operation": "less-than",
156-
// "measure": "width",
157-
// "threshold": "|xe-x|",
158-
// "transitionPadding": 10,
159-
// "target": "mark"
160-
// }
161-
// ],
162-
// "opacity": { "value": 0.8 },
163-
// "width": 350,
164-
// "height": 100,
165-
// "tracks": [
166-
// ,
167-
// {
168-
// "dataTransform": [
169-
// { "type": "filter", "field": "strand", "oneOf": ["-"] }
170-
// ],
171-
// "mark": "triangleLeft",
172-
// "x": { "field": "pos", "type": "genomic" },
173-
// "size": { "value": 15 },
174-
// "style": { "align": "right" }
175-
176-
// }
177-
// ]
178-
// }
179-
180-
181-
// }
173+
182174

183175
export default GoslingGenomeViz

0 commit comments

Comments
 (0)