thanks for following up!
I have a dataset in PLINK binary format (bed/bim/fam) and this contains unrelated and related (family) individuals.
The FAM file looks like the following:
1553 1553_10 0 0 1 2
1553 1553_03 0 0 2 1
1555 1555_14 0 0 2 1
2001 2001_05 0 0 2 2
1558 1558_05 0 0 2 2
1559 1559_09 0 0 1 1
1021 1021_07 0 0 1 2
1021 1021_09 0 0 1 2
1555 1555_03 0 0 2 2
I need to create a dataset where the IDs are ordered and individuals from the same family appear one after another. Frr this, I think I just need to sort the IDs and create a new plink binary file i.e. the new file should have this as the order of IDs.
1021 1021_07 0 0 1 2
1021 1021_09 0 0 1 2
1553 1553_10 0 0 1 2
1553 1553_03 0 0 2 1
1555 1555_03 0 0 2 2
1555 1555_14 0 0 2 1
1558 1558_05 0 0 2 2
1559 1559_09 0 0 1 1
2001 2001_05 0 0 2 2
I can't seem to get the right option to do this in PLINK.
Thanks,
1 answer
Firstly, sorry for the bad format. Thanks for the edit.
I couldn't find a way to re-order in PLINK. I did solve this problem, but not sure if this is the best way.
a) I sorted the FAM file, kept FID and IID and generated a variable to identify families. I used that variable in a for loop to split the dataset into unique families and save each in a different text file (same format we need "--keep" option in PLINK.).
b) Ran PLINK using a loop to generate PLINK files (bed/bim/fam) for each family.
c) Merged them back together by creating a merge list and using the "----merge-list" option in PLINK.
Log in to answer this question.
Edited to correct the formatting. Please indent lines of data with 4 spaces. Note that questions are previewed as you type, so you can see when things look right.