splitplink-genomics

How do I split my bed bim and fam files by family ID in plink?


I want to split my bed, bim and fam files by family ID in plink. For example, I can do this by chromosome by typing:

plink --bfile datafile1 --chr 1 --make-bed --out datafile2

And that makes a separate bed, bim and fam file for chromosome 1.

However, in my fam file, I have several different family IDs that I want to split the files by. For example

Family 1 TS11339 0 0 2 -9
Family 1 TS11233 0 0 2 -9
Family 2 TF99288 0 0 2 -9
Family 2 YJ22997 0 0 2 -9
Family 3 YF00277 0 0 2 -9
Family 3 YY92779 0 0 2 -9

I want to have Family1.bed -.bim and -.bam, Family2.bed -.bim and -.bam etc.

How can I do this? (Sorry for poor knowledge - just started using plink).


Solution

  • I figured it out, you can do it via plink as follows:

    p-link --bfile datafile1 --keep LIST1.txt --make-bed --out

    Where LIST1.txt is a list of family ID's and individuals. So say if you wanted to extract Family 1, LIST1.txt would consist of:

    Family 1 TS11339

    Family 1 TS11233

    More information can be found at the plink website.