Answers.Body: <p>Responded in the plink2-users group (<a href="https://groups.google.com/forum/#!topic/plink2-users/zgJxdXxvdLo" rel="nofollow noreferrer">https://groups.google.com/forum/#!topic/plink2-users/zgJxdXxvdLo</a> ).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-16T19:14:15.807Z
Answers.LastActivityDate: 2020-02-16T19:14:15.807Z
Answers.UserDisplayName: Christopher Chang
Body: <p>Plink documentation about <a href="https://www.cog-genomics.org/plink/1.9/formats#bim" rel="nofollow noreferrer">.bim</a> says the columns 5 and 6 are the Allele 1 and Allele 2 respectively. 
  The documentation about the <a href="https://www.cog-genomics.org/plink/1.9/formats#ped" rel="nofollow noreferrer">.ped</a> in turn, says "...The first six fields are the same as those in a .fam file. The seventh and eighth fields are allele calls for the first variant in the .map file ('0' = no call); the 9th and 10th are allele calls for the second variant; and so on.."</p>
  
  <p>I've simulated a dataset as per:</p>
  
  <pre><code><span class="math-container">$ plink1.9 --simulate ds1.sim acgt --out ds1
  ...
  $</span> head ds1.bim 
  1       null_0  0       1       C       T
  1       null_1  0       2       A       C
  1       null_2  0       3       C       A
  1       null_3  0       4       T       A
  1       null_4  0       5       G       C
  1       null_5  0       6       T       C
  1       null_6  0       7       T       C
  1       null_7  0       8       G       C
  1       null_8  0       9       C       G
  1       null_9  0       10      T       A
  </code></pre>
  
  <p>Than I converted it to plain PED and MAP: </p>
  
  <pre><code><span class="math-container">$ plink1.9 --bfile ds1 --recode --out ds1
  ...
  $</span> head ds1.ped &gt; ds1.head.ped
  $ vim ds1.head.ped
  per0 per0 0 0 2 2 T T A C A A T A C C T C T C C C....
  </code></pre>
  
  <p>Given the data above, why my .bim file shows "C and T" for the first variant while my .ped file shows "T and T"?
  Apparently they don't match as per described in the documentation (or more likely, I'm misinterpreting it)...</p>
  
  <p>Also, how do those 2 files related to each other? E.g.: How do I know that my Sample 1 has the SNP's null_3, null_4 or null_5, etc?</p>
  
  <p>I need to clarify those doubt because I want to fit a LightGBM model with the Genomic Data (can be plink or vcf). Not sure yet how to do. I was trying to convert the plink files to a CSV-style somehow, to be able to use in my model. Not sure if this is the way to go though... </p>
  
  <p>Thanks!</p>
  
Tags: <machine-learning><plink>
Title: Why my bim file doesn't match to my ped file as the Plink documentation suggests?
ThreadText: # Why my bim file doesn't match to my ped file as the Plink documentation suggests?
  
  (Asked by: username_0 on 2020-02-15)
  
  Plink documentation about [.bim](https://www.cog-genomics.org/plink/1.9/formats#bim) says the columns 5 and 6 are the Allele 1 and Allele 2 respectively.
  The documentation about the [.ped](https://www.cog-genomics.org/plink/1.9/formats#ped) in turn, says "...The first six fields are the same as those in a .fam file. The seventh and eighth fields are allele calls for the first variant in the .map file ('0' = no call); the 9th and 10th are allele calls for the second variant; and so on.."
  
  I've simulated a dataset as per:
  
  ```
  $ plink1.9 --simulate ds1.sim acgt --out ds1
  ...
  $ head ds1.bim 
  1       null_0  0       1       C       T
  1       null_1  0       2       A       C
  1       null_2  0       3       C       A
  1       null_3  0       4       T       A
  1       null_4  0       5       G       C
  1       null_5  0       6       T       C
  1       null_6  0       7       T       C
  1       null_7  0       8       G       C
  1       null_8  0       9       C       G
  1       null_9  0       10      T       A
  
  ```
  
  Than I converted it to plain PED and MAP:
  
  ```
  $ plink1.9 --bfile ds1 --recode --out ds1
  ...
  $ head ds1.ped > ds1.head.ped
  $ vim ds1.head.ped
  per0 per0 0 0 2 2 T T A C A A T A C C T C T C C C....
  
  ```
  
  Given the data above, why my .bim file shows "C and T" for the first variant while my .ped file shows "T and T"?
  Apparently they don't match as per described in the documentation (or more likely, I'm misinterpreting it)...
  
  Also, how do those 2 files related to each other? E.g.: How do I know that my Sample 1 has the SNP's null\_3, null\_4 or null\_5, etc?
  
  I need to clarify those doubt because I want to fit a LightGBM model with the Genomic Data (can be plink or vcf). Not sure yet how to do. I was trying to convert the plink files to a CSV-style somehow, to be able to use in my model. Not sure if this is the way to go though...
  
  Thanks!
  
  **Tags:** machine-learning, plink
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-02-16. Score: 2 | Accepted answer
  
  Responded in the plink2-users group (<https://groups.google.com/forum/#!topic/plink2-users/zgJxdXxvdLo> ).
  
  
  ---
  
  