This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to extract a subset of samples from plink .bed files

Hello. I am trying to extract data from .bed file using the following command:

./plink_linux_i686_20200616/plink --bed study.bed --bim study.bim --fam study.fam --keep-fam ii.txt --make-bed --out ii

It works for affected samples, but when I try to do the same for controls it says that there are 0 samples left after filtration. Could it be because the order of control samples is different in --keep-fam txt file and fam file itself? The order of affected samples and samples in txt file matches.

plink ped bed

Order does not matter.

If you need help figuring out what happened, please post the .log file from the problematic run, along with the top lines from your .fam file and the —keep-fam file you used.

Here is the plink log from problematic run.

 PLINK v1.90b6.18 32-bit (16 Jun 2020) Options in effect:   --bed
 study.bed   --bim study.bim   --fam study.fam   --keep-fam
 controls_ii.txt   --make-bed   --out controls_ii

 Hostname: aydar-XPS-13-9360 Working directory:
 /home/aydar/Documents/khrunin Start time: Wed Sep 16 17:39:18 2020

 Random number seed: 1600267158 15775 MB RAM detected; reserving 2047
 MB for main workspace. 714238 variants loaded from .bim file. 144
 people (69 males, 74 females, 1 ambiguous) loaded from .fam. Ambiguous
 sex ID written to controls_ii.nosex . 96 phenotype values loaded from
 .fam. Error: No people remaining after --keep-fam.

 End time: Wed Sep 16 17:39:19 2020

Here is the top of the fam file:

204171650105_R01C01 061-ii-1 0 0 2 2
204171650105_R01C02 075-ii-1 0 0 1 2
204171650105_R02C01 062-ii-1 0 0 1 2
204171650105_R02C02 077-ii-1 0 0 1 2
204171650105_R03C01 063-ii-1 0 0 1 2

here is --keep-fam txt:

2041171650112_R01C01
2041171650112_R02C01
2041171650112_R03C01
2041171650112_R04C01
2041171650112_R05C01

Look closely at your --keep-fam file. The IDs are slightly off: "204117..." instead of "20417...".

Thanks, but at the top of the fam file are IDs that I already extracted. IDs that I need are somewhere in the middle.

The number of digits is different. From what you have posted, there is every reason to believe you made a mistake creating this --keep-fam file, and your problem will go away when you fix that mistake.

0 answers

No answers yet.

Log in to answer this question.