... | ... |
@@ -6,6 +6,7 @@ CHANGES in VERSION 1.99.5 |
6 | 6 |
* `HeatmapAnnotation()`: fixed a bug for setting `height` when all annotations are simple annotations. |
7 | 7 |
* `default_col()`: if the fraction of positive values in the matrix is in (0.3, 0.7), the color mapping |
8 | 8 |
is symmetric to zero. |
9 |
+* check `NA` values in `anno_boxplot()` and `anno_density()`. |
|
9 | 10 |
|
10 | 11 |
======================== |
11 | 12 |
|
... | ... |
@@ -1352,9 +1352,11 @@ anno_boxplot = function(x, which = c("column", "row"), border = TRUE, |
1352 | 1352 |
if(outline) { |
1353 | 1353 |
for(i in seq_along(value)) { |
1354 | 1354 |
l1 = value[[i]] > boxplot_stats[5,i] |
1355 |
+ l1[is.na(l1)] = FALSE |
|
1355 | 1356 |
if(sum(l1)) grid.points(y = rep(n - i + 1, sum(l1)), x = value[[i]][l1], |
1356 | 1357 |
default.units = "native", gp = subset_gp(gp, i), pch = pch[i], size = size[i]) |
1357 | 1358 |
l2 = value[[i]] < boxplot_stats[1,i] |
1359 |
+ l2[is.na(l2)] = FALSE |
|
1358 | 1360 |
if(sum(l2)) grid.points(y = rep(n - i + 1, sum(l2)), x = value[[i]][l2], |
1359 | 1361 |
default.units = "native", gp = subset_gp(gp, i), pch = pch[i], size = size[i]) |
1360 | 1362 |
} |
... | ... |
@@ -1399,9 +1401,11 @@ anno_boxplot = function(x, which = c("column", "row"), border = TRUE, |
1399 | 1401 |
if(outline) { |
1400 | 1402 |
for(i in seq_along(value)) { |
1401 | 1403 |
l1 = value[[i]] > boxplot_stats[5,i] |
1404 |
+ l1[is.na(l1)] = FALSE |
|
1402 | 1405 |
if(sum(l1)) grid.points(x = rep(i, sum(l1)), y = value[[i]][l1], |
1403 | 1406 |
default.units = "native", gp = subset_gp(gp, i), pch = pch[i], size = size[i]) |
1404 | 1407 |
l2 = value[[i]] < boxplot_stats[1,i] |
1408 |
+ l2[is.na(l2)] = FALSE |
|
1405 | 1409 |
if(sum(l2)) grid.points(x = rep(i, sum(l2)), y = value[[i]][l2], |
1406 | 1410 |
default.units = "native", gp = subset_gp(gp, i), pch = pch[i], size = size[i]) |
1407 | 1411 |
} |
... | ... |
@@ -1679,7 +1683,7 @@ anno_density = function(x, which = c("column", "row"), |
1679 | 1683 |
type = match.arg(type)[1] |
1680 | 1684 |
|
1681 | 1685 |
n_all = length(value) |
1682 |
- density_stats = lapply(value, density) |
|
1686 |
+ density_stats = lapply(value, density, na.rm = TRUE) |
|
1683 | 1687 |
density_x = lapply(density_stats, function(x) x$x) |
1684 | 1688 |
density_y = lapply(density_stats, function(x) x$y) |
1685 | 1689 |
|
... | ... |
@@ -119,6 +119,10 @@ anno = anno_points(1:10, gp = gpar(col = rep(2:3, each = 5)), pch = rep(2:3, eac |
119 | 119 |
draw(anno, test = "anno_points") |
120 | 120 |
draw(anno, index = c(1, 3, 5, 7, 9, 2, 4, 6, 8, 10), test = "anno_points") |
121 | 121 |
|
122 |
+anno = anno_points(c(1:5, NA, 7:10)) |
|
123 |
+draw(anno, test = "anno_points") |
|
124 |
+ |
|
125 |
+ |
|
122 | 126 |
##### test anno_lines ### |
123 | 127 |
anno = anno_lines(runif(10)) |
124 | 128 |
draw(anno, test = "anno_lines") |
... | ... |
@@ -139,6 +143,8 @@ anno = anno_lines(cbind(sort(rnorm(10)), sort(rnorm(10), decreasing = TRUE)), |
139 | 143 |
width = unit(2, "cm"), smooth = TRUE, add_points = TRUE, gp = gpar(col = 2:3), which = "row") |
140 | 144 |
draw(anno, test = "anno_lines, smooth, matrix, by row") |
141 | 145 |
|
146 |
+anno = anno_lines(c(1:5, NA, 7:10)) |
|
147 |
+draw(anno, test = "anno_lines") |
|
142 | 148 |
|
143 | 149 |
|
144 | 150 |
###### test anno_text ####### |
... | ... |
@@ -190,6 +196,8 @@ draw(anno, test = "proportion matrix") |
190 | 196 |
anno = anno_barplot(m, gp = gpar(fill = 2:5), bar_width = 1, height = unit(6, "cm")) |
191 | 197 |
draw(anno, test = "proportion matrix") |
192 | 198 |
|
199 |
+anno = anno_barplot(c(1:5, NA, 7:10)) |
|
200 |
+draw(anno, test = "a vector") |
|
193 | 201 |
|
194 | 202 |
##### test anno_boxplot ##### |
195 | 203 |
set.seed(123) |
... | ... |
@@ -202,6 +210,12 @@ draw(anno, test = "anno_boxplot with gp") |
202 | 210 |
anno = anno_boxplot(m, height = unit(4, "cm"), box_width = 0.9) |
203 | 211 |
draw(anno, test = "anno_boxplot with box_width") |
204 | 212 |
|
213 |
+m = matrix(rnorm(100), 10) |
|
214 |
+m[1, ] = NA |
|
215 |
+anno = anno_boxplot(m, height = unit(4, "cm")) |
|
216 |
+draw(anno, test = "anno_boxplot") |
|
217 |
+ |
|
218 |
+ |
|
205 | 219 |
####### test anno_joyplot #### |
206 | 220 |
m = matrix(rnorm(1000), nc = 10) |
207 | 221 |
lt = apply(m, 2, function(x) data.frame(density(x)[c("x", "y")])) |
... | ... |
@@ -240,6 +254,10 @@ anno = anno_histogram(t(m), which = "row", gp = gpar(fill = 1:10)) |
240 | 254 |
draw(anno, test = "row histogram with color") |
241 | 255 |
anno = anno_histogram(t(m), which = "row", n_breaks = 20) |
242 | 256 |
draw(anno, test = "row histogram with color") |
257 |
+m[1, ] = NA |
|
258 |
+anno = anno_histogram(t(m), which = "row") |
|
259 |
+draw(anno, test = "row histogram") |
|
260 |
+ |
|
243 | 261 |
|
244 | 262 |
####### test anno_density ###### |
245 | 263 |
anno = anno_density(t(m), which = "row") |