cafe自带的程序,只能单独标注扩增或者收缩的基因家族数。手工标注又很麻烦,所以我写了一个R程序,虽然图不够精致,不过基本解决问题。
- cafe_node_filename: cafe自带程序解析后产生的node文件
- cafe_tree_filename: cafe对应的树文件,就是fams.txt的第一行
- graph_filename: 生成的树文件
# 1. packages and external scripts ---------------------------------------- TODO:
suppressWarnings(suppressWarnings(library(treeio)))
suppressWarnings(suppressWarnings(library(ggtree)))
# 2. functions ------------------------------------------------------------ TODO:
# 3. input ---------------------------------------------------------------- TODO:
Args <- commandArgs()
cafe_node_filename <- Args[6]
cafe_tree_filename <- Args[7]
graph_filename <- Args[8]
# 4. variable setting of test module--------------------------------------- TODO:
# 5. process -------------------------------------------------------------- TODO:
data <- read.table(cafe_node_filename, header = T, as.is = T, sep = "\t")
data$sep <- "/"
data$species <- gsub("<[0-9]{1,2}>", "", data$Node, perl = T)
mytree <- read.tree(cafe_tree_filename)
my_p <- ggtree(mytree, size = 1.5)
my_p %<+% data +
geom_tiplab(aes(label=species),size = 8) +
geom_text(aes(label = Contractions), color = "green", nudge_x = -0.2, vjust = -0.4, size = 5) +
geom_text(aes(label = sep), color = "black", nudge_x = -0.45, vjust = -0.4, size = 5) +
geom_text(aes(label = Expansions), color = "red", nudge_x = -0.65, vjust = -0.4, size = 5)
# geom_nodelab() # 如果要查看内节点label,可以用这行
ggsave(graph_filename, width = 12, height = 7)
结果图:因为和课题有关,所以就不放物种名了。实际情况是会输出的
image.png
小bug:不知道为什么,生成的图有一部分没有在画布上。需要用adobe illustrator打开,挪一下位置···
网友评论