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

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

拟南芥的富集分析

「知识星球」里的问题,https://t.zsxq.com/aEyneA2,拟南芥的ID怎么搞,这个内置是支持的。

比如我随便搞几个ID来演示一下:

> require(clusterProfiler)
Loading required package: clusterProfiler

clusterProfiler v3.9.0  For help: https://guangchuangyu.github.io/software/clusterProfiler

If you use clusterProfiler in published research, please cite:
Guangchuang Yu, Li-Gen Wang, Yanyan Han, Qing-Yu He. clusterProfiler: an R package for 
comparing biological themes among gene clusters. OMICS: A Journal of Integrative Biology. 2012, 16(5):284-287.

g <- c("AT5G61600", "AT2G44230", "AT1G49130", "AT1G30310", "AT3G18560",
"AT2G15960", "AT2G29290", "AT1G08930", "AT2G44460", "AT3G46600",
"AT5G24380", "AT3G59270", "AT5G55780", "AT2G45090", "AT5G38430",
"AT2G17040", "AT4G35770", "AT5G30341", "AT1G56320", "AT2G16367")

Continue reading

在《一个要复活的R包和一个404的网站》一文中第一次介绍了scholar包,它可以应用于《自动抓取论文的引用数据》,虽然数据源来自于Google Scholar,国内用户可能访问不了,但今天要介绍的这个功能,所有人都是可以用的,它允许我们检索期刊的影响因子,在《scholar包支持检索期刊影响因子》一文中第一次介绍了这个功能,当时是2016年的影响因子(2017年发布),现在数据已经更新至2018年6月26号发布的2017年影响因子。

> library(scholar)
> jn = c("bioinformatics", "methods in ecology and evolution",
+     "molecular biosystems", "molecular biology and evolution")
> get_impactfactor(jn)
# A tibble: 4 x 4
  Journal                          Cites ImpactFactor Eigenfactor
  <chr>                            <dbl>        <dbl>       <dbl>
1 BIOINFORMATICS                   95300         5.48      0.201
2 Methods in Ecology and Evolution  8866         6.36      0.0370
3 Molecular BioSystems              7269         2.76      0.0175
4 MOLECULAR BIOLOGY AND EVOLUTION  44664        10.2       0.102

Continue reading

说到世界杯,我是不追的,但1998年法国世界杯我还是有印象的,那时候读初中的我,一直在集邮,那年代没有网购,通讯基本靠吼,当年的我已经是个老司机了,通过邮政汇款,买了好多东西,包括1998年世界杯从法国寄往中国的首日封,当然锁在老家的柜子里,尘封多年,所以我现在也没办法随手拍一张照片给大家分享。

另一件事,同样是1998年,那年升高一,开学第一天,老师让大家自我介绍一下,有位帅哥在见面第一天,就立了flag,说自己中考没考好,是因为看世界杯了,他高考必定要怎么样怎么样,毕竟世界杯是四年一次。你一个交钱进学校的学渣,牛逼吹大了,我印象深刻,所以我后来留意了一下这家伙高考上了那家高校,结果是「中山大学网络教育学院」,也就是电视大学!真的是情节反转如疾风!

转发5个群,Y叔送你一顶帽子》这一篇文章写的是加圣诞帽子,但你要加个C罗、梅西,有什么差别吗?没有!你要加某球队的队服,有什么差别吗?没有。所以要制作世界杯专属头像,已然可以用ggimage纯代码生成。

Continue reading

Author's picture

Guangchuang Yu

Bioinformatics Professor @ SMU

Bioinformatics Professor

Guangzhou