在Genome-wide association study(GWAS,全基因組關聯(lián)研究)關聯(lián)分析的時候,我們經常會看到一些非常漂亮的曼哈頓圖,能對候選位點的分布和數值一目了然。 那么如何繪制好看的曼哈頓圖呢? 就用R語言中CMplot包,幫你繪制高質量的曼哈頓圖。 1. 安裝CMplot包 > install.packages('CMplot') > library('CMplot') #首先讀取數據 > data(pig60K) #CMplot包中自帶數據,SNP位點信息表 > head(pig60K) #顯示部分數據,第一列是SNP的名稱,第二列是SNP所在染色體名字,第三列是SNP的位置,后面幾列為不同特征的P值 2. 函數及主要參數如下: 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) 部分參數及其含義: Pmap:輸入數據文件,數據框。 col:設置染色體中點的顏色。 pch:設置點的形狀。 band:設置染色體之間的間隔。 H:設置每個圈的高度。 bin.size:設置SNP密度圖中的窗口大小。 cex.axis:設置坐標軸字體和標簽字體的大小。 plot.type:設置不同的繪圖類型,可以設定為 'd', 'c', 'm', 'q' or 'b'。 multracks:設置是否需要繪制多個track。 r:設置圈的半徑大小。 threshold:設置閾值并添加閾值線。 amplify:設置是否放大顯著的點。 signal.cex:設置顯著點的大小。 chr.labels:設置染色體的標簽。 cir.legend:設置是否顯示圖例。 file:設置輸出圖片的格式,可以設定為'jpg', 'pdf', 'tiff'。 dpi:設置輸出圖片的分辨度。 memo:設置輸出圖片文件的名字。 其中各個參數更加詳細用法可參看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 今日份的精彩內容已落下帷幕,想了解更多R語言繪圖相關介紹,就來2019暑期銳翌培訓班吧——>相約暑假|2019銳翌暑期培訓班,報名開始! 供稿:溫平平 編輯:魯淑妮 |
|
來自: 生物_醫(yī)藥_科研 > 《待分類》