Skip to content

Commit cb5da1a

Browse files
committed
Working version with aggregation of TSSs
1 parent 5a8b858 commit cb5da1a

File tree

4 files changed

+71
-92
lines changed

4 files changed

+71
-92
lines changed

server_tsspredator/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,6 @@ def aggregateTSS(tssList, maxGenome):
381381
@app.route('/api/TSSViewer/<filePath>/')
382382
def getTSSViewer(filePath):
383383
'''send result of TSS prediction to frontend'''
384-
print(filePath)
385384
# get path of zip file
386385
completePath = tempfile.gettempdir().replace('\\', '/') + '/' + filePath + '/result.zip'
387386
if os.path.exists(completePath):
@@ -401,7 +400,6 @@ def getTSSViewer(filePath):
401400
masterTable[genomeKey]['superGFF'], maxValue = parseSuperGFF(superGFFPath)
402401
masterTable[genomeKey]['maxValue'] = maxValue
403402
masterTable[genomeKey]['aggregatedTSS'] = aggregateTSS(masterTable[genomeKey]['TSS'], maxValue)
404-
print(masterTable[genomeKey]['aggregatedTSS'])
405403

406404
return jsonify({'result': 'success', 'data': masterTable})
407405
except Exception as e:
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dbfilename dump-tsspredator.rdb
2+
dir /data
3+
save 43200 1 300 100 60 10000

src/components/Result/GoslingViz.js

Lines changed: 68 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function GoslingGenomeViz({ dataKey, showPlot, filter }) {
3434
const spec = {
3535
"arrangement": "vertical",
3636
"spacing": 50,
37+
"linkingId": "detail",
3738
"views": getViews(data["data"])
3839
};
3940
setSpec(spec);
@@ -90,8 +91,60 @@ function GoslingGenomeViz({ dataKey, showPlot, filter }) {
9091
}
9192

9293
const createTSSTrack = (data, aggregatedTSS, strand, title = null) => {
93-
console.log(aggregatedTSS);
94-
console.log(data);
94+
let binnedViews = [
95+
{ "GT": 50000, "LT": 200000, "size": 5000 },
96+
{ "GT": 200000, "LT": 500000, "size": 10000 },
97+
{ "GT": 500000, "LT": NaN, "size": 50000 }].map(({ GT, LT, size }) => {
98+
let transitionPadding = 20000;
99+
return {
100+
"data": {
101+
"values": aggregatedTSS[size].filter(d => filter.includes(d["typeTSS"])),
102+
"type": "json",
103+
"genomicFields": ["binStart", "binEnd"],
104+
},
105+
"dataTransform": [
106+
{ "type": "filter", "field": "strand", "oneOf": [strand] }
107+
],
108+
"x": { "field": "binStart", "type": "genomic", "axis": strand === "+" ? "top" : "none", },
109+
"xe": { "field": "binEnd", "type": "genomic", },
110+
"mark": "bar",
111+
"y": { "field": "count", "type": "quantitative", axis: "left" },
112+
"color": {
113+
"field": "mainClass",
114+
"type": "nominal",
115+
"domain": ["Primary", "Secondary", "Internal", "Antisense", "Orphan"],
116+
"range": ["#7585FF", "#FF8A85", "#FFC785", "#85FFD9", "#B285FF"],
117+
"legend": strand === "+"
118+
},
119+
"tooltip": [
120+
{ "field": "binStart", "type": "genomic", "alt": "Bin start" },
121+
{ "field": "binEnd", "alt": "Bin end" },
122+
{
123+
"field": "mainClass",
124+
"type": "nominal",
125+
"alt": "Main TSS class",
126+
},
127+
{ "field": "count", "alt": "Number of TSS" },
128+
],
129+
"visibility": [
130+
{
131+
"operation": "GT",
132+
"measure": "zoomLevel",
133+
"threshold": GT,
134+
"transitionPadding": transitionPadding,
135+
"target": "track"
136+
},
137+
!isNaN(LT) &&
138+
{
139+
"operation": "LT",
140+
"measure": "zoomLevel",
141+
"threshold": LT + 7500,
142+
"transitionPadding": transitionPadding,
143+
"target": "track"
144+
}
145+
]
146+
}
147+
});
95148
return [
96149
{
97150
"title": title,
@@ -102,13 +155,7 @@ function GoslingGenomeViz({ dataKey, showPlot, filter }) {
102155
"genomicFields": ["superPos"],
103156
},
104157

105-
"color": {
106-
"field": "mainClass",
107-
"type": "nominal",
108-
"domain": ["Primary", "Secondary", "Internal", "Antisense", "Orphan"],
109-
"range": ["#7585FF", "#FF8A85", "#FFC785", "#85FFD9", "#B285FF"],
110-
"legend": strand === "+"
111-
},
158+
112159
"tracks": [
113160
{
114161

@@ -118,7 +165,14 @@ function GoslingGenomeViz({ dataKey, showPlot, filter }) {
118165
"x": { "field": "superPos", "type": "genomic", "axis": strand === "+" ? "top" : "none" },
119166
"mark": strand === "+" ? "triangleRight" : "triangleLeft",
120167
"style": { "align": strand === "+" ? "left" : "right" },
121-
"size": { "value": 15 },
168+
"size": { "value": 10, "legend": false, axis: "none" },
169+
"color": {
170+
"field": "mainClass",
171+
"type": "nominal",
172+
"domain": ["Primary", "Secondary", "Internal", "Antisense", "Orphan"],
173+
"range": ["#7585FF", "#FF8A85", "#FFC785", "#85FFD9", "#B285FF"],
174+
"legend": strand === "+"
175+
},
122176
"tooltip": [
123177
{ "field": "superPos", "type": "genomic", "alt": "TSS Position" },
124178
{
@@ -132,87 +186,12 @@ function GoslingGenomeViz({ dataKey, showPlot, filter }) {
132186
{
133187
"operation": "LT",
134188
"measure": "zoomLevel",
135-
"threshold": 50000,
136-
"transitionPadding": 500,
137-
"target": "mark"
189+
"threshold": 57500,
190+
"transitionPadding": 0,
191+
"target": "track"
138192
}
139193
]
140-
}, ...[
141-
{ "GT": 50000, "LT": 200000, "size": 5000 },
142-
{ "GT": 200000, "LT": 500000, "size": 10000 },
143-
{ "GT": 500000, "LT": null, "size": 50000 }].map(({ GT, LT, size }) => {
144-
console.log(GT, LT, size);
145-
return {
146-
"data": {
147-
"values": aggregatedTSS[size].filter(d => filter.includes(d["typeTSS"])),
148-
"type": "json",
149-
"genomicFields": ["binStart", "binEnd"],
150-
},
151-
"dataTransform": [
152-
{ "type": "filter", "field": "strand", "oneOf": [strand] }
153-
],
154-
"x": { "field": "binStart", "type": "genomic", "axis": strand === "+" ? "top" : "none", },
155-
"xe": { "field": "binEnd", "type": "genomic", },
156-
"mark": "bar",
157-
"y": { "field": "count", "type": "quantitative" },
158-
"color": {
159-
"field": "mainClass",
160-
"type": "nominal",
161-
"domain": ["Primary", "Secondary", "Internal", "Antisense", "Orphan"],
162-
"range": ["#7585FF", "#FF8A85", "#FFC785", "#85FFD9", "#B285FF"],
163-
"legend": false
164-
},
165-
"tooltip": [
166-
{ "field": "binStart", "type": "genomic", "alt": "Bin start" },
167-
{
168-
"field": "mainClass",
169-
"type": "nominal",
170-
"alt": "Main TSS class",
171-
},
172-
{ "field": "count", "alt": "Number of TSS" },
173-
{ "field": "binEnd", "alt": "Bin end" },
174-
],
175-
"visibility": [
176-
{
177-
"operation": "GT",
178-
"measure": "zoomLevel",
179-
"threshold": GT,
180-
"transitionPadding": 10,
181-
"target": "mark"
182-
},
183-
{
184-
"operation": "LT",
185-
"measure": "zoomLevel",
186-
"threshold": LT,
187-
"transitionPadding": 10,
188-
"target": "mark"
189-
}
190-
]
191-
}
192-
})
193-
194-
,
195-
// {
196-
// "data": {
197-
// "values": [{ "test": 1, "binStart": 12, "binEnd": 412 }],
198-
// "type": "json",
199-
// // "genomicFields": ["binStart", "binEnd"],
200-
201-
// },
202-
// // "dataTransform": [
203-
// // { "type": "filter", "field": "strand", "oneOf": [strand] }
204-
// // ],
205-
// // "x": { "field": "binStart", "type": "genomic", "axis": "none" },
206-
// // "size": { "value": 1 },
207-
// // "color": {
208-
// // "field": "typeTSS",
209-
// // "type": "nominal",
210-
// // "domain": ["Primary", "Secondary", "Internal", "Antisense", "Orphan"],
211-
// // "range": ["#7585FF", "#FF8A85", "#FFC785", "#85FFD9", "#B285FF"],
212-
// // "legend": false
213-
// // },
214-
// "mark": "bar",
215-
// }
194+
}, ...binnedViews
216195
]
217196
}
218197

@@ -228,7 +207,6 @@ function GoslingGenomeViz({ dataKey, showPlot, filter }) {
228207

229208
const getViews = (data) => {
230209
let views = [];
231-
console.log(data);
232210
for (let genome of Object.keys(data)) {
233211
views.push({
234212
"alignment": "stack",

0 commit comments

Comments
 (0)