前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >plink软件初体验1--初试牛刀

plink软件初体验1--初试牛刀

作者头像
邓飞
发布2020-11-03 10:48:57
1.1K0
发布2020-11-03 10:48:57
举报

准备写一系列plink软件常用的命令,最近在数据分析时,需要将基因型的数据转化为0-1-2的形式,编程实现效果太差,100万的数据,plink十几秒完成,真的是厉害,非常值得学习,所以,开始搞起!

.map格式

格式说明链接: http://zzz.bwh.harvard.edu/plink/data.shtml#map

❝map格式的文件, 主要是图谱文件信息, 主要包括染色体名称, 所在的染色体和所在染色体的坐标. ❞

1, map文件没有行头

2, map文件包括四列: 染色体, SNP名称, SNP位置, 碱基对坐标

  • 染色体编号为数字, 未知为0
  • SNP名称为字符或数字, 如果不重要, 可以从1编号, 注意要和bed文件SNP列一一对应
  • 染色体的摩尔未知(可选项, 可以用0)
  • SNP物理坐标

3, 如果只有SNP名称, 可以手动构建map文件, 第二列为SNP名称, 其它三列为0即可.


「英文格式说明」

代码语言:javascript
复制
By default, each line of the MAP file describes a single marker and must contain exactly 4 columns:

     chromosome (1-22, X, Y or 0 if unplaced)
     rs# or snp identifier
     Genetic distance (morgans)
     Base-pair position (bp units)

Genetic distance can be specified in centimorgans with the --cm flag. Alternatively, you can use a MAP file with the genetic distance excluded by adding the flag --map3, i.e.
plink --file mydata --map3

In this case, the three columns are expected to be

     chromosome (1-22, X, Y or 0 if unplaced)
     rs# or snp identifier
     Base-pair position (bp units)

Base-pair positions are expected to correspond to positive integers within the range of typical human chromosome sizes. 
Example
代码语言:javascript
复制
1 snp1 0 1
1 snp2 0 2
1 snp3 0 3
  • 这里有3个SNP, 分别名为snp1, snp3, snp3 「(第二列)」
  • 这三个SNP在第一个染色体上 「(第一列)」
  • 第三列为0
  • 第四列为SNP所在染色体的坐标

.ped格式

格式说明链接:http://zzz.bwh.harvard.edu/plink/data.shtml#ped

❝bed格式的文件, 主要包括SNP的信息, 包括个体ID, 系谱信息, 表型和SNP的分型信息. ❞

1, 数据没有行头, 空格或者tab隔开的文件 2, 必须要有六列, 包括系谱信息, 表型信息

  • 第一列: Family ID # 如果没有, 可以用个体ID代替
  • 第二列: Individual ID # 个体ID编号
  • 第三列: Paternal ID # 父本编号
  • 第四列: Maternal ID # 母本编号
  • 第五列: Sex (1=male; 2=female; other=unknown) # 性别, 如果未知, 用0表示
  • 第六列: Phenotype # 表型数据, 如果未知, 用0表示
  • 第七列以后: 为SNP分型数据, 可以是AT CG或11 12, 或者A T C G或1 1 2 2

3, 上面六列, 必须要有, 如果没有相关数据, 用0表示.

「英文格式说明」

代码语言:javascript
复制
As well as the --file command described above, PED and MAP files can be specified separately, if they have different names:
plink --ped mydata.ped --map autosomal.map
Note Loading a large file (100K+ SNPs) can take a while (which is why we suggest converting to binary format). PLINK will give an error message in most circumstances when something has gone wrong.
The PED file is a white-space (space or tab) delimited file: the first six columns are mandatory:

     Family ID
     Individual ID
     Paternal ID
     Maternal ID
     Sex (1=male; 2=female; other=unknown)
     Phenotype

The IDs are alphanumeric: the combination of family and individual ID should uniquely identify a person. A PED file must have 1 and only 1 phenotype in the sixth column. The phenotype can be either a quantitative trait or an affection status column: PLINK will automatically detect which type (i.e. based on whether a value other than 0, 1, 2 or the missing genotype code is observed). 
Example
代码语言:javascript
复制
1 1 0 0 1  0  G G  2 2  C C
1 2 0 0 2  0  A A  0 0  A C
1 3 1 2 1  2  0 0  1 2  A C
2 1 0 0 1  0  A A  2 2  0 0
2 2 0 0 2  2  A A  2 2  0 0
2 3 1 2 1  2  A A  2 2  A A
  • 数据包括两个家系 「(第一列)」
  • 每个家系有三个个体 「(第二列)」
  • 第三列父本编号
  • 第四列母本编号
  • 第五列性别
  • 第六列表型值
  • 第七列, 第八列为一个基因型
  • 第九列, 第十列为第二个基因型
  • 第十一列, 第十二列为第三个基因型

练习1

ped格式是1 1 2 2 的格式转化为0 1 2 这里1 1之间有空格

「test1.ped」

代码语言:javascript
复制
1 1 0 0 1  0  1 1  2 2  1 1
1 2 0 0 2  0  2 2  0 0  2 1
1 3 1 2 1  2  0 0  1 2  2 1
2 1 0 0 1  0  1 1  2 2  0 0
2 2 0 0 2  2  2 2  2 2  0 0
2 3 1 2 1  2  1 1  2 2  1 1

「test1.map」

代码语言:javascript
复制
1 snp1 0 1
1 snp2 0 2
1 snp3 0 3

「plink命令行」

代码语言:javascript
复制
plink --file test2 --recodeA

「结果:」

代码语言:javascript
复制
FID IID PAT MAT SEX PHENOTYPE snp1_2 snp2_1 snp3_2
1 1 0 0 1 -9 0 0 0
1 2 0 0 2 -9 2 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

可以看出, 表型值缺失的部分变为了"-9", 基因型值缺失的部分变为了NA, snp的major变为了0, snp的minor变为了2, 杂合变为了1.

练习2

ped格式是11 22 的格式转化为0 1 2 这里11中间没有空格「test2.ped」

代码语言:javascript
复制
1 1 0 0 1 0 11 22 11
1 2 0 0 2 0 22 00 21
1 3 1 2 1 2 00 12 21
2 1 0 0 1 0 11 22 00
2 2 0 0 2 2 22 22 00
2 3 1 2 1 2 11 22 11

「test2.map」

代码语言:javascript
复制
1 snp1 0 1
1 snp2 0 2
1 snp3 0 3

「命令:」结果:plink.raw

代码语言:javascript
复制
FID IID PAT MAT SEX PHENOTYPE snp1_2 snp2_1 snp3_2
1 1 0 0 1 -9 0 0 0
1 2 0 0 2 -9 2 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

练习3

ped格式是A T C G 的格式转化为0 1 2 这里A A之间有空格

「test3.ped」

代码语言:javascript
复制
1 1 0 0 1  0  A A  T T  G G
1 2 0 0 2  0  G G  0 0  A G
1 3 1 2 1  2  0 0  A T  A G
2 1 0 0 1  0  A A  A T  0 0
2 2 0 0 2  2  G G  T T  0 0
2 3 1 2 1  2  A A  T T  G G

「test3.map」

代码语言:javascript
复制
1 snp1 0 1
1 snp2 0 2
1 snp3 0 3

「plink命令行」

代码语言:javascript
复制
plink --file test3 --recodeA

「结果不变」

代码语言:javascript
复制
FID IID PAT MAT SEX PHENOTYPE snp1_2 snp2_1 snp3_2
1 1 0 0 1 -9 0 0 0
1 2 0 0 2 -9 2 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

练习4

ped格式是AT CG 的格式转化为0 1 2 这里AT之间没有空格

「test3.ped」

代码语言:javascript
复制
1 1 0 0 1  0  AA  TT  GG
1 2 0 0 2  0  GG  00  AG
1 3 1 2 1  2  00  AT  AG
2 1 0 0 1  0  AA  AT  00
2 2 0 0 2  2  GG  TT  00
2 3 1 2 1  2  AA  TT  GG

「test3.map」

代码语言:javascript
复制
1 snp1 0 1
1 snp2 0 2
1 snp3 0 3

「plink命令行」

代码语言:javascript
复制
plink --file test4 --recodeA

「结果不变」

代码语言:javascript
复制
FID IID PAT MAT SEX PHENOTYPE snp1_2 snp2_1 snp3_2
1 1 0 0 1 -9 0 0 0
1 2 0 0 2 -9 2 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

练习5

ped格式是A T 1 2 的格式转化为0 1 2 这里AT和12都包含

「test3.ped」

代码语言:javascript
复制
1 1 0 0 1  0  G G  2 2  C C
1 2 0 0 2  0  A A  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

「test3.map」

代码语言:javascript
复制
1 snp1 0 1
1 snp2 0 2
1 snp3 0 3

「plink命令行」

代码语言:javascript
复制
plink --file test4 --recodeA

「结果不变」

代码语言:javascript
复制
FID IID PAT MAT SEX PHENOTYPE snp1_2 snp2_1 snp3_2
1 1 0 0 1 -9 0 0 0
1 2 0 0 2 -9 2 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

结论

  • 1, ped文件中, SNP的分型是1 1 2 2 还是11 22 还是AA TT 还是 AA 22不影响结果
  • 2, ped文件中, SNP转化为012的标准是, 主等位基因为0, 杂合为1, 次等位基因为2
  • 3, plink命令中, 如果使用--file name, 那么ped和map文件名为: name.ped 和 name.map
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2020-10-29,如有侵权请联系 cloudcommunity@tencent.com 删除

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

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

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

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • .map格式
    • Example
    • .ped格式
      • Example
      • 练习1
      • 练习2
      • 练习3
      • 练习4
      • 练习5
      • 结论
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档