I need to use and show stars for significances within my pheatmp
, I have utilised the approach below.
As you can see the stars reported by the figure cross the cell border. Is there a way to centre it within the cell?
test_vals <- matrix(rnorm(20), 5, 4)
test_labels <- matrix(1:20, 5, 4)
test_labels[test_labels<=10] <- "**"
pheatmap(test_vals, display_numbers = test_labels, fontsize_number=40, cellheight=20)
I did not find a straight way to solve your task, so I can suggest a little dirty hack. You can use a different asterisk symbol from Unicode (U+2217 ASTERISK OPERATOR). So try this:
UPDATE: it is possible to pass Unicode strings into plotting function without previous parsing. Therefore I have updated the code and removed stringi
library requirement.
library(pheatmap)
test_vals <- matrix(rnorm(20), 5, 4)
test_labels <- matrix(1:20, 5, 4)
test_labels[test_labels <= 10] <- "\u2217\u2217"
pheatmap(test_vals, display_numbers = test_labels, fontsize_number=20, cellheight=20)
Also, you can try other variants. Next two are slightly bigger the common asterisk.
# Heavy asterisk
#test_labels[test_labels<=10] <- "\u2731\u2731"
# Full width asterisk
#test_labels[test_labels<=10] <- "\uFF0A\uFF0A"