引言
❝
有用户在 github 提问,clusterGvis 怎么添加行注释,What I am expecting is to add row annotations for gene types and variants. Thank you! 实际上我已经写死了 left_annotation/right_annotation,有些时候用户可能自己想添加其它的行注释,于是对函数进行了更新,来完成这样的需求。
安装
Note: please update your ComplexHeatmap to the latest version!
install.packages(“devtools”)
devtools::install_github(“junjunlab/ClusterGVis”)
示例
我们选部分基因画个聚类的热图:
library(ClusterGVis)
library(ComplexHeatmap)
load data
data(exps)
using TCseq for clustering
ct <- clusterData(exp = exps[1:20,],
cluster.method = “TCseq”,
cluster.num = 2)
visCluster(object = ct,
plot.type = “heatmap”,
column_names_rot = 45)
❝
我提供了一个 row_annotation_obj 的参数,如果你的 plot.type = “heatmap” 或者 plot.type = “both” 且 line.side 在右边,你需要传入一个 ComplexHeatmap::rowAnnotation 注释对象就行。除了以上情况,你只需要传入一个含有 named vector 的 list 就行。注意基因的顺序需要和图中的 cluster 的顺序保持一致。 比如上面的顺序就是 C1-C2。
给基因分个组:
df <- ct$wide.res %>% dplyr::arrange(cluster)
l_ano <- rep(LETTERS[1:3],c(6,4,10))
names(l_ano) <- df$gene
l_ano
Nhlrc2 Trappc4 Ywhah Ppp2r2d Kpnb1 Ckb Gpx1
“A” “A” “A” “A” “A” “A” “B”
Qdpr Oog4 Psmd9 Sephs2 Dctpp1 Ciao1 Oas1f
“B” “B” “B” “C” “C” “C” “C”
Scrn2 Arl6 Fam188a C630004H02Rik Tmem135 Ipo9
“C” “C” “C” “C” “C” “C”
然后添加注释(给了其他无用的注释):
visCluster(object = ct,
plot.type = “heatmap”,
column_names_rot = 45,
show_row_names = T,
row_annotation_obj = ComplexHeatmap::rowAnnotation(anno = l_ano,
hh = anno_text(LETTERS[1:20]),
nm = anno_barplot(runif(20)))
)
或者这样添加:
row_annotation_obj <- list(anno = l_ano,
hh = anno_text(LETTERS[1:20],which = “row”),
nm = anno_barplot(runif(20),which = “row”))
left_annotation <- do.call(ComplexHeatmap::rowAnnotation,
modifyList(list(),
row_annotation_obj))
visCluster(object = ct,
plot.type = “heatmap”,
column_names_rot = 45,
show_row_names = T,
row_annotation_obj = left_annotation)
line.side 在右边的情况:
pdf(‘addgene.pdf’,height = 6,width = 6,onefile = F)
visCluster(object = ct,
plot.type = “both”,
column_names_rot = 45,
row_annotation_obj = left_annotation)
dev.off()
如果在左边,你就给这个 row_annotation_obj list 就行:
pdf(‘addgene2.pdf’,height = 6,width = 6,onefile = F)
visCluster(object = ct,
plot.type = “both”,
column_names_rot = 45,
row_annotation_obj = row_annotation_obj,
line.side = “left”)
dev.off()
结尾
❝
路漫漫其修远兮,吾将上下而求索。
欢迎加入生信交流群。加我微信我也拉你进 微信群聊 老俊俊生信交流群 (微信交流群需收取 20 元入群费用,一旦交费,拒不退还!(防止骗子和便于管理)) 。
声明:文中观点不代表本站立场。本文传送门:https://eyangzhen.com/423544.html