GEMMA演示腳本

1.計(jì)算親緣關(guān)系矩陣

# BIMBAM格式文件
gemma \
-g mouse_hs1940.geno.txt.gz \
-p mouse_hs1940.pheno.txt \
-a mouse_hs1940.anno.txt \
-gk 2 \
-o mouse_hs1940

# plink格式文件
gemma \
-bfile mouse_hs1940 \
-gk 2 \
-o mouse_hs1940test

# The estimated relatedness matrix should look like this:
0.3350590  -0.0227226  0.0103535 ...
-0.0227226  0.3035960 -0.0253762 ...
0.0103535  -0.0253762  0.3536100 ...
....................................

2.單性狀LMM GWAS分析

# BIMBAM格式文件
gemma \
-g mouse_hs1940.geno.txt.gz \
-p mouse_hs1940.pheno.txt \
-n 1 \
-a mouse_hs1940.anno.txt \
-k ./output/mouse_hs1940.cXX.txt \
-lmm 1 \
-o mouse_hs1940_CD8_lmm
# plink格式文件
gemma \
-bfile mouse_hs1940 \
-n 1 \
-k ./output/mouse_hs1940.cXX.txt \
-lmm 1 \
-o mouse_hs1940_CD8_lmm

# The result for top 5 SNPs should look like this:
# chr rs ps n_miss allele1 allele0 af beta se l_remle p_wald
# 1 rs3683945 3197400 0 A G 0.443 -7.788665e-02 6.193502e-02 4.317993e+00 2.087616e-01
# 1 rs3707673 3407393 0 G A 0.443 -6.654282e-02 6.210234e-02 4.316144e+00 2.841271e-01
# 1 rs6269442 3492195 0 A G 0.365 -5.344241e-02 5.377464e-02 4.323611e+00 3.204804e-01
# 1 rs6336442 3580634 0 A G 0.443 -6.770154e-02 6.209267e-02 4.315713e+00 2.757541e-01
# 1 rs13475700 4098402 0 A C 0.127 -5.659089e-02 7.175374e-02 4.340145e+00 4.304306e-01

# The log file also contains pve estimates and its standard error
# pve estimate in the null model = 0.608801
# se(pve) in the null model = 0.032774

3.多性狀LMM GWAS分析

## To perform association tests with a multivariate linear mixed model, for two phenotypes CD8 (column 1) and MCH (column 6):
## Notice that the number of individuals in this analysis is different from that above, so the allele frequencies are different between the two analyses
# BIMBAM格式文件
gemma \
-g mouse_hs1940.geno.txt.gz \
-p mouse_hs1940.pheno.txt \
-n 1 6 \
-a mouse_hs1940.anno.txt \
-k ./output/mouse_hs1940.cXX.txt \
-lmm 1\
-o mouse_hs1940_CD8MCH_lmm
# plink格式文件
gemma \
-bfile mouse_hs1940 \
-n 1 6 \
-k ./output/mouse_hs1940.cXX.txt \
-lmm 1\
-o mouse_hs1940_CD8MCH_lmm

# The result for top 5 SNPs should look like this:
# chr rs ps n_miss allele1 allele0 af beta_1 beta_2 Vbeta_1_1 Vbeta_1_2 Vbeta_2_2 p_wald
# 1 rs3683945 3197400 0 A G 0.451 -9.611213e-02 8.165302e-02 3.966873e-03 -2.526118e-04 5.540032e-03 1.862363e-01
# 1 rs3707673 3407393 0 G A 0.451 -8.464470e-02 7.130876e-02 3.986286e-03 -2.593467e-04 5.571616e-03 2.757067e-01
# 1 rs6269442 3492195 0 A G 0.377 -7.146771e-02 5.179252e-02 3.157023e-03 -7.187157e-05 4.276041e-03 3.317712e-01
# 1 rs6336442 3580634 0 A G 0.451 -8.502513e-02 6.813728e-02 3.985054e-03 -2.577585e-04 5.568602e-03 2.835426e-01
# 1 rs13475700 4098402 0 A C 0.128 -6.727883e-02 1.685363e-01 5.597160e-03 -1.366799e-04 7.574216e-03 1.060482e-01

# The log file also contains Vg and Ve estimates and their standard errors
## REMLE estimate for Vg (遺傳方差)in the null model:
# 1.39398
# -0.226714 2.08168
## se(Vg):標(biāo)準(zhǔn)誤
# 0.156661
# 0.136319 0.235858

## REMLE estimate for Ve (誤差方差)in the null model:
# 0.348882
# 0.0490525 0.414433

## se(Ve):標(biāo)準(zhǔn)誤
# 0.0206226
# 0.0166233 0.0266869

4.先填充缺失表型匈庭,再做LMM GWAS分析

# Since there are individuals with partially missing phenotypes, one can impute these missing values before association tests
# BIMBAM格式文件
gemma \
-g mouse_hs1940.geno.txt.gz \
-p mouse_hs1940.pheno.txt \
-n 1 6 \
-a mouse_hs1940.anno.txt \
-k ./output/mouse_hs1940.cXX.txt \
-predict \
-o mouse_hs1940_CD8MCH_prdt

gemma \
-g mouse_hs1940.geno.txt.gz \
-p ./output/mouse_hs1940_CD8MCH_prdt.prdt.txt \
-n 1 2 \
-a mouse_hs1940.anno.txt \
-k ./output/mouse_hs1940.cXX.txt \
-lmm 1\
-o mouse_hs1940_CD8MCH_prdt_lmm

###############################################
# plink格式文件
gemma \
-bfile mouse_hs1940 \
-n 1 6 \
-k ./output/mouse_hs1940.cXX.txt \
-predict \
-o mouse_hs1940_CD8MCH_prdt

gemma \
-bfile mouse_hs1940 \
-n 1 2 \
-k ./output/mouse_hs1940.cXX.txt \
-lmm 1\
-o mouse_hs1940_CD8MCH_prdt_lmm

5.貝葉斯稀疏線性混合模型

## To fit BSLMM in the training set:
## To fit a quantitative trait(數(shù)量性狀)
# BIMBAM格式文件
gemma \
-g mouse_hs1940.geno.txt.gz \
-p mouse_hs1940.pheno.txt \
-n 2 \
-a mouse_hs1940.anno.txt \
-bslmm \
-o mouse_hs1940_CD8_bslmm \
-w 1000 \
-s 10000 \
-seed 1
# plink格式文件
gemma \
-bfile mouse_hs1940 \
-n 2 \
-bslmm \
-o mouse_hs1940_CD8_bslmm \
-w 1000 \
-s 10000 \
-seed 1

# the following three files may be of most importance:
# the *.hyp.txt contains a column for pve and pge
# the *.param.txt contains estimates for betas, gammas and alphas
# the *.bv.txt contains breeding value estimates
## To fit a binary trait(質(zhì)量性狀) using a linear model
# BIMBAM格式文件
gemma \
-g mouse_hs1940.geno.txt.gz \
-p mouse_hs1940.pheno.txt \
-n 4 \
-a mouse_hs1940.anno.txt \
-bslmm \
-o mouse_hs1940_CD8_bslmm_cc1 \
-w 1000 \
-s 10000
-seed 1

## To fit a binary trait using a probit model instead
gemma \
-g mouse_hs1940.geno.txt.gz \
-p mouse_hs1940.pheno.txt \
-n 4 \
-a mouse_hs1940.anno.txt \
-bslmm 3 \
-o mouse_hs1940_CD8_bslmm_cc3 \
-w 1000 \
-s 10000 \
-seed 1

# The pve estimates in the log file are based on the standard linear model (i.e. on the observed scale), and so you will need to properly transform it back to the liability scale
# To generate relatedness matrix based on the training data.

gemma \
-g mouse_hs1940.geno.txt.gz \
-p mouse_hs1940.pheno.txt \
-n 2 \
-a mouse_hs1940.anno.txt \
-gk 1 \
-o mouse_hs1940_CD8_train

# This matrix will only be required if you want to do prediction based on estimated breeding values
# Prediction can also be done without using the breeding values but instead using the alphas.
# This later approach does not appear to lose much accuracy in many examples we have encountered,
# although this may not be the case in your data.

## To obtain predicted values for the test set using estimates from BSLMM
## To do prediction in the test set for quantitative traits

gemma \
-g mouse_hs1940.geno.txt.gz \
-p mouse_hs1940.pheno.txt \
-n 2 \
-epm ./output/mouse_hs1940_CD8_bslmm.param.txt \
-emu ./output/mouse_hs1940_CD8_bslmm.log.txt \
-ebv ./output/mouse_hs1940_CD8_bslmm.bv.txt \
-k ./output/mouse_hs1940_CD8_train.cXX.txt \
-predict \
-o mouse_hs1940_CD8_prdt_k

## or use the alphas instead of breeding values
gemma \
-g mouse_hs1940.geno.txt.gz \
-p mouse_hs1940.pheno.txt \
-n 2 \
-epm ./output/mouse_hs1940_CD8_bslmm.param.txt \
-emu ./output/mouse_hs1940_CD8_bslmm.log.txt \
-predict \
-o mouse_hs1940_CD8_prdt

# The results will be inside ./output/*.prdt.txt
# If you load both results in R and check the mean squared error or correlation, you will find that both ways give very similar results. Both the correlation and the mean squared error should be around 0.65

## Now, do prediction in the test set for the binary traits
## If the traits were fitted using the linear model, then:

gemma \
-g mouse_hs1940.geno.txt.gz \
-p mouse_hs1940.pheno.txt \
-n 4 \
-epm ./output/mouse_hs1940_CD8_bslmm_cc1.param.txt \
-emu ./output/mouse_hs1940_CD8_bslmm_cc1.log.txt \
-predict \
-o mouse_hs1940_CD8_prdt_cc1

## If the traits were fitted using the probit model, then use predict option 2:
gemma \
-g mouse_hs1940.geno.txt.gz \
-p mouse_hs1940.pheno.txt \
-n 4 \
-epm ./output/mouse_hs1940_CD8_bslmm_cc3.param.txt \
-emu ./output/mouse_hs1940_CD8_bslmm_cc3.log.txt \
-predict 2 \
-o mouse_hs1940_CD8_prdt_cc3

# You will find that fitting the binary traits using either the linear version or the probit version of BSLMM gives similar results. The brier scores should be
# around 0.19 and the area under the curve (AUC) should be around 0.78.
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末早芭,一起剝皮案震驚了整個(gè)濱河市现斋,隨后出現(xiàn)的幾起案子容诬,更是在濱河造成了極大的恐慌盲赊,老刑警劉巖坦胶,帶你破解...
    沈念sama閱讀 206,839評(píng)論 6 482
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件杨凑,死亡現(xiàn)場(chǎng)離奇詭異滤奈,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)撩满,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,543評(píng)論 2 382
  • 文/潘曉璐 我一進(jìn)店門(mén)蜒程,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人伺帘,你說(shuō)我怎么就攤上這事昭躺。” “怎么了伪嫁?”我有些...
    開(kāi)封第一講書(shū)人閱讀 153,116評(píng)論 0 344
  • 文/不壞的土叔 我叫張陵窍仰,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我礼殊,道長(zhǎng),這世上最難降的妖魔是什么针史? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 55,371評(píng)論 1 279
  • 正文 為了忘掉前任晶伦,我火速辦了婚禮,結(jié)果婚禮上啄枕,老公的妹妹穿的比我還像新娘婚陪。我一直安慰自己,他們只是感情好频祝,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,384評(píng)論 5 374
  • 文/花漫 我一把揭開(kāi)白布泌参。 她就那樣靜靜地躺著,像睡著了一般常空。 火紅的嫁衣襯著肌膚如雪沽一。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 49,111評(píng)論 1 285
  • 那天漓糙,我揣著相機(jī)與錄音铣缠,去河邊找鬼。 笑死昆禽,一個(gè)胖子當(dāng)著我的面吹牛蝗蛙,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播醉鳖,決...
    沈念sama閱讀 38,416評(píng)論 3 400
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼捡硅,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了盗棵?” 一聲冷哼從身側(cè)響起壮韭,我...
    開(kāi)封第一講書(shū)人閱讀 37,053評(píng)論 0 259
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤北发,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后泰涂,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體鲫竞,經(jīng)...
    沈念sama閱讀 43,558評(píng)論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,007評(píng)論 2 325
  • 正文 我和宋清朗相戀三年逼蒙,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了从绘。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,117評(píng)論 1 334
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡是牢,死狀恐怖僵井,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情驳棱,我是刑警寧澤批什,帶...
    沈念sama閱讀 33,756評(píng)論 4 324
  • 正文 年R本政府宣布,位于F島的核電站社搅,受9級(jí)特大地震影響驻债,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜形葬,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,324評(píng)論 3 307
  • 文/蒙蒙 一合呐、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧笙以,春花似錦淌实、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,315評(píng)論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至倘感,卻和暖如春放坏,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背老玛。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 31,539評(píng)論 1 262
  • 我被黑心中介騙來(lái)泰國(guó)打工轻姿, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人逻炊。 一個(gè)月前我還...
    沈念sama閱讀 45,578評(píng)論 2 355
  • 正文 我出身青樓互亮,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親余素。 傳聞我的和親對(duì)象是個(gè)殘疾皇子豹休,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,877評(píng)論 2 345

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