[R] Circos plot Start

BioinformaticsAndMe






Circos plot


: Circos plot은 보유한 데이터를 종합적으로 보여주기 위한 시각화 방법

: 데이터를 원형 레이아웃으로 시각화하여, 특정 정보 사이의 위치 관계를 탐색하기에 유리함

: R 패키지 'OmicCircos'를 통해, 오믹스 데이터 간의 관계를 Circos plot으로 나타냄

: http://bioconductor.org/packages/release/bioc/html/OmicCircos.html





1. 데이터 준비


1) 패키지 설치 및 데이터 로딩 options(stringsAsFactors = F) source("https://bioconductor.org/biocLite.R") biocLite("OmicCircos") library("OmicCircos")

data("UCSC.hg19.chr") data("TCGA.BC.gene.exp.2k.60") dat <- UCSC.hg19.chr dat$chrom <- gsub("chr", "",dat$chrom) dat[dat[,1]==1,]

2) 시뮬레이션 데이터 생성 colors <- rainbow(10, alpha = 0.8)    #alpha : 투명도 lab.n <- 50 cnv.n <- 200 arc.n <- 30 fus.n <- 10


arc.d <- c() for(i in 1:arc.n){ chr <- sample(1:19, 1) chr.i <- which(dat$chrom == chr) chr.arc <- dat[chr.i,] arc.i <- sample(1:nrow(chr.arc), 2) arc.d <- rbind(arc.d, c(chr.arc[arc.i[1], c(1,2)], chr.arc[arc.i[2], c(2,4)])) } colnames(arc.d) <- c("chr", "start", "end", "value")


2-1) Gene funsion 시뮬레이션 데이터

fus.d <- c() for(i in 1:fus.n){ chr1 <- sample(1:19, 1) chr2 <- sample(1:19, 1) chr1.i <- which(dat$chrom == chr1) chr2.i <- which(dat$chrom == chr2) chr1.f <- dat[chr1.i,] chr2.f <- dat[chr2.i,] fus1.i <- sample(1:nrow(chr1.f), 1) fus2.i <- sample(1:nrow(chr2.f), 1) n1 <- paste0("geneA", i) n2 <- paste0("geneB", i) fus.d <- rbind(fus.d, c( chr1.f[fus1.i, c(1,2)], n1, chr2.f[fus2.i, c(1,2)], n2 )) } colnames(fus.d) <- c("chr1","po1","gene1","chr2","po2","gene2")


2-2) Copy number 시뮬레이션 데이터
cnv.i <- sample(1:nrow(dat), cnv.n) vale <- rnorm(cnv.n) cnv.d <- data.frame(dat[cnv.i,c(1,2)], value=vale)
2-3) Genomic position 시뮬레이션 데이터 gene.pos <- TCGA.BC.gene.exp.2k.60[,1:3] 2-4) Gene expression 시뮬레이션 데이터 gene.exp <- TCGA.BC.gene.exp.2k.60 2-5) p-value 시뮬레이션 데이터 gene.pos$p <- rnorm(250,0.01,0.001)* sample(c(1,0.5,0.01,0.001,0.0001),250,replace=TRUE)




2. Circos plot 그리기


1) 염색체 그리기 par(mar=c(1,1,1,1)) plot(c(1,800), c(1,800), type="n", axes=FALSE, xlab="", ylab="") circos(R=400, cir="hg19", type="chr", W=10, scale=T, print.chr.lab = T)    #R : 반지름, W : 원형 너비


2) 같은 높이의 bar chart 그리기 par(mar=c(1,1,1,1)) plot(c(1,800),c(1,800),type="n",axes=FALSE,xlab="",ylab="") circos(R=400, cir="hg19", type="chr", W=10, scale=T, print.chr.lab = T) circos(R=355, cir="hg19", type="b3", W=40, mapping=cnv.d, B=T, col=colors[7])    #b3 : 같은 높이의 형태로 bar chart 생성

3) 고정된 반지름을 점으로 표시 par(mar=c(1,1,1,1)) plot(c(1,800), c(1,800), type="n", axes=FALSE, xlab="", ylab="") circos(R=400, cir="hg19", type="chr", W=10, scale=TRUE, print.chr.lab=TRUE) circos(R=355, cir="hg19", type="b3", W=40, mapping=cnv.d, B=TRUE, col=colors[7]) circos(R=355, cir="hg19", type="s2", W=40, mapping=cnv.d, B=FALSE, col=colors[1], cex=0.5)    #s2 : 고정된 반지름 점 표시

4) 고정된 반지름으로 원호 그리기 par(mar=c(1,1,1,1)) plot(c(1,800), c(1,800), type="n", axes=FALSE, xlab="", ylab="") circos(R=400, cir="hg19", type="chr", W=10, scale=TRUE, print.chr.lab=TRUE, cex=14) circos(R=355, cir="hg19", type="b3", W=40, mapping=cnv.d, B=TRUE, col=colors[7]) circos(R=355, cir="hg19", type="s2", W=40, mapping=cnv.d, B=FALSE, col=colors[1], cex=0.5) circos(R=320, cir="hg19", type="arc2", W=35, mapping=arc.d, B=TRUE, col=colors, lwd=10, cutoff=0) #color는 matrix의 row 순서대로 들어감

5) cutoff value 반대편에 bar chart 그리기 par(mar=c(1,1,1,1)) plot(c(1,800), c(1,800), type="n", axes=FALSE, xlab="", ylab="") circos(R=400, cir="hg19", type="chr", W=10, scale=TRUE, print.chr.lab=TRUE) circos(R=355, cir="hg19", type="b3", W=40, mapping=cnv.d, B=TRUE, col=colors[7]) circos(R=355, cir="hg19", type="s2", W=40, mapping=cnv.d, B=FALSE, col=colors[1], cex=0.5) circos(R=320, cir="hg19", type="arc2", W=35, mapping=arc.d, B=TRUE, col=colors, lwd=10) circos(R=280, cir="hg19", type="b2", W=40, mapping=cnv.d, B=TRUE, col=colors[c(5,9)], lwd=2, cutoff=-0.2, col.v=3) #col.v : 값이 있는 칼럼 위치,    cutoff : +이상값제외/-이하값제외

6) type 파라미터를 계속해서 추가해주면서, Circos plot을 그려나감 par(mar=c(1,1,1,1)) plot(c(1,800), c(1,800), type="n", axes=FALSE, xlab="", ylab="") circos(R=400, cir="hg19", type="chr", W=10, scale=TRUE, print.chr.lab=TRUE) circos(R=355, cir="hg19", type="b3", W=40, mapping=cnv.d, B=TRUE, col=colors[7]) circos(R=355, cir="hg19", type="s2", W=40, mapping=cnv.d, B=FALSE, col=colors[1], cex=0.5) circos(R=320, cir="hg19", type="arc2", W=35, mapping=arc.d, B=TRUE, col=colors, lwd=10, cutoff=0) circos(R=280, cir="hg19", type="b2", W=40, mapping=cnv.d, B=TRUE, col=colors[c(7,9)], lwd=2, cutoff=-0.2, col.v=3) circos(R=240, cir="hg19", type="arc", W=40, mapping=arc.d, B=TRUE, col=colors[c(1,7)], lwd=4, scale=TRUE, col.v=4) circos(R=200, cir="hg19", type="box", W=40, mapping=cnv.d, B=TRUE, col=colors[1], lwd=0.1, scale=TRUE, col.v=3) circos(R=160, cir="hg19", type="h", W=40, mapping=cnv.d, B=FALSE, col=colors[3], lwd=0.1, col.v=3) circos(R=120, cir="hg19", type="link", W=10, mapping=fus.d, col=colors[c(1,7,9)], lwd=2)

7) 바깥쪽으로 Label을 두고 그리기 par(mar=c(1,1,1,1)) plot(c(1,800), c(1,800), type="n", axes=FALSE, xlab="", ylab="") circos(R=300, cir="hg19", type="chr", W=10, scale=FALSE, print.chr.lab=FALSE) circos(R=310, cir="hg19", type="label", W=40, mapping=gene.pos, col=c("black","blue","red"), cex=0.4, side="out") circos(R=250, cir="hg19", type="b3", W=40, mapping=cnv.d, B=TRUE, col=colors[7]) circos(R=250, cir="hg19", type="s2", W=40, mapping=cnv.d, B=FALSE, col=colors[1], cex=0.5) circos(R=220, cir="hg19", type="arc2", W=30, mapping=arc.d, B=TRUE, col=colors, lwd=10, cutoff=0) circos(R=190, cir="hg19", type="b2", W=30, mapping=cnv.d, B=TRUE, col=colors[c(7,9)], lwd=2, cutoff=-0.2, col.v=3) circos(R=160, cir="hg19", type="arc", W=30, mapping=arc.d, B=TRUE, col=colors[c(1,7)], lwd=4, scale=TRUE, col.v=4) circos(R=130, cir="hg19", type="box", W=30, mapping=cnv.d, B=TRUE, col=colors[1], lwd=0.1, scale=TRUE, col.v=3) circos(R=100, cir="hg19", type="h", W=30, mapping=cnv.d,B=FALSE, col=colors[3], lwd=0.1, col.v=3) circos(R=90, cir="hg19", type="link", mapping=fus.d, col=colors[c(1,7,9)], lwd=2)

6) Heatmap circos plot 그리기 par(mar=c(1,1,1,1)) plot(c(1,800), c(1,800), type="n", axes=FALSE, xlab="", ylab="") circos(R=400, cir="hg19", type="chr", W=10, scale=FALSE, print.chr.lab=T) circos(R=300, cir="hg19", type="heatmap2", W=100, mapping=gene.exp, col.v=4, cluster=F, col.bar=T, lwd=0.1, col="green") circos(R=200, cir="hg19", type="s", W=100, mapping=gene.pos, col.v=4, col=colors, scale=TRUE, B=TRUE) sig.gene <- gene.pos[gene.pos$p<0.000001,] circos(R=190, cir="hg19", type="label", W=40, mapping=sig.gene, col=c("black","blue","red"), cex=0.4, side="in")







#Reference

1) http://circos.ca/

2) Hu, Ying, et al. "OmicCircos: a simple-to-use R package for the circular visualization of multidimensional omics data." Cancer informatics 13 (2014): CIN-S13495.

3) http://felixfan.github.io/circos/

4) http://bioconductor.org/packages/release/bioc/html/OmicCircos.html





[R] Circos plot End

BioinformaticsAndMe



'R' 카테고리의 다른 글

[R] Multiple linear regression (다중회귀분석)  (1) 2020.01.14
[R] ChIP-seq 분석  (1) 2020.01.05
[R] ggplot2  (0) 2019.12.16
[R] 상자그림(Box plot)  (0) 2019.12.10
[R] 파이차트(Pie plot)  (0) 2019.12.03

+ Recent posts