如何在我的热图中仅将基因名称设为斜体(使用 R)?
How to italicize just gene names in my heatmap (using R)?
我正在用 R (gplots) 绘制热图,我只想将我的基因名称用斜体显示(在我的示例中 - gene1、gene2 和 gene3)。
例如:
df <- data.frame(Gene = c ("gene1", "gene2", "gene3"), value = c(3, 2, 2.5), time = c("10d","10d","10d"))
gplots::heatmap.2(cbind(df$value, df$value), trace= "none", Colv = NA, labCol = "", labRow = df$Gene, Rowv=FALSE)
我试过了(没用):
df <- data.frame(Gene = c ( expression(italic("gene1", "gene2", "gene3"))), value = c(3, 2, 2.5), time = c("10d","10d","10d"))
或
df <- data.frame(Gene = expression(italic(c ("gene1", "gene2", "gene3"))), value = c(3, 2, 2.5), time = c("10d","10d","10d"))
有什么建议吗?
这将以编程方式进行:
gene_list <- as.character(df$Gene)
make_italics <- function(x) {
as.expression(lapply(x, function(y) bquote(italic(.(y)))))
}
heatmap.2(
cbind(df$value, df$value),
trace = "none",
Colv = NA,
labCol = "",
labRow = make_italics(gene_list),
Rowv = FALSE
)
我正在用 R (gplots) 绘制热图,我只想将我的基因名称用斜体显示(在我的示例中 - gene1、gene2 和 gene3)。 例如:
df <- data.frame(Gene = c ("gene1", "gene2", "gene3"), value = c(3, 2, 2.5), time = c("10d","10d","10d"))
gplots::heatmap.2(cbind(df$value, df$value), trace= "none", Colv = NA, labCol = "", labRow = df$Gene, Rowv=FALSE)
我试过了(没用):
df <- data.frame(Gene = c ( expression(italic("gene1", "gene2", "gene3"))), value = c(3, 2, 2.5), time = c("10d","10d","10d"))
或
df <- data.frame(Gene = expression(italic(c ("gene1", "gene2", "gene3"))), value = c(3, 2, 2.5), time = c("10d","10d","10d"))
有什么建议吗?
这将以编程方式进行:
gene_list <- as.character(df$Gene)
make_italics <- function(x) {
as.expression(lapply(x, function(y) bquote(italic(.(y)))))
}
heatmap.2(
cbind(df$value, df$value),
trace = "none",
Colv = NA,
labCol = "",
labRow = make_italics(gene_list),
Rowv = FALSE
)