R在没有X11的Linux机器上剧情崩溃

时间:2017-05-12 17:34:27

标签: r ggplot2 x11 plotly

我正在[HOST]/de-DE [HOST]/sv-SE [HOST]/fr-BE [HOST]/nl-BE plotlyheatmap树状图上一起绘制ggplot2处理了一点(与heatmaply不兼容)机器没有linux并遇到错误:

以下是代码:

X11

给出: enter image description here

在没有library(ggplot2) library(plotly) library(dendextend) #dendogram data set.seed(1) my.mat <- matrix(rnorm(10*100),nrow=100,ncol=10,dimnames = list(paste("g",1:100,sep=""),paste("s",1:10,sep=""))) my.hover.mat <- matrix(paste(paste(rownames(my.mat),paste("description",1:100,sep=" "),sep=":"),colnames(my.mat),signif(my.mat,3),sep="'</br>'"),nrow=100,ncol=10) x <- as.matrix(scale(my.mat)) dd.col <- as.dendrogram(hclust(dist(x))) dd.row <- as.dendrogram(hclust(dist(t(x)))) #cut dd.col dd.col <- cut(dd.col,h=6)$upper ggdend.col <- as.ggdend(dd.col) leaf.heights <- dplyr::filter(ggdend.col$nodes,!is.na(leaf))$height leaf.seqments.idx <- which(ggdend.col$segments$yend %in% leaf.heights) ggdend.col$segments$yend[leaf.seqments.idx] <- max(ggdend.col$segments$yend[leaf.seqments.idx]) ggdend.col$segments$col[leaf.seqments.idx] <- "black" ggdend.col$labels$label <- 1:nrow(ggdend.col$labels) ggdend.col$labels$y <- max(ggdend.col$segments$yend[leaf.seqments.idx]) ggdend.col$labels$x <- ggdend.col$segments$x[leaf.seqments.idx] ggdend.col$labels$col <- "black" ggdend.col$segments$lwd <- 0.5 ggdend.row <- dendro_data(dd.row) ggdend.row$labels$label <- "" ggdend.row$labels$col <- "black" ggdend.row$segments$lwd <- 0.5 #ggplot dendrograms py <- ggplot()+geom_segment(data=ggdend.col$segments,aes(x=x,y=y,xend=xend,yend=yend))+coord_flip()+annotate("text",size=4,hjust=1,x=ggdend.col$label$x,y=ggdend.col$label$y,label=ggdend.col$label$label,colour=ggdend.col$label$col)+labs(x="",y="")+ theme_minimal()+theme(axis.text=element_blank(),axis.ticks=element_blank(),panel.grid=element_blank()) px <- ggplot()+geom_segment(data=ggdend.row$segments,aes(x=x,y=y,xend=xend,yend=yend))+annotate("text",size=4,hjust=1,x=ggdend.row$label$x,y=ggdend.row$label$y,label=ggdend.row$label$label,colour=ggdend.row$label$col)+labs(x="",y="")+ labs(x="",y="")+theme_minimal()+theme(axis.text=element_blank(),axis.ticks=element_blank(),panel.grid=element_blank()) # heatmap col.ord <- order.dendrogram(dd.col) row.ord <- order.dendrogram(dd.row) my.mat <- my.mat[col.ord,row.ord] my.hover.mat <- my.hover.mat[col.ord,row.ord] heatmap.plotly <- plot_ly() %>% add_heatmap(z=~my.mat,x=factor(colnames(my.mat),lev=colnames(my.mat)),y=factor(rownames(my.mat),lev=rownames(my.mat)),hoverinfo='text',text=my.hover.mat) # plotting it all together eaxis <- list(showticklabels = FALSE,showgrid = FALSE,zeroline = FALSE) p_empty <- plot_ly(filename="r-docs/dendrogram") %>% layout(margin = list(l = 200),xaxis = eaxis,yaxis = eaxis) all.together <- plotly::subplot(px, p_empty, heatmap.plotly, py, nrows = 2, margin = 0.01) 的{​​{1}}计算机上,linux对象转换为X11对象,发生在ggplot2命令,崩溃时出现此错误消息:

plotly

如果我尝试将树形图plotly::subplot对象:Error in .External2(C_X11, paste("png::", filename, sep = ""), g$width, : unable to start device PNG [1]: https://i.stack.imgur.com/UhKg7.png ggplot转换为px个对象,则会获得相同的错误:

py

所以这不是我问题的解决方案。

所以我的问题是:

  1. 是否有解决plotly问题的方法?我无法在我的机器上安装> plotly_build(py) Error in .External2(C_X11, paste("png::", filename, sep = ""), g$width, : unable to start device PNG ,因此无法解决问题。

  2. 也许可以直接或从X11X11对象生成plotly dendrogram - 即无需转换dendrogramggdend个对象。

0 个答案:

没有答案