Reputation: 29
By using the data from heatmap.2:
data(mtcars)
x<-scale(mtcars)
set.seed(123)
tf<-sample(rownames(x), 5)
tf
[1] "Merc 280" "Pontiac Firebird" "Merc 450SL"
"Fiat X1-9" "Porsche 914-2"
heatmap.2(x)
I wanted put in bold row names in tf (on the right). I dug around and I can't find the solutions, only for a color names. Does anybody have suggestions using the above sample?
Upvotes: 2
Views: 926
Reputation: 46908
We can try this function written by @skafdasschaf:
make_bold_names <- function(mat, rc_fun, rc_names) {
bold_names <- rc_fun(mat)
ids <- rc_names %>% match(rc_fun(mat))
ids %>%
walk(
function(i)
bold_names[i] <<-
bquote(bold(.(rc_fun(mat)[i]))) %>%
as.expression()
)
bold_names
}
Then:
library(gplots)
library(dplyr)
library(purrr)
data(mtcars)
x<-scale(mtcars)
set.seed(123)
tf<-sample(rownames(x), 5)
hm = heatmap.2(x)
heatmap.2(x,labRow=make_bold_names(x,rownames,tf),margins=c(8,8))
Upvotes: 1