This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extract specific variants from binary plink files

Hi, I have plink binary file (mydata.ped, mydata.fam, and mydata.bim). Using this data I need to create a file that will contain all patients with two APOE variants. Ideally this file willl be in a text format and will contain patients identifier (IID and/or FID) and two APOE variants. However, I do not know how to do it. I will be very grateful for any advice. Many thanks. O

snp gene plink

1 answer

Create a file called, for example, snps.txt with the list of SNPs you want to extract and then run

plink \
 --bed mydata.bed \
 --bim mydata.bim \
 --fam mydata.fam \
 --extract snps.txt \
 --make-bed \
 --out mydata_subset

Hi, Thank you so much for this. It is so helpful. I have just tried to run this and I get the following error:

Error: No variants remaining after --extract.

I am a bit puzzled by this as I have more than 20M variants. I would have thought it would be extremely unlikely if the Apoe variants are not among them. I will be grateful for any thought regarding this.

Check using grep in the bim file (chr19)

grep "rs7412" mydata.bim

Hi, Thank you so much for your help. I have checked with grep and the APOE does not appear to be among my variants (even though I have more than 20M of them (imputed)). Is it possible that there is something incorrect with my data?

By the way, even when I run this command for a variant that I know is present in my data, I get the same error. Perhaps there is another way of constructing the text format and will contain patients identifier (IID and/or FID) and APOE. Many thanks in advance

check in the log if its really reading the variants in the snps.txt file

It has worked! Thank you so much for your advice and patience :)

Log in to answer this question.