首页 文章

R plotly热图刻度标签被截止

提问于
浏览
0

尝试使用 Rplotly 生成基因表达热图 . 基因名称很长,尺寸很大:

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=".")

集群:

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]

生成绘图并保存html文件:

heatmap.plotly <- plot_ly(x=colnames(mat),y=rownames(mat),z=mat,type="heatmap",colors=colorRamp(c("darkblue","white","darkred")))
htmlwidgets::saveWidget(heatmap.plotly,"heatmap.plotly.html")

我获得的数字基因名称被截断,我提供了所有数据:
enter image description here

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

1 回答

  • 2

    增加利润

    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
    

相关问题