前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >使用TASSEL学习GWAS笔记:从入门到出家

使用TASSEL学习GWAS笔记:从入门到出家

作者头像
邓飞
发布2024-06-08 08:57:34
1900
发布2024-06-08 08:57:34
举报
文章被收录于专栏:育种数据分析之放飞自我

1. TASSEL的GLM和MLM分析结果

质控后的plink数据和表型数据:

「GLM的GWAS分析结果:」

「MLM的GWAS分析结果:」

2. TASSEL中的可视化

TASSEL有对结果进行可视化的模块,包括qq图和曼哈顿图,但是图不方便调整。这里用TASSEL的分析结果,使用R语言进行绘制qq图和曼哈顿图。

3. R语言包安装及载入

需要用到:

  • qqman
  • tidyverse
  • data.table

下面代码,会判断是否有这三个包,如果没有,就自动安装。然后载入软件包。

代码语言:javascript
复制
if(!require(data.table)) install.packages("data.table")
if(!require(qqman)) install.packages("qqman")
if(!require(tidyverse)) install.packages("tidyverse")

library(qqman)
library(tidyverse)
library(data.table)

4. GLM模型GWAS结果可视化

代码语言:javascript
复制
results_log = fread("glm-result.txt")
dim(results_log)
head(results_log)

select = dplyr::select
table(results_log$Trait)

结果:

代码语言:javascript
复制
> table(results_log$Trait)

 dpoll EarDia  EarHT 
  2460   2460   2460

数据中共有三个性状,可以选择一个性状,进行可视化。

代码语言:javascript
复制
d1 = results_log %>% filter(Trait == "dpoll") %>% select(Chr,Marker,Pos,p)
head(d1)
summary(d1)
d1 = d1 %>% drop_na(p)
summary(d1)

注意,有些P值是NA,在作图时会报错,这里将其移除。

整理后的结果:

代码语言:javascript
复制
> summary(d1)
      Chr          Marker               Pos                  p         
 Min.   : 1.0   Length:2460        Min.   :   139753   Min.   :0.0000  
 1st Qu.: 2.0   Class :character   1st Qu.: 43868061   1st Qu.:0.1236  
 Median : 4.0   Mode  :character   Median :128423374   Median :0.3911  
 Mean   : 4.7                      Mean   :120382976   Mean   :0.4165  
 3rd Qu.: 7.0                      3rd Qu.:175628840   3rd Qu.:0.6743  
 Max.   :10.0                      Max.   :298413352   Max.   :0.9996

作图代码:

代码语言:javascript
复制
manhattan(d1,chr="Chr",bp="Pos",p="p",snp="Marker", main = "Manhattan plot: logistic")
tiff("y1-曼哈顿图.tiff")
manhattan(d1,chr="Chr",bp="Pos",p="p",snp="Marker", main = "Manhattan plot: logistic")
dev.off()

qq(d1$p, main = "Q-Q plot of GWAS p-values : log")
tiff("y1-QQ图.tiff")
qq(d1$p, main = "Q-Q plot of GWAS p-values : log")
dev.off()

「曼哈顿图:」

「QQ图:」

其它两个性状的作图代码:

代码语言:javascript
复制

d2 = results_log %>% filter(Trait == "EarDia") %>% select(Chr,Marker,Pos,p)
head(d2)
summary(d2)
d2 = d2 %>% drop_na(p)
summary(d2)

tiff("y2-曼哈顿图.tiff")
manhattan(d2,chr="Chr",bp="Pos",p="p",snp="Marker", main = "Manhattan plot: logistic")
dev.off()

tiff("y2-QQ图.tiff")
qq(d2$p, main = "Q-Q plot of GWAS p-values : log")
dev.off()


d3 = results_log %>% filter(Trait == "EarHT") %>% select(Chr,Marker,Pos,p)
head(d3)
summary(d3)
d3 = d3 %>% drop_na(p)
summary(d3)

tiff("y3-曼哈顿图.tiff")
manhattan(d3,chr="Chr",bp="Pos",p="p",snp="Marker", main = "Manhattan plot: logistic")
dev.off()

tiff("y3-QQ图.tiff")
qq(d3$p, main = "Q-Q plot of GWAS p-values : log")
dev.off()

将整理后的不同性状的结果保存到本地:

代码语言:javascript
复制
fwrite(d1,"y1_result.csv")
fwrite(d2,"y2_result.csv")
fwrite(d3,"y3_result.csv")

5. MLM模型GWAS结果可视化

读取数据,提取性状,去掉P值为缺失的行:

代码语言:javascript
复制
library(qqman)
library(data.table)
results_log = fread("mlm-result.txt", head=TRUE)
dim(results_log)
head(results_log)

library(tidyverse)
select = dplyr::select
table(results_log$Trait)
d1 = results_log %>% filter(Trait == "dpoll") %>% select(Chr,Marker,Pos,p)
head(d1)
summary(d1)
d1 = d1 %>% drop_na(p)
summary(d1)

「曼哈顿图:」

「QQ图:」

其它两个作图代码:

代码语言:javascript
复制

d2 = results_log %>% filter(Trait == "EarDia") %>% select(Chr,Marker,Pos,p)
head(d2)
summary(d2)
d2 = d2 %>% drop_na(p)
summary(d2)

tiff("y2-曼哈顿图.tiff")
manhattan(d2,chr="Chr",bp="Pos",p="p",snp="Marker", main = "Manhattan plot: logistic")
dev.off()

tiff("y2-QQ图.tiff")
qq(d2$p, main = "Q-Q plot of GWAS p-values : log")
dev.off()


d3 = results_log %>% filter(Trait == "EarHT") %>% select(Chr,Marker,Pos,p)
head(d3)
summary(d3)
d3 = d3 %>% drop_na(p)
summary(d3)

tiff("y3-曼哈顿图.tiff")
manhattan(d3,chr="Chr",bp="Pos",p="p",snp="Marker", main = "Manhattan plot: logistic")
dev.off()

tiff("y3-QQ图.tiff")
qq(d3$p, main = "Q-Q plot of GWAS p-values : log")
dev.off()

6. 完整代码汇总

「GLM的可视化代码:」

代码语言:javascript
复制
## 对TASSEL GLM 模型可视化

if(!require(data.table)) install.packages("data.table")
if(!require(qqman)) install.packages("qqman")
if(!require(tidyverse)) install.packages("tidyverse")

library(qqman)
library(tidyverse)
library(data.table)

results_log = fread("glm-result.txt")
dim(results_log)
head(results_log)

select = dplyr::select
table(results_log$Trait)
d1 = results_log %>% filter(Trait == "dpoll") %>% select(Chr,Marker,Pos,p)
head(d1)
summary(d1)
d1 = d1 %>% drop_na(p)
summary(d1)

manhattan(d1,chr="Chr",bp="Pos",p="p",snp="Marker", main = "Manhattan plot: logistic")
tiff("y1-曼哈顿图.tiff")
manhattan(d1,chr="Chr",bp="Pos",p="p",snp="Marker", main = "Manhattan plot: logistic")
dev.off()

qq(d1$p, main = "Q-Q plot of GWAS p-values : log")
tiff("y1-QQ图.tiff")
qq(d1$p, main = "Q-Q plot of GWAS p-values : log")
dev.off()

d2 = results_log %>% filter(Trait == "EarDia") %>% select(Chr,Marker,Pos,p)
head(d2)
summary(d2)
d2 = d2 %>% drop_na(p)
summary(d2)

tiff("y2-曼哈顿图.tiff")
manhattan(d2,chr="Chr",bp="Pos",p="p",snp="Marker", main = "Manhattan plot: logistic")
dev.off()

tiff("y2-QQ图.tiff")
qq(d2$p, main = "Q-Q plot of GWAS p-values : log")
dev.off()


d3 = results_log %>% filter(Trait == "EarHT") %>% select(Chr,Marker,Pos,p)
head(d3)
summary(d3)
d3 = d3 %>% drop_na(p)
summary(d3)

tiff("y3-曼哈顿图.tiff")
manhattan(d3,chr="Chr",bp="Pos",p="p",snp="Marker", main = "Manhattan plot: logistic")
dev.off()

tiff("y3-QQ图.tiff")
qq(d3$p, main = "Q-Q plot of GWAS p-values : log")
dev.off()

fwrite(d1,"y1_result.csv")
fwrite(d2,"y2_result.csv")
fwrite(d3,"y3_result.csv")

「MLM的可视化代码:」

代码语言:javascript
复制
## 对TASSEL GLM 模型可视化

library(qqman)
library(data.table)
results_log = fread("mlm-result.txt", head=TRUE)
dim(results_log)
head(results_log)

library(tidyverse)
select = dplyr::select
table(results_log$Trait)
d1 = results_log %>% filter(Trait == "dpoll") %>% select(Chr,Marker,Pos,p)
head(d1)
summary(d1)
d1 = d1 %>% drop_na(p)
summary(d1)

manhattan(d1,chr="Chr",bp="Pos",p="p",snp="Marker", main = "Manhattan plot: logistic")
tiff("y1-曼哈顿图.tiff")
manhattan(d1,chr="Chr",bp="Pos",p="p",snp="Marker", main = "Manhattan plot: logistic")
dev.off()

qq(d1$p, main = "Q-Q plot of GWAS p-values : log")
tiff("y1-QQ图.tiff")
qq(d1$p, main = "Q-Q plot of GWAS p-values : log")
dev.off()

d2 = results_log %>% filter(Trait == "EarDia") %>% select(Chr,Marker,Pos,p)
head(d2)
summary(d2)
d2 = d2 %>% drop_na(p)
summary(d2)

tiff("y2-曼哈顿图.tiff")
manhattan(d2,chr="Chr",bp="Pos",p="p",snp="Marker", main = "Manhattan plot: logistic")
dev.off()

tiff("y2-QQ图.tiff")
qq(d2$p, main = "Q-Q plot of GWAS p-values : log")
dev.off()


d3 = results_log %>% filter(Trait == "EarHT") %>% select(Chr,Marker,Pos,p)
head(d3)
summary(d3)
d3 = d3 %>% drop_na(p)
summary(d3)

tiff("y3-曼哈顿图.tiff")
manhattan(d3,chr="Chr",bp="Pos",p="p",snp="Marker", main = "Manhattan plot: logistic")
dev.off()

tiff("y3-QQ图.tiff")
qq(d3$p, main = "Q-Q plot of GWAS p-values : log")
dev.off()

fwrite(d1,"y1_result.csv")
fwrite(d2,"y2_result.csv")
fwrite(d3,"y3_result.csv")

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2024-06-03,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 育种数据分析之放飞自我 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1. TASSEL的GLM和MLM分析结果
  • 2. TASSEL中的可视化
  • 3. R语言包安装及载入
  • 4. GLM模型GWAS结果可视化
  • 5. MLM模型GWAS结果可视化
  • 6. 完整代码汇总
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档