R语言绘图包10–Circos图的绘制:circlize包
R语言绘图包系列:
- R语言绘图包01--优秀的拼图包patchwork
- R语言绘图包02--热图pheatmap
- R语言绘图包03--火山图EnhancedVolcano
- R语言绘图包04--GOplot:富集分析结果可视化
- R语言绘图包05--韦恩图的绘制:ggvenn和VennDiagram
- R语言绘图包06--基因表达相关性绘图corrplot
- R语言绘图包07--多集合可视化UpSetR
- R语言绘图包08--森林图的绘制:forestplot
- R语言绘图包09--序列分析图的绘制ggseqlogo
0. 简介
circos plot可以展示不同实体之间的相互关系和彼此分享的一些共通之处,因此这种图表非常适合用来比较数据集或不同数据组之间的相似性,节点围绕圆周分布,点与点之间以弧线彼此连接以显示其中的关系,然后再给每个连接分配权重。它的主要特点在于可以帮助我们看出数据之间的关系,适用于比较数据集或不同数据组之间的数值,但也存在不足之处,比如如果需要显示太多连接的时候会显得比较混乱。
示例:
设计原理
circlize 圆形布局由 sectors(扇形)和 tracks(轨迹)组成。对于数据中的不同分类,会作为不同的 sectors,在圆形布局上看起来就是将圆切割为一个个扇形;而同一个类别的不同维度的观测值,会作为从圆外向圆内不断堆叠的图形轨迹 tracks,即展示的各种数据图形。
例如,对于下面这张图
1. R包安装
install.packages("circlize")
# devtools::install_github("jokergoo/circlize")
R包中包含的函数见最后一部分
2. 简单示例
library(circlize)
library(RColorBrewer)
data=matrix(sample(18,18),3,6)
rownames(data)=paste0("R",1:3)
colnames(data)=paste0("C",1:6)
df=data.frame(from=rep(rownames(data),times=ncol(data)),
to=rep(colnames(data),each=nrow(data)),
value=as.vector(data),
stringsAsFactors = F)
df
# from to value
# 1 R1 C1 10
# 2 R2 C1 6
# 3 R3 C1 17
# 4 R1 C2 3
# 5 R2 C2 2
# 6 R3 C2 9
# 7 R1 C3 5
# 8 R2 C3 8
# 9 R3 C3 7
# 10 R1 C4 1
# 11 R2 C4 16
# 12 R3 C4 14
# 13 R1 C5 15
# 14 R2 C5 13
# 15 R3 C5 12
# 16 R1 C6 11
# 17 R2 C6 4
# 18 R3 C6 18
chordDiagram(df,grid.col = brewer.pal(9,"Set1")[1:9],link.border = "grey")
R包中包含的函数
Current there are following low-level graphic functions:
- circos.points()
- circos.lines()
- circos.segments()
- circos.rect()
- circos.polygon()
- circos.text()
- circos.axis()
- circos.raster()
- circos.arrow()
- circos.raster()
- circos.barplot()
- circos.boxplot()
- circos.link(), This maybe the unique feature for circos layout to represent relationships between elements.
For drawing points, lines and text through the whole track (among several sectors), the following functions are available:
Draw circular heatmaps
Functions to arrange the circular layout:
Theoretically, you are able to draw most kinds of circular plots by the above functions.
For specific use in Genomics, we also implement functions which add graphics in genome scale.
Functions to initialize circular plot with genomic coordinates:
Functions to arrange genomic circular layout:
Functions to add basic graphics in genomic scale:
- circos.genomicPoints()
- circos.genomicLines()
- circos.genomicText()
- circos.genomicRect()
- circos.genomicLink()
Functions with specific purpose:
- circos.genomicIdeogram()
- circos.genomicHeatmap()
- circos.genomicLabels()
- circos.genomicDensity()
- circos.genomicRainfall()
Finally, function that draws Chord diagram:
参考:
circlize: circular visualization in R
Circular Visualization in R
共有 0 条评论