omicsplayground
omicsplayground copied to clipboard
cytoplot not working
I have a dataset (~900 cells, 8000 genes) of scRNAseq that is loaded in and working pretty decently. However, the cytoplot graph is throwing an error. Looking at the logs I get:
Warning: Error in kde2d: bandwidths must be strictly positive
187: stop
186: kde2d
185: pgx.cytoPlot
184: <reactive>
182: .func
179: contextFunc
178: env$runWith
171: ctx$run
170: self$.updateValue
168: func
167: renderPlot
165: func
125: drawPlot
111: <reactive:plotObj>
95: drawReactive
82: origRenderFunc
81: output$scell-sc_cytoplot-renderfigure
1: runApp
I tried something suggested here: https://stackoverflow.com/questions/53075331/error-using-geom-density-2d-in-r-computation-failed-in-stat-density2d-b and replaced the following code:
z1 <- kde2d( x1[j1], x2[j1], n=50)
z2 <- kde2d( x1[j2], x2[j2], n=50)
z3 <- kde2d( x1[j3], x2[j3], n=50)
z4 <- kde2d( x1[j4], x2[j4], n=50)
with
z1 <- kde2d( x1[j1], x2[j1], n=50, h = c(ifelse(bandwidth.nrd(x1[j1]) == 0, 0.1, bandwidth.nrd(x1[j1])), ifelse(bandwidth.nrd(x2[j1]) == 0, 0.1, bandwidth.nrd(x2[j1]))))
z2 <- kde2d( x1[j2], x2[j2], n=50, h = c(ifelse(bandwidth.nrd(x1[j2]) == 0, 0.1, bandwidth.nrd(x1[j2])), ifelse(bandwidth.nrd(x2[j2]) == 0, 0.1, bandwidth.nrd(x2[j2]))))
z3 <- kde2d( x1[j3], x2[j3], n=50, h = c(ifelse(bandwidth.nrd(x1[j3]) == 0, 0.1, bandwidth.nrd(x1[j3])), ifelse(bandwidth.nrd(x2[j3]) == 0, 0.1, bandwidth.nrd(x2[j3]))))
z4 <- kde2d( x1[j4], x2[j4], n=50, h = c(ifelse(bandwidth.nrd(x1[j4]) == 0, 0.1, bandwidth.nrd(x1[j4])), ifelse(bandwidth.nrd(x2[j4]) == 0, 0.1, bandwidth.nrd(x2[j4]))))
to pre-compute the bandwidth value. That somewhat worked (some genes would plot), but gave a new error on the genes that didn't work (that I know are expressed in the dataset):
Warning: Error in contour.default: increasing 'x' and 'y' values expected
188: stop
187: contour.default
185: pgx.cytoPlot
184: <reactive>
182: .func
179: contextFunc
178: env$runWith
171: ctx$run
170: self$.updateValue
168: func
167: renderPlot
165: func
125: drawPlot
111: <reactive:plotObj>
95: drawReactive
82: origRenderFunc
81: output$scell-sc_cytoplot-renderfigure
1: runApp
Thoughts on what might be going on, or what else to try?