@@ -33,6 +33,7 @@ function UpSet({ showUpSet, allGenomes, filterForPlots, tableColumns, tableData,
33
33
const [ plotSettings , setPlotSettings ] = useState ( {
34
34
classUpsetPlot : "tssClass" ,
35
35
type : "all" ,
36
+ countType : "position"
36
37
} ) ;
37
38
38
39
const handleClassUpsetPlotChange = ( value ) => {
@@ -41,6 +42,10 @@ function UpSet({ showUpSet, allGenomes, filterForPlots, tableColumns, tableData,
41
42
42
43
const handleTypeChange = ( value ) => {
43
44
setPlotSettings ( ( prev ) => ( { ...prev , type : value } ) ) ;
45
+ } ;
46
+
47
+ const handleCountTSS = ( value ) => {
48
+ setPlotSettings ( ( prev ) => ( { ...prev , countType : value } ) ) ;
44
49
} ;
45
50
46
51
@@ -71,7 +76,7 @@ function UpSet({ showUpSet, allGenomes, filterForPlots, tableColumns, tableData,
71
76
* for upset plot: count frequncy of each tss class
72
77
* and get all genome/condition names
73
78
*/
74
- const TSSperPosition = ( rows , columns , typeIntersection = "all" ) => {
79
+ const TSSperPosition = ( rows , columns ) => {
75
80
// get column indices
76
81
const primaryIdx = columns . findIndex ( ( col ) => col [ "header" ] === "Primary" ) ;
77
82
const secondaryIdx = columns . findIndex ( ( col ) => col [ "header" ] === "Secondary" ) ;
@@ -84,10 +89,8 @@ function UpSet({ showUpSet, allGenomes, filterForPlots, tableColumns, tableData,
84
89
85
90
86
91
// save frequency of classes for a TSS (upset plot)
87
- let tssByClass = { } ;
88
92
let tssWithMultipleClasses = { } ;
89
93
// For the condition
90
- let tssByCondition = { } ;
91
94
let tssWithMultipleConditions = { } ;
92
95
93
96
rows . forEach ( ( row ) => {
@@ -119,16 +122,6 @@ function UpSet({ showUpSet, allGenomes, filterForPlots, tableColumns, tableData,
119
122
tssWithMultipleConditions [ tmpTuple ] [ tmpClass ] = [ genomeName ]
120
123
}
121
124
122
- if ( genomeName in tssByCondition ) {
123
- if ( ! tssByCondition [ genomeName ] . includes ( tmpTuple ) ) {
124
- tssByCondition [ genomeName ] . push ( tmpTuple ) ;
125
- } else if ( typeIntersection === "dedup" ) {
126
- return ; // Exit the current iteration of the loop
127
- }
128
- } else {
129
- tssByCondition [ genomeName ] = [ tmpTuple ] ;
130
- }
131
-
132
125
// add tss to tssWithMultipleClasses
133
126
if ( tmpTuple in tssWithMultipleClasses ) {
134
127
// Add once to set
@@ -147,19 +140,6 @@ function UpSet({ showUpSet, allGenomes, filterForPlots, tableColumns, tableData,
147
140
tssWithMultipleClasses [ tmpTuple ] [ genomeName ] = [ tmpClass ]
148
141
}
149
142
150
-
151
-
152
- // add tss to tssByClass
153
- if ( tmpClass in tssByClass ) {
154
- if ( ! tssByClass [ tmpClass ] . includes ( tmpTuple ) ) {
155
- tssByClass [ tmpClass ] . push ( tmpTuple ) ;
156
- } else if ( typeIntersection === "dedup" ) {
157
- return ; // Exit the current iteration of the loop
158
- }
159
- } else {
160
- tssByClass [ tmpClass ] = [ tmpTuple ] ;
161
- }
162
-
163
143
}
164
144
} ) ;
165
145
if ( plotSettings . classUpsetPlot === "tssClass" ) {
@@ -175,9 +155,6 @@ function UpSet({ showUpSet, allGenomes, filterForPlots, tableColumns, tableData,
175
155
// create new plots
176
156
processedData = TSSperPosition ( tableData , tableColumns ) ;
177
157
}
178
- else if ( selectedDataToShow === "dedup" ) {
179
- processedData = TSSperPosition ( tableData , tableColumns , selectedDataToShow ) ;
180
- }
181
158
else {
182
159
const genomeIdx = tableColumns . findIndex (
183
160
( col ) => col [ "header" ] === "Genome" || col [ "header" ] === "Condition"
@@ -212,7 +189,7 @@ function UpSet({ showUpSet, allGenomes, filterForPlots, tableColumns, tableData,
212
189
color_tss [ x ] = COLORS_TSS [ i ]
213
190
} )
214
191
let elems ;
215
- if ( plotSettings . type === "all " ) {
192
+ if ( plotSettings . countType === "classification " ) {
216
193
elems = Object . entries ( processedData ) . reduce ( ( accum , curr ) => {
217
194
let tssName = curr [ 0 ]
218
195
let mapGenomes = Object . entries ( curr [ 1 ] ) . filter ( x => x [ 0 ] !== "set" ) . map ( ( other ) => {
@@ -240,7 +217,7 @@ function UpSet({ showUpSet, allGenomes, filterForPlots, tableColumns, tableData,
240
217
}
241
218
else {
242
219
filteredSet = sets . filter ( x => ! ORDER_TSS_CLASSES . includes ( x . name ) )
243
- if ( ! [ "all" , "dedup" ] . includes ( plotSettings . type ) ) {
220
+ if ( plotSettings . type !== "all" ) {
244
221
filteredSet . forEach ( x => x . color = color_tss [ plotSettings . type ] )
245
222
}
246
223
@@ -268,21 +245,26 @@ function UpSet({ showUpSet, allGenomes, filterForPlots, tableColumns, tableData,
268
245
width : "100%"
269
246
} } className = { showUpSet ? '' : 'hidden' } >
270
247
< div className = "upset-settings" >
248
+ < SingleSelectDropdown
249
+ label = "Categories to Analyze"
250
+ value = { plotSettings . classUpsetPlot }
251
+ onChange = { ( value ) => handleClassUpsetPlotChange ( value ) }
252
+ options = { [
253
+ { value : "tssClass" , label : "TSS classes" } ,
254
+ { value : "conditions" , label : "Conditions/Genomes" } ,
255
+ ] }
256
+ helpText = { `This option defines the axes of the UpSet plot.` }
257
+
258
+ />
259
+
271
260
< SingleSelectDropdown
272
261
label = "Show UpSet Plot for"
273
262
value = { plotSettings . type }
274
263
onChange = { ( value ) => handleTypeChange ( value ) }
275
264
options = { [
276
265
{
277
266
value : "all" ,
278
- label : `Union of all TSS across ${ plotSettings . classUpsetPlot === "tssClass"
279
- ? "Conditions/Genomes"
280
- : "TSS classes"
281
- } `,
282
- } ,
283
- {
284
- value : "dedup" ,
285
- label : `Intersection of all TSS across ${ plotSettings . classUpsetPlot === "tssClass"
267
+ label : `All ${ plotSettings . classUpsetPlot === "tssClass"
286
268
? "Conditions/Genomes"
287
269
: "TSS classes"
288
270
} `,
@@ -292,17 +274,33 @@ function UpSet({ showUpSet, allGenomes, filterForPlots, tableColumns, tableData,
292
274
: [ ...ORDER_TSS_CLASSES ]
293
275
) . map ( ( col ) => ( { value : col , label : col } ) ) ,
294
276
] }
277
+ helpText = { `Either show data for all ${ plotSettings . classUpsetPlot === "tssClass" ? "Conditions/Genomes" : "TSS classes" } or for specific ones` }
295
278
/>
296
279
< SingleSelectDropdown
297
- label = "Categories to Analyze"
298
- value = { plotSettings . classUpsetPlot }
299
- onChange = { ( value ) => handleClassUpsetPlotChange ( value ) }
280
+ label = { `A TSSs is defined by its` }
281
+ value = { plotSettings . countType }
282
+ onChange = { ( value ) => handleCountTSS ( value ) }
283
+ helpText = { `A TSS can be associated with multiple ${ plotSettings . classUpsetPlot === "tssClass"
284
+ ? "Conditions/Genomes"
285
+ : "TSS classes"
286
+ } . However, the genomic position is the same. This option defines how to count the TSSs, either as unique genomic positions or account also for the classification.
287
+ Please consider that for the case that a TSS is classified twice as internal or antisense, it will only be counted once.` }
288
+
300
289
options = { [
301
- { value : "tssClass" , label : "TSS classes" } ,
302
- { value : "conditions" , label : "Conditions/Genomes" } ,
290
+ {
291
+ value : "position" ,
292
+ label : `Location` ,
293
+ } ,
294
+ {
295
+ value : "classification" ,
296
+ label : `Location and ${ plotSettings . classUpsetPlot === "tssClass"
297
+ ? "Conditions/Genomes"
298
+ : "TSS classes"
299
+ } `,
300
+ }
303
301
] }
304
302
/>
305
-
303
+
306
304
307
305
</ div >
308
306
0 commit comments