2017-02-28 58 views
0

尝试使用Rplotly产生基因表达热图。基因名称很长,尺寸是相当大的:R plotly heatmap刻度标签被截止

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

增加你的利润

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