@@ -22,6 +22,11 @@ InteractionQC = {
22
22
type : "section" ,
23
23
collapsed : true ,
24
24
} ,
25
+ _uns_postfix : {
26
+ label : "For HDF5 files, postfix of the uns key containing the matrix:" ,
27
+ type : "text" ,
28
+ default : "/uns/{obs}_nhood_enrichment/zscore" ,
29
+ } ,
25
30
} ,
26
31
_matrix : null ,
27
32
_matrix_header : null ,
@@ -53,7 +58,7 @@ InteractionQC.init = function (container) {
53
58
kind : "label" ,
54
59
extraAttributes : { for : "matrix" } ,
55
60
} ) ;
56
- label412 . innerText = "Select file" ;
61
+ label412 . innerText = "For CSV file, select it on disk: " ;
57
62
58
63
input411 . addEventListener ( "change" , ( event ) => {
59
64
var reader = new FileReader ( ) ;
@@ -136,12 +141,16 @@ InteractionQC.loadFromH5AD = async function () {
136
141
data_obj = dataUtils . data [ _dataset ] ;
137
142
if ( ! data_obj . _filetype == "h5" ) return ;
138
143
try {
139
- let obs = data_obj . _gb_col . replace ( / \/ o b s / g, "" ) ;
144
+ let obs = data_obj . _gb_col . replace ( / \/ o b s / g, "" ) . replace ( / \/ / g, "" ) ;
145
+ InteractionQC . _className = obs ;
140
146
let matrix = await dataUtils . _hdf5Api . get ( data_obj . _csv_path , {
141
- path : "/uns/" + obs + "_nhood_enrichment/zscore" ,
147
+ path : InteractionQC . get ( "_uns_postfix" ) . replace ( "{ obs}" , obs ) ,
142
148
} ) ;
143
149
console . log ( matrix ) ;
144
- let _matrix_header = Object . keys ( data_obj . _groupgarden ) ;
150
+ let _matrix_header = await dataUtils . _hdf5Api . get ( data_obj . _csv_path , {
151
+ path : "/obs/" + obs + "/categories" ,
152
+ } ) ;
153
+ _matrix_header = _matrix_header . value ;
145
154
// convert matrix from 1D typed array of shape NxN to array of arrays
146
155
147
156
InteractionQC . _matrix = [ ] ;
@@ -173,6 +182,8 @@ InteractionQC.run = async function () {
173
182
let _matrix_header = InteractionQC . _matrix_header ;
174
183
if ( ! InteractionQC . _matrix_header ) {
175
184
_matrix_header = await InteractionQC . loadFromH5AD ( ) ;
185
+ } else {
186
+ InteractionQC . _className = "Cell classes" ;
176
187
}
177
188
var op = tmapp [ "object_prefix" ] ;
178
189
@@ -197,18 +208,19 @@ InteractionQC.run = async function () {
197
208
tickvals : _matrix_header ,
198
209
ticktext : _matrix_header . map ( function ( text ) {
199
210
let color = document . getElementById (
200
- _dataset + "_" + text + "_color" ,
211
+ _dataset + "_" + text . replace ( / / g , "_" ) + "_color" ,
201
212
) ?. value ;
202
- return "<span style='font-weight:bold;color:" + color + "'>███ </span>" ;
213
+ return "<span style='font-weight:bold;color:" + color + "'>█</span>" ;
203
214
} ) ,
204
215
ticks : "" ,
205
- tickangle : 90 ,
216
+ tickangle : 0 ,
206
217
title : {
207
- text : "Cell class 2" ,
218
+ text : InteractionQC . _className ,
208
219
font : {
209
- size : 25 ,
220
+ size : 20 ,
210
221
color : "black" ,
211
222
} ,
223
+ standoff : 20 ,
212
224
} ,
213
225
} ,
214
226
xaxis : {
@@ -219,20 +231,19 @@ InteractionQC.run = async function () {
219
231
. reverse ( )
220
232
. map ( function ( text ) {
221
233
let color = document . getElementById (
222
- _dataset + "_" + text + "_color" ,
234
+ _dataset + "_" + text . replace ( / / g , "_" ) + "_color" ,
223
235
) ?. value ;
224
- return (
225
- "<span style='font-weight:bold;color:" + color + "'>███</span>"
226
- ) ;
236
+ return "<span style='font-weight:bold;color:" + color + "'>█</span>" ;
227
237
} ) ,
228
238
ticks : "" ,
229
- tickangle : 0 ,
239
+ tickangle : 90 ,
230
240
title : {
231
- text : "Cell class 1" ,
241
+ text : InteractionQC . _className ,
232
242
font : {
233
- size : 25 ,
243
+ size : 20 ,
234
244
color : "black" ,
235
245
} ,
246
+ standoff : 5 ,
236
247
} ,
237
248
ticklabelposition : "top" ,
238
249
side : "top" ,
@@ -254,7 +265,7 @@ InteractionQC.run = async function () {
254
265
let legend = "" ;
255
266
for ( type of _matrix_header ) {
256
267
let typecolor = document . getElementById (
257
- _dataset + "_" + type + "_color" ,
268
+ _dataset + "_" + type . replace ( / / g , "_" ) + "_color" ,
258
269
) ?. value ;
259
270
legend +=
260
271
"<div style='display:inline-block;margin-right:10px;'><span style='width:15px;color:" +
@@ -285,6 +296,13 @@ InteractionQC.run = async function () {
285
296
data.points[i].y.toPrecision(4) + '\n\n';
286
297
}
287
298
alert('Closest point clicked:\n\n'+pts);*/
299
+ } )
300
+ . on ( "plotly_doubleclick" , function ( ) {
301
+ setTimeout ( function ( ) {
302
+ var uid = _dataset ;
303
+ document . getElementById ( uid + "_all_check" ) . checked = false ;
304
+ document . getElementById ( uid + "_all_check" ) . click ( ) ;
305
+ } , 200 ) ;
288
306
} ) ;
289
307
} ;
290
308
0 commit comments