R语言可视化R生信相关作图

R语言绘图包10--Circos图的绘制:circlize包

2022-10-28  本文已影响0人  Hayley笔记

R语言绘图包系列:


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:

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:

Functions with specific purpose:

Finally, function that draws Chord diagram:

参考:
circlize: circular visualization in R
Circular Visualization in R

上一篇下一篇

猜你喜欢

热点阅读