I post this because I am facing the same problem: I want to change the text of the label (not the font, the face, the colour, etc: the text itself) of the leftmost panel which is automatically called “Tree” by ggtree. As far as I understand, and contrary to what is posted below, the “theme” thing of ggplot2 only allows to change the appearance of the panel header, not the text of the panel title itself… So how to go about that?

这是google group里的问题,说的是facet_plot会把画树的panel叫做Tree,而他想改名,于是我就写了一个函数,facet_labeller来回应这个问题。

Continue reading

I’ve been having great success with ggtree now and have recommended it to several colleages here in Oxford.

Is there any way to seperate the legend in heatmaps? Eg I have plotted a tree in a circular style with outer rings given extra data - I would like a seperate key for each ring - is this possible?

This is a user question. Plotting multiple heatmaps that align to the phylogenetic tree is easy with gheatmap function.

Here is a simple example:

library("ggplot2")
library("ggtree")

nwk <- system.file("extdata", "sample.nwk", package="treeio")

tree <- read.tree(nwk)
circ <- ggtree(tree, layout = "circular")

df <- data.frame(first=c("a", "b", "a", "c", "d", "d", "a", "b", "e", "e", "f", "c", "f"),
                 second= c("z", "z", "z", "z", "y", "y", "y", "y", "x", "x", "x", "a", "a"))

rownames(df) <- tree$tip.label


p1 <- gheatmap(circ, df[, "first", drop=F], offset=.8, width=.1,
               colnames_angle=90, colnames_offset_y = .25)
p2 <- gheatmap(p1, df[, "second", drop=F], offset=5, width=.1,
               colnames_angle=90, colnames_offset_y = .25)

Continue reading

用ggplot2画3D

在《扪心自问,meme几何?》一文中,我画了一只兔子,今天给大家演示一下画一只3D版本的兔子,我们知道ggplot2不支持3D,只能画2D的图,但3D其实只是视觉上的,显示在你屏幕上的,同样只是2D。所以我们要做的,就是把3D的坐标转换成2D,然后画出2D的图片来,而这2D看上去有3D的效果。

Continue reading

Arch之软件降级

用Arch Linux就是每天睡觉关机前滚一下,然而有时候有些软件升级滚出问题,比如glibc-2.28就导致了R安装包有问题,会抛出下面的错误:

terminate called after throwing an instance of 'std::runtime_error'
  what():  Mutex creation failed

blogdown编译博客也同样会抛出这个错误。

然后electron也有问题,《开源的macOS和linux版微信》跑着跑着突然CPU就狂飙。

解决办法就是安装回老版本,但pacman永远是最新的,当然可以去git/svn仓库里找老版本的PKGBUILD,然后再makepkg,但经常会在signature checking这步报错,你还得到导入keyring,挺麻烦。

这时候我找到了downgrade脚本:

Bash script for downgrading one or more packages to a version in your cache or the A.L.A.

AUR有收录,安装非常简单:

Continue reading

pheatmap我其实用的次数不多,但在帮别人解决一些问题之后,比如:

我发现这包的交互能力是比较差的,它就像传统的plot函数一样,命令一打下去,就直接画图,虽然它其实是有输出的,但事实上超出了一般用户的理解能力,它的输出,比如说可以用cowplot来拼图,我在上面链接的那篇文章中皆来演示,然而很多人问我,怎么把pheatmap画的热图和ggplot2的图,用cowplot来拼。这就是因为拼图的方法超出了很多的理解范围,看过演示,也只能照猫画老虎,过后也就忘记了。有没有办法用大家可以理解的方法来拼?这样就不太容易忘记,答案是肯定的,我下次再讲。今天先讲一讲其前提条件。

Continue reading

国内的办公环境,离不开QQ等Windows软件,以前我通过《安装黑苹果》来解决,如果要用Linux呢?我们不禁想问,连Windows都能跑Linux程序了,Linux到底什么时候能跑Windows程序?

干了这杯酒,不干没鸡鸡!

Wine虽然是一个解决方案,而且现在也有现成的方案,比如《你们想要的:QQ跑在Linux上 》,再比如有打包好的深度QQ等。但我不想在我64位的系统里装一堆32位的兼容包,也不想(多多少少得)折腾Wine。

无需安装,开箱即用?

这显然是最好的方案,比如在苹果系统上,我已经打包了《OSX版BioEdit》和《独家:SciHub苹果桌面版》,你只需要拖到Applications里,双击就能用。

这有什么好处?第一你不用去系统里装Wine以及一堆依赖包,第二你不需要去配置Wine,第三这个运行环境是与你的系统分离的(系统是干净的)。对于用户来说,傻瓜化开箱即用,对于系统来说,干净不影响。这是最好的方案。谁愿意去装一堆没用的兼容libs,谁愿意去折腾老半天还用不上!当然有一点点不好的地方,是打包的软件体积稍大一点,因为你要打包整个运行环境嘛,但现在最不值钱的就是存储空间了。

所以最好的方案是像Mac这样,可以把运行环境分离出来,系统干净不折腾!当然再者还得有像我这样的好心人去打包。

Continue reading

R总给我惊喜

Hello! First of all, I would like to thank you for this wonderful and very powerful package!

I have tried to plot a phylogenetic tree with heatmap of associated matrix (with gheatmap). I found that the row names of matrix doesn’t exactly match to the tip names of tree in case if there is missing data in associated matrix. In other words, if we have two species (e.g., Species198 and Species1981), but only one of them is represented in the associated matrix, we will have colored cells for both species in the heatmap.

Continue reading

Author's picture

Guangchuang Yu

Bioinformatics Professor @ SMU

Bioinformatics Professor

Guangzhou