在Genome-wide association study(GWAS,全基因組關(guān)聯(lián)研究)關(guān)聯(lián)分析的時候,我們經(jīng)常會看到一些非常漂亮的曼哈頓圖,能對候選位點(diǎn)的分布和數(shù)值一目了然。 那么如何繪制好看的曼哈頓圖呢? 就用R語言中CMplot包,幫你繪制高質(zhì)量的曼哈頓圖。 1. 安裝CMplot包 > install.packages('CMplot') > library('CMplot') #首先讀取數(shù)據(jù) > data(pig60K) #CMplot包中自帶數(shù)據(jù),SNP位點(diǎn)信息表 > head(pig60K) #顯示部分?jǐn)?shù)據(jù),第一列是SNP的名稱,第二列是SNP所在染色體名字,第三列是SNP的位置,后面幾列為不同特征的P值 2. 函數(shù)及主要參數(shù)如下: CMplot(Pmap,col=c('#377EB8','#4DAF4A','#984EA3','#FF7F00'),bin.size=1e6,pch=19,band=1,cir.band=0.5,H=1.5,ylim=NULL,cex.axis=1,plot.type='b',multracks=FALSE,cex=c(0.5,1,1),r=0.3,xlab='Chromosome',ylab=expression(-log[10](italic(p))),xaxs='i',yaxs='r',outward=FALSE,threshold=NULL,threshold.col='red',threshold.lwd=1, threshold.lty=2, amplify=TRUE, chr.labels=NULL,signal.cex=1.5,signal.pch=19,signal.col='red',signal.line=1,cir.chr=TRUE,cir.chr.h=1.5, chr.den.col=c('darkgreen', 'yellow','red'),cir.legend=TRUE,cir.legend.cex=0.6,cir.legend.col='black',LOG10=TRUE,box=FALSE,conf.int.col='grey',file.output=TRUE,file='jpg',dpi=300,memo='',verbose=TRUE) 部分參數(shù)及其含義: Pmap:輸入數(shù)據(jù)文件,數(shù)據(jù)框。 col:設(shè)置染色體中點(diǎn)的顏色。 pch:設(shè)置點(diǎn)的形狀。 band:設(shè)置染色體之間的間隔。 H:設(shè)置每個圈的高度。 bin.size:設(shè)置SNP密度圖中的窗口大小。 cex.axis:設(shè)置坐標(biāo)軸字體和標(biāo)簽字體的大小。 plot.type:設(shè)置不同的繪圖類型,可以設(shè)定為 'd', 'c', 'm', 'q' or 'b'。 multracks:設(shè)置是否需要繪制多個track。 r:設(shè)置圈的半徑大小。 threshold:設(shè)置閾值并添加閾值線。 amplify:設(shè)置是否放大顯著的點(diǎn)。 signal.cex:設(shè)置顯著點(diǎn)的大小。 chr.labels:設(shè)置染色體的標(biāo)簽。 cir.legend:設(shè)置是否顯示圖例。 file:設(shè)置輸出圖片的格式,可以設(shè)定為'jpg', 'pdf', 'tiff'。 dpi:設(shè)置輸出圖片的分辨度。 memo:設(shè)置輸出圖片文件的名字。 其中各個參數(shù)更加詳細(xì)用法可參看R語言中幫助文檔:?CMplot。 3. 作圖代碼 3.1 示例1 -- SNP密度條形圖 >CMplot(pig60K,plot.type='d',bin.size=1e6,col=c('darkgreen','yellow','red'),file='jpg',memo='',dpi=300,file.output=TRUE, verbose=TRUE) #繪制SNP在不同染色體的分布情況 # users can personally set the windowsize and the max of legend by: # bin.size=1e6 # bin.max=N # memo: add a character to the output file name. 3.2 示例2 -- 環(huán)狀圖 >CMplot(pig60K,plot.type='c',chr.labels=paste('Chr',c(1:18,'X'),sep=''),r=0.4,cir.legend=TRUE,outward=FALSE,cir.legend.col='black',cir.chr.h=1.3,chr.den.col='black',file='jpg',memo='',dpi=300,file.output=TRUE,verbose=TRUE) 3.3 示例3 -- 多層圈圖 >CMplot(pig60K,plot.type='c',r=0.4,col=c('grey30','grey60'),chr.labels=paste('Chr',c(1:18,'X'),sep=''),threshold=c(1e-6,1e-4),cir.chr.h=1.5,amplify=TRUE,threshold.lty=c(1,2),threshold.col=c('red','blue'),signal.line=1,signal.col=c('red','green'),chr.den.col=c('darkgreen','yellow','red'),bin.size=1e6,outward=FALSE,file='jpg',memo='',dpi=300,file.output=TRUE,verbose=TRUE) 3.4 示例4 -- 曼哈頓圖 >CMplot(pig60K,plot.type='m',LOG10=TRUE,threshold=NULL,chr.den.col=NULL,file='jpg',memo='',dpi=300,file.output=TRUE,verbose=TRUE) >CMplot(pig60K,plot.type='m',LOG10=TRUE,ylim=NULL,threshold=c(1e-6,1e-4),threshold.lt=c(1,2),threshold.lwd=c(1,1),threshold.col=c('black','grey'),amplify=TRUE,bin.size=1e6,chr.den.col=c('darkgreen','yellow','red'),signal.col=c('red','green'),signal.cex=c(1,1),signal.pch=c(19,19),file='jpg',memo='',dpi=300,file.output=TRUE,verbose=TRUE) ![]() 3.5 示例5 -- QQ 圖 >CMplot(pig60K,plot.type='q',conf.int.col=NULL,box=TRUE,file='jpg',memo='',dpi=300,file.output=TRUE,verbose=TRUE) ![]() >CMplot(pig60K,plot.type='q',col=c('dodgerblue1','olivedrab3','darkgoldenrod1'),threshold= 1e6,signal.pch=19,signal.cex=1.5,signal.col='red',conf.int.col='grey',box=FALSE, multracks=TRUE,file='jpg',memo='',dpi=300,file.output=TRUE,verbose=TRUE) ![]() 參考資料:https://github.com/YinLiLin/R-CMplot 今日份的精彩內(nèi)容已落下帷幕,想了解更多R語言繪圖相關(guān)介紹,就來2019暑期銳翌培訓(xùn)班吧——>相約暑假|(zhì)2019銳翌暑期培訓(xùn)班,報名開始! 供稿:溫平平 編輯:魯淑妮 |
|