R plotly热图刻度标签被截止

时间:2017-02-28 08:10:39

标签: r heatmap plotly

尝试使用R的{​​{1}}生成基因表达热图。基因名称很长,尺寸很大:

plotly

聚类:

require(permute)
require(plotly)
set.seed(1)
mat <- matrix(shuffle(c(rnorm(5000,2,1),rnorm(5000,-2,1))),nrow=2500,ncol=4)
rownames(mat) <- paste("very_long_gene_name",1:2500,sep=".")
colnames(mat) <- paste("s",1:4,sep=".")

制作情节并保存html文件:

hc.col <- hclust(dist(t(mat)))
dd.col <- as.dendrogram(hc.col)
col.order <- order.dendrogram(dd.col)
hc.row <- hclust(dist(mat))
dd.row <- as.dendrogram(hc.row)
row.order <- order.dendrogram(dd.row)
mat <- mat[row.order,col.order]

我得到的数字基因名称被截断,我不确定它是否提供了所有数据: enter image description here

知道如何解决这两个问题吗?

1 个答案:

答案 0 :(得分:3)

增加保证金

m <- list(
  l = 200,
  r = 10,
  b = 50,
  t = 10,
  pad = 2
)
heatmap.plotly <- plot_ly(x=colnames(mat),y=rownames(mat),z=mat,type="heatmap",
    colors=colorRamp(c("darkblue","white","darkred"))) %>%
    layout(margin = m)

heatmap.plotly