Answers.Body: <p>Thanks Christopher Chang for the great answer via the plink2 google group! (See <a href="https://groups.google.com/forum/#!topic/plink2-users/QGBJ_Xn62Uk" rel="nofollow noreferrer">here</a>)</p>
  
  <p>His answer was as follows:</p>
  
  <p>"Yes, plink 1.9 did change the default merged sample order.  However, you can request plink 1.07’s behavior by adding “--indiv-sort 0” during the merge.  (You can also use --indiv-sort + --make-bed at any time to change the sample order to whatever you want.)</p>
  
  <p>As for why the default was changed, take a look at the new default order: it will probably make a lot of sense.  It’s “natural-sorted” which tends to make it easy for humans to manually search through regardless of what mix of letters and numbers are used in the IDs."</p>
  
  <p>See also the Plink 1.9 documentation for <a href="https://www.cog-genomics.org/plink/1.9/data#indiv_sort" rel="nofollow noreferrer">--indiv-sort</a> which makes the point that this behavior is default only for merges--in other commands Plink 1.9 uses the same ordering as in Plink 1.07, which is the order the samples were in.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-28T07:14:10.973Z
Answers.LastActivityDate: 2019-03-04T18:37:04.523Z
Answers.LastEditDate: 2019-03-04T18:37:04.523Z
Answers.UserDisplayName: Sarah
Body: <p>I am doing some whole-genome sequence analysis and to speed things up split the data into chromosomes and also into regions within those chromosomes. (So I have my dataset split into ~300ish files) I am doing some IBD analysis with plink files and to do this IBD analysis I am combining the files into one big plink file. </p>
  
  <p>I ran into issues today where when using plink 1.9 and the --bfile and --merge-list commands, the output fam file is different from the input fam file.  My dataset has related individuals so the fam file is very important.  Also its is important to note that when using binary files the order in the fam file needs to be exactly the same as the order the individuals appear in the other files (I learned this the hard way haha).</p>
  
  <p>Does anyone know why plink 1.9 changes the order in the fam file when merging plink files, and how to fix this?  It works with plink 1.07 but with 1.9 I get a different fam file.</p>
  
  <p>Performing "diff" on input and output fam files shows they are different:</p>
  
  <pre><code>plink=$mydir/bin/plink_1_9/plink
  
  <span class="math-container">$plink --noweb --bfile $</span>indir/chr22/285/<span class="math-container">$prefix.chr.22.region.285.qc --merge-list $</span>indir/chr22/merge_list.txt --make-bed --out <span class="math-container">$indir/chr22/$</span>prefix.chr.22.qc
  </code></pre>
  
  <p>Using the same code but using plink-1.07 creates matching fam files as expected"</p>
  
  <pre><code>plink1=bin/plink-1.07-x86_64/plink
  $plink1 --noweb --bfile $indir/chr22/285/$prefix.chr.22.region.285.qc --merge-list $indir/chr22/merge_list.txt --make-bed --out $indir/chr22/$prefix.chr.22.qc
  </code></pre>
  
  <p>The merge_list.txt file is in this format:</p>
  
  <pre><code>$indir/chr22/286/$prefix.chr.22.region.286.qc.bed $indir/chr22/286/$prefix.chr.22.region.286.qc.bim $indir/chr22/286/$prefix.chr.22.region.286.qc.fam
  $indir/chr22/287/$prefix.chr.22.region.287.qc.bed $indir/chr22/287/$prefix.chr.22.region.287.qc.bim $indir/chr22/287/$prefix.chr.22.region.287.qc.fam
  $indir/chr22/288/$prefix.chr.22.region.288.qc.bed $indir/chr22/288/$prefix.chr.22.region.288.qc.bim $indir/chr22/288/$prefix.chr.22.region.288.qc.fam
  </code></pre>
  
  <p>Can someone explain to me why this could be happening and if there is a way to fix it? Thanks so much!!</p>
  
  <p>(Note, I know I can manually replace the fam file with the correct one with cp or mv, but I would like to know how to handle this with plink 1.9, if possible, as I am afraid it could be indicative of an underlying error in the merge process :) )</p>
  
Tags: <plink><wgs>
Title: Plink 1.9 --merge-list changing order of fam file
ThreadText: # Plink 1.9 --merge-list changing order of fam file
  
  (Asked by: username_0 on 2019-02-28)
  
  I am doing some whole-genome sequence analysis and to speed things up split the data into chromosomes and also into regions within those chromosomes. (So I have my dataset split into ~300ish files) I am doing some IBD analysis with plink files and to do this IBD analysis I am combining the files into one big plink file.
  
  I ran into issues today where when using plink 1.9 and the --bfile and --merge-list commands, the output fam file is different from the input fam file. My dataset has related individuals so the fam file is very important. Also its is important to note that when using binary files the order in the fam file needs to be exactly the same as the order the individuals appear in the other files (I learned this the hard way haha).
  
  Does anyone know why plink 1.9 changes the order in the fam file when merging plink files, and how to fix this? It works with plink 1.07 but with 1.9 I get a different fam file.
  
  Performing "diff" on input and output fam files shows they are different:
  
  ```
  plink=$mydir/bin/plink_1_9/plink
  
  $plink --noweb --bfile $indir/chr22/285/$prefix.chr.22.region.285.qc --merge-list $indir/chr22/merge_list.txt --make-bed --out $indir/chr22/$prefix.chr.22.qc
  
  ```
  
  Using the same code but using plink-1.07 creates matching fam files as expected"
  
  ```
  plink1=bin/plink-1.07-x86_64/plink
  $plink1 --noweb --bfile $indir/chr22/285/$prefix.chr.22.region.285.qc --merge-list $indir/chr22/merge_list.txt --make-bed --out $indir/chr22/$prefix.chr.22.qc
  
  ```
  
  The merge\_list.txt file is in this format:
  
  ```
  $indir/chr22/286/$prefix.chr.22.region.286.qc.bed $indir/chr22/286/$prefix.chr.22.region.286.qc.bim $indir/chr22/286/$prefix.chr.22.region.286.qc.fam
  $indir/chr22/287/$prefix.chr.22.region.287.qc.bed $indir/chr22/287/$prefix.chr.22.region.287.qc.bim $indir/chr22/287/$prefix.chr.22.region.287.qc.fam
  $indir/chr22/288/$prefix.chr.22.region.288.qc.bed $indir/chr22/288/$prefix.chr.22.region.288.qc.bim $indir/chr22/288/$prefix.chr.22.region.288.qc.fam
  
  ```
  
  Can someone explain to me why this could be happening and if there is a way to fix it? Thanks so much!!
  
  (Note, I know I can manually replace the fam file with the correct one with cp or mv, but I would like to know how to handle this with plink 1.9, if possible, as I am afraid it could be indicative of an underlying error in the merge process :) )
  
  **Tags:** plink, wgs
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-02-28. Score: 3 | Accepted answer
  
  Thanks Christopher Chang for the great answer via the plink2 google group! (See [here](https://groups.google.com/forum/#!topic/plink2-users/QGBJ_Xn62Uk))
  
  His answer was as follows:
  
  "Yes, plink 1.9 did change the default merged sample order. However, you can request plink 1.07’s behavior by adding “--indiv-sort 0” during the merge. (You can also use --indiv-sort + --make-bed at any time to change the sample order to whatever you want.)
  
  As for why the default was changed, take a look at the new default order: it will probably make a lot of sense. It’s “natural-sorted” which tends to make it easy for humans to manually search through regardless of what mix of letters and numbers are used in the IDs."
  
  See also the Plink 1.9 documentation for [--indiv-sort](https://www.cog-genomics.org/plink/1.9/data#indiv_sort) which makes the point that this behavior is default only for merges--in other commands Plink 1.9 uses the same ordering as in Plink 1.07, which is the order the samples were in.
  
  
  ---
  
  