繪制 SNP 密度圖

一般使用 CMplot 繪制SNP密度圖:
包鏈接:https://github.com/YinLiLin/R-CMplot

要繪制 SNP 密度圖秕铛,僅僅需要三列即可:
a. 第一列是 SNP 名稱
b. 第二列是染色體
c. 第三列是 SNP 的位置
d. 第四列開始為不同性狀的P值

1. 示例數(shù)據(jù):

          SNP Chromosome Position    trait1     trait2     trait3
1 ALGA0000009          1    52297 0.7738187 0.51194318 0.51194318
2 ALGA0000014          1    79763 0.7738187 0.51194318 0.51194318
3 ALGA0000021          1   209568 0.7583016 0.98405289 0.98405289
4 ALGA0000022          1   292758 0.7200305 0.48887140 0.48887140
5 ALGA0000046          1   747831 0.9736840 0.22096836 0.22096836
6 ALGA0000047          1   761957 0.9174565 0.05753712 0.05753712

2. 安裝 CMplot 包

install.packages("CMplot")
library("CMplot")

3. 作圖代碼

首先讀取數(shù)據(jù)
pig60k <- read.table("data.txt",header=T)

3.1 示例1 -- 密度條形圖

# 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.

data(pig60K)
CMplot(
        pig60K, plot.type="d",  bin.size=1e6, col=c("darkgreen", "yellow", "red"),
        file="jpg", memo="Fig1", dpi=300, file.output=TRUE, verbose=TRUE
)
Fig1

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="Fig2", dpi=300, file.output=TRUE, verbose=TRUE
)
Fig2

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)

## Note:
# 1. if signal.line=NULL, the lines that crosse circles won't be added.
# 2. if the length of parameter 'chr.den.col' is not equal to 1, SNP density that counts the number of SNP within given size('bin.size') will be plotted around the circle.
Fig3

3.4 示例4 -- 曼哈頓圖

CMplot(
        pig60K, plot.type="m", col=c("grey30","grey60"), LOG10=TRUE, ylim=c(2,12), threshold=c(1e-6,1e-4),
        threshold.lty=c(1,2), threshold.lwd=c(1,1), threshold.col=c("black","grey"), amplify=TRUE,
        chr.den.col=NULL, 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
)

## Note:
## if the ylim is setted, then CMplot will only plot the ponits which among this interval.
Fig4

3.5 示例5 -- 曼哈頓 + 條形圖

CMplot(
        pig60K, plot.type="m", LOG10=TRUE, ylim=NULL, threshold=c(1e-6,1e-4),threshold.lty=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
)  
## Note:
## if the length of parameter 'chr.den.col' is bigger than 1, SNP density that counts the number of SNP within given size('bin.size') will be plotted.
Fig5

3.6 示例6 -- 分染色體曼哈頓圖

CMplot(
        pig60K, plot.type="m", multracks=TRUE, threshold=c(1e-6,1e-4),threshold.lty=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),
        file="jpg",memo="",dpi=300,file.output=TRUE,verbose=TRUE
)
Fig6

3.7 示例7 -- 單性狀 QQ 圖

CMplot(
      pig60K,plot.type="q",conf.int.col=NULL,box=TRUE,file="jpg",memo="",dpi=300,
      file.output=TRUE,verbose=TRUE
)
Fig7

3.8 示例8 -- 多性狀 QQ 圖

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
)
Fig8

4. CMplot 的參數(shù)及解釋:

Pmap: 
  a dataframe, at least four columns. The first column is the name of SNP, the second column is the chromosome of SNP, the third column is the position of SNP, and the remaining columns are the P-value of each trait(Note:each trait a column).
col:
  a vector or a matrix, if "col" equals to a vector, each circle use the same colors, it means that the same chromosome is drewed in the same color, the colors are not fixed, one, two, three or more colors can be used, if the length of the "col" is shorter than the length the chromosome, then colors will be applied circularly. 
  if "col" equals to a matrix, the row is the number of circles(traits), the columns are the colors that users want to use for different circles, so each circle can be plotted in different number of colors, the missing value can be replaced by NA. For example: 
  col=matrix(c("grey30","grey60",NA,"red","blue","green","orange",NA,NA),3,3,byrow=T).
bin.size: 
  the size of bin for SNP_density plot.
bin.max: 
  the max value of legend of SNP_density plot, the bin whose SNP number is bigger than 'bin.max' will be use the same color.
pch: 
  a number, the type for the points, is the same with "pch" in <plot>.
band:   
  a number, the space between chromosomes, the default is 1(if the band equals to 0, then there would be no space between chromosome).
cir.band: 
  a number, the space between circles, the default is 1.
H:   
  a number, the height for each circle, each circle represents a trait, the default is 1.
ylim: 
  a vector, the range of Y-axis when plotting the two type of Manhattans, is the same with "ylim" in <plot>.
cex.axis: 
  a number, controls the size of numbers of X-axis and the size of labels of circle plot.
plot.type: 
  a character or vector, only "d", "c", "m", "q" or "b" can be used. if plot.type="d", SNP density will be plotted; if plot.type="c", only circle-Manhattan plot will be plotted; if plot.type="m",only Manhattan plot will be plotted; if plot.type="q",only Q-Q plot will be plotted;if plot.type="b", both circle-Manhattan, Manhattan and Q-Q plots will be plotted; if plot.type=c("m","q"), Both Manhattan and Q-Q plots will be plotted.
multracks: 
  a logical,if multracks=FALSE, plotting multiple traits on multiple tracks, if it is TRUE, all Manhattan plots will be plotted in only one track.
cex:
  a number or a vector, the size for the points, is the same with "size" in <plot>, and if it is a vector, the first number controls the size of points in circle plot(the default is 0.5), the second number controls the size of points in Manhattan plot(the default is 1), the third number controls the size of points in Q-Q plot(the default is 1)
r: 
  a number, the radius for the circle(the inside radius), the default is 1.
xlab: 
  a character, the labels for x axis.
ylab: 
  a character, the labels for y axis.
xaxs: 
  a character, The style of axis interval calculation to be used for the x-axis. Possible values are "r", "i", "e", "s", "d". The styles are generally controlled by the range of data or xlim, if given.
yaxs: 
  a character, The style of axis interval calculation to be used for the y-axis. See xaxs above..
outward: 
  logical, if outward=TRUE,then all points will be plotted from inside to outside.
threshold: 
  a number or vector, the significant threshold. For example, Bonfferoni adjustment method: threshold=0.01/nrow(Pmap). More than one significant line can be added on the plots, if threshold=0 or NULL, then the threshold line will not be added.
threshold.col: 
  a character or vector, the colour for the line of threshold levels.
threshold.lwd: 
  a number or vector, the width for the line of threshold levels.
threshold.lty: 
  a number or vector, the type for the line of threshold levels.
amplify: 
  logical, CMplot can amplify the significant points, if amplify=T, then the points greater than the minimal significant level will be highlighted, the default: amplify=TRUE.
chr.labels: 
  a vector, the labels for the chromosomes of circle-Manhattan plot.
signal.cex: 
  a number, if amplify=TRUE, users can set the size of significant points.
signal.pch: 
  a number, if amplify=TRUE, users can set the shape of significant points.
signal.col: 
  a character, if amplify=TRUE, users can set the colour of significant points, if signal.col=NULL, then the colors of significant points will not be changed.
signal.line: 
  a number, the width of the lines cross the circle
cir.chr: 
  logical, a boundary represents chromosome, the default is TRUE.
cir.chr.h: 
  a number, the width for the boundary, if cir.chr=FALSE, then this parameter will be useless.
chr.den.col: 
  a character or vector or NULL, the colour for the SNP density. If the length of parameter 'chr.den.col' is bigger than 1, SNP density that counts 
   the number of SNP within given size('bin.size') will be plotted around the circle. If chr.den.col=NULL, then the default colours are the same with the parameter "col" for circle.
cir.legend: 
  logical, whether to add the legend of each circle.
cir.legend.cex: 
  a number, the size of the number of legend.
cir.legend.col: 
  a character, the color of the axis of legend.
LOG10: 
  logical, whether to change the p-value into log10(p-value).
box: 
  logical, this function draws a box around the current Manhattan plot.
conf.int.col: 
  a character, the color of the confidence interval on QQ-plot.
file.output: 
  a logical, users can choose whether to output the plot results.
file: 
  a character, users can choose the different output formats of plot, so for, "jpg", "pdf", "tiff" can be selected by users.
dpi: 
  a number, the picture element for .jpg and .tiff files. The default is 300.
memo: 
  add a character to the output file name.
verbose: 
  whether print the reminder.

感覺作者好棒怯晕!

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末导坟,一起剝皮案震驚了整個濱河市是尔,隨后出現(xiàn)的幾起案子渊抄,更是在濱河造成了極大的恐慌拆宛,老刑警劉巖确封,帶你破解...
    沈念sama閱讀 206,839評論 6 482
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異鹉动,居然都是意外死亡轧坎,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,543評論 2 382
  • 文/潘曉璐 我一進店門训裆,熙熙樓的掌柜王于貴愁眉苦臉地迎上來眶根,“玉大人,你說我怎么就攤上這事边琉∈舭伲” “怎么了?”我有些...
    開封第一講書人閱讀 153,116評論 0 344
  • 文/不壞的土叔 我叫張陵变姨,是天一觀的道長族扰。 經(jīng)常有香客問我,道長定欧,這世上最難降的妖魔是什么渔呵? 我笑而不...
    開封第一講書人閱讀 55,371評論 1 279
  • 正文 為了忘掉前任,我火速辦了婚禮砍鸠,結(jié)果婚禮上扩氢,老公的妹妹穿的比我還像新娘。我一直安慰自己爷辱,他們只是感情好录豺,可當我...
    茶點故事閱讀 64,384評論 5 374
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著饭弓,像睡著了一般双饥。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上弟断,一...
    開封第一講書人閱讀 49,111評論 1 285
  • 那天咏花,我揣著相機與錄音,去河邊找鬼阀趴。 笑死昏翰,一個胖子當著我的面吹牛苍匆,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播棚菊,決...
    沈念sama閱讀 38,416評論 3 400
  • 文/蒼蘭香墨 我猛地睜開眼锉桑,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了窍株?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,053評論 0 259
  • 序言:老撾萬榮一對情侶失蹤攻柠,失蹤者是張志新(化名)和其女友劉穎球订,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體瑰钮,經(jīng)...
    沈念sama閱讀 43,558評論 1 300
  • 正文 獨居荒郊野嶺守林人離奇死亡冒滩,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,007評論 2 325
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了浪谴。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片开睡。...
    茶點故事閱讀 38,117評論 1 334
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖苟耻,靈堂內(nèi)的尸體忽然破棺而出篇恒,到底是詐尸還是另有隱情,我是刑警寧澤凶杖,帶...
    沈念sama閱讀 33,756評論 4 324
  • 正文 年R本政府宣布胁艰,位于F島的核電站,受9級特大地震影響智蝠,放射性物質(zhì)發(fā)生泄漏腾么。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 39,324評論 3 307
  • 文/蒙蒙 一杈湾、第九天 我趴在偏房一處隱蔽的房頂上張望解虱。 院中可真熱鬧,春花似錦漆撞、人聲如沸殴泰。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,315評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽艰匙。三九已至,卻和暖如春抹恳,著一層夾襖步出監(jiān)牢的瞬間员凝,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,539評論 1 262
  • 我被黑心中介騙來泰國打工奋献, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留健霹,地道東北人旺上。 一個月前我還...
    沈念sama閱讀 45,578評論 2 355
  • 正文 我出身青樓,卻偏偏與公主長得像糖埋,于是被迫代替她去往敵國和親宣吱。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 42,877評論 2 345

推薦閱讀更多精彩內(nèi)容