Skip to content

Commit

Permalink
NA is allowed in pch in legend
Browse files Browse the repository at this point in the history
  • Loading branch information
jokergoo committed Nov 24, 2022
1 parent 136d94d commit debb53d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/getting-help.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ assignees: ''

---

Please provide example datasets and the code you use. It will help me to understand your problem and help you!
> Please provide example datasets and the code you use. It will help me to understand your problem and help you!
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: ComplexHeatmap
Type: Package
Title: Make Complex Heatmaps
Version: 2.13.4
Date: 2022-10-15
Version: 2.15.1
Date: 2022-11-24
Authors@R: person("Zuguang", "Gu", email = "[email protected]", role = c("aut", "cre"),
comment = c('ORCID'="0000-0002-7395-8709"))
Depends: R (>= 3.5.0), methods, grid, graphics, stats, grDevices
Expand Down
2 changes: 1 addition & 1 deletion R/Heatmap-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ Heatmap = function(matrix, col, name,

if(is.null(names(col))) {
if(length(col) == length(unique(as.vector(matrix)))) {
if(length(col) >= 50) {
if(length(col) >= 6) {
message_wrap(qq("There are @{length(col)} unique colors in the vector `col` and @{length(col)} unique values in `matrix`. `Heatmap()` will treat it as an exact discrete one-to-one mapping. If this is not what you want, slightly change the number of colors, e.g. by adding one more color or removing a color."))
}
if(is.null(fa_level)) {
Expand Down
11 changes: 6 additions & 5 deletions R/grid.Legend.R
Original file line number Diff line number Diff line change
Expand Up @@ -1482,20 +1482,21 @@ is_diff_equal = function(x) {
# pch are numeric
.pointsGrob_as_a_list = function(x, y, pch, gp, size, width, height) {
n = length(x)
if(any(pch %in% 26:31)) {
pch2 = pch; pch2[is.na(pch2)] = -1
if(any(pch2 %in% 26:31)) {
gl = list()
for(i in 1:n) {
if(pch[i] == 26) {
if(pch2[i] == 26) {
gb = segmentsGrob(x[i] - width*0.4, y[i] - height*0.4, x[i] + width*0.4, y[i] + height*0.4, gp = subset_gp(gp[i]))
} else if(pch[i] == 27) {
} else if(pch2[i] == 27) {
gb = segmentsGrob(x[i] + width*0.4, y[i] - height*0.4, x[i] - width*0.4, y[i] + height*0.4, gp = subset_gp(gp[i]))
} else if(pch[i] == 28) {
} else if(pch2[i] == 28) {
gb = segmentsGrob(unit.c(x[i] - width*0.4, x[i] + width*0.4),
unit.c(y[i] - height*0.4, y[i] - height*0.4),
unit.c(x[i] + width*0.4, x[i] - width*0.4),
unit.c(y[i] + height*0.4, y[i] + height*0.4),
gp = subset_gp(gp[i]))
} else if(pch[i] %in% 29:31) {
} else if(pch2[i] %in% 29:31) {
stop_wrap("pch in 29:31 is not implemented in Legend().")
} else {
gb = pointsGrob(x = x[i], y = y[i], pch = pch[i], gp = subset_gp(gp, i), size = size[i])
Expand Down

0 comments on commit debb53d

Please sign in to comment.