GWAS分析中0-1-2的编码问题

昨天一个小伙伴给我写了封信,问我了几个GWAS的问题,我就回信说,答案可以写一下公众号了。

这不,就来了。

邓老师,您好,看了好多博文,学到好多,最近看一些GWAS原理相关的内容,有些疑惑。想请教一下。

1、GWAS分析基本都是基于回归分析,分析时势必会将序列转化为012编码的基因型,这个编码格式什么规格?Major allel
0;杂合1;minor allel :2?,还是其他规则?仅考虑加性模型。

2、看这个好多软件大多都支持Plink的格式,是否在其他软件(GAPIT、GEMMA等?)进行转化过程中也遵循Plink的编码格式?

3、我是做植物的,GAPIT计算结果输出的Effect
是否就是PlinkGLM模型中的beta值?都表示回归系数?代表单个位点的改变性状的变化?

4、回归系数反应优异等位基因的来源,这和常用的VCF文件中的REF 和ALT 基因型有没有对比,是否Major
allel一定是REF,而Minor allel基因型一定是ALT基因型?

十分感谢!

第一个问题:GWAS中0-1-2的编码?

应该都是采用这样的编码:主等位基因纯合编码为0,杂合为1,次等位基因纯合编码为2。

看一下plink的官网说明:

–recode creates a new text fileset, after applying sample/variant filters and other operations. By default, the fileset includes a .ped
and a .map file, readable with --file.

The ‘12’ modifier causes A1 (usually minor) alleles to be coded as ‘1’
and A2 alleles to be coded as ‘2’, while ‘01’ maps A1→0 and A2→1.
(PLINK forces you to combine ‘01’ with --[output-]missing-genotype
when this is necessary to prevent missing genotypes from becoming
indistinguishable from A1 calls.) The ‘23’ modifier causes a
23andMe-formatted file to be generated. This can only be used on a
single sample’s data (a one-line --keep file may come in handy here).
There is currently no special handling of the XY pseudo-autosomal
region. The ‘AD’ modifier causes an additive (0/1/2) + dominant (het =
1, otherwise 0) component file, suitable for loading from R, to be
generated. ‘A’ is the same, except without the dominance component. By
default, A1 alleles are counted; this can be customized with
–recode-allele. --recode-allele’s input file should have variant IDs in the first column and allele IDs in the second. By default, the
header line for .raw files only names the counted alleles. To include
the alternate allele codes as well, add the ‘include-alt’ modifier.
Haploid additive components are 0/2-valued instead of 0/1-valued, to
maintain a consistent scale on the X chromosome.

测试一下,手动生成一个模拟的plink文件

ped数据:

1 1 0 0 1  0  G G  2 2  C C
1 2 0 0 2  0  A G  0 0  A C
1 3 1 2 1  2  0 0  1 2  A C
2 1 0 0 1  0  G G  2 2  0 0
2 2 0 0 2  2  A A  2 2  0 0
2 3 1 2 1  2  G G  2 2  C C

map数据:

1 snp1 0 1
1 snp2 0 2
1 snp3 0 3

查看一下频率:

plink命令:

plink --file tt --freq --out re1

结果:

$ cat re1.frq
 CHR  SNP   A1   A2          MAF  NCHROBS
   1 snp1    A    G        0.375        8
   1 snp2    1    2            0        6
   1 snp3    A    C         0.25        4

结果中,A1是次等位基因,A2是主等位基因。

转化为0-1-2的形式:

plink命令:

plink --file tt --recodeA --out re2

结果:

FID IID PAT MAT SEX PHENOTYPE snp1_A snp2_1 snp3_A
1 1 0 0 1 -9 0 0 0
1 2 0 0 2 -9 1 NA 1
1 3 1 2 1 2 NA 1 1
2 1 0 0 1 -9 0 0 NA
2 2 0 0 2 2 2 0 NA
2 3 1 2 1 2 0 0 0

可以看到第一个SNP,G为主等位基因,纯合的编码为0,杂合的编码为1,次等位纯合编码为2.

第二个问题:其它软件是否也是这样的编码形式?

应该是这样的。

plink编码:

plink上面已经介绍过了。

GAPIT编码:
下面我们看一下GAPIT的说明:https://www.zzlab.net/GAPIT/gapit_help_document.pdf

GEMMA编码:
下面我们看一下GEMMA的说明:https://www.xzlab.org/software/GEMMAmanual.pdf

第三个问题:GAPIT输出的Effect和plink中GLM中的beta是否一样?

一样,都是回归系数。

不同的是,GAPIT用的是MLM模型,而plink用的是GLM模型,他们都是利用单位点作为数字协变量计算回归系数(effect)的显著性(pvalue)。

第四个问题:等位基因变化

等位基因变化,与VCF中的REF和ALT,是否REF一定是major,而ALT一定是minor
不是的,major和minor是根据GWAS的群体计算的,与VCF中的REF和ALT不一定对应

所以,上面算是回答吧。

关注我的公众号:育种数据分析之放飞自我。主要分享R语言,Python,育种数据分析,生物统计,数量遗传学,混合线性模型,GWAS和GS相关的知识。

好的,这是一个关于独热编码问题。独热编码是一种将分类数据转换为数字数据的技术,以便机器学习算法能够处理。在你的问题,每个SNP(碱基多态性)可以被编码为一个10位的二进制数,其每个位代表这个SNP在某个品种是否存在,0表示不存在,1表示存在。因此,对于每个品种,你需要将其10个SNP分别转换为一个10位的二进制数,最终得到一个形状为(3, 10)的独热编码矩阵。具体实现可以使用Python的NumPy库,代码如下: ```python import numpy as np # 假设有3个品种,每个品种有10个SNP snp_data = [['a', 'g', 'c', 't', 'a', 't', 'g', 'c', 'a', 't'], ['g', 'a', 't', 'c', 'g', 'a', 't', 'c', 'g', 'a'], ['c', 't', 'a', 'g', 'c', 't', 'a', 'g', 'c', 't']] # 创建一个编码矩阵,初始值为0 one_hot_matrix = np.zeros((3, 10, 4)) # 将每个SNP进行独热编码 for i in range(3): for j in range(10): if snp_data[i][j] == 'a': one_hot_matrix[i, j, 0] = 1 elif snp_data[i][j] == 'g': one_hot_matrix[i, j, 1] = 1 elif snp_data[i][j] == 'c': one_hot_matrix[i, j, 2] = 1 elif snp_data[i][j] == 't': one_hot_matrix[i, j, 3] = 1 print(one_hot_matrix) ``` 输出的结果如下: ``` [[[1. 0. 0. 0.] [0. 1. 0. 0.] [0. 0. 1. 0.] [0. 0. 0. 1.] [1. 0. 0. 0.] [0. 0. 0. 1.] [0. 1. 0. 0.] [0. 0. 1. 0.] [1. 0. 0. 0.] [0. 0. 0. 1.]] [[0. 1. 0. 0.] [1. 0. 0. 0.] [0. 0. 0. 1.] [0. 1. 0. 0.] [1. 0. 0. 0.] [0. 1. 0. 0.] [0. 0. 0. 1.] [0. 1. 0. 0.] [1. 0. 0. 0.] [0. 1. 0. 0.]] [[0. 0. 1. 0.] [0. 0. 0. 1.] [1. 0. 0. 0.] [0. 1. 0. 0.] [0. 0. 1. 0.] [0. 0. 0. 1.] [1. 0. 0. 0.] [0. 0. 0. 1.] [0. 0. 1. 0.] [0. 0. 0. 1.]]] ``` 这就是每个品种的SNP独热编码矩阵。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值