To convert raw DNA data from 23andMe, AncestryDNA, MyHeritage, or FamilyTreeDNA (FTDNA) to PLINK binary format (.bed, .bim, .fam), you will have to first convert the raw file to 23andMe format. You can then convert it with PLINK 1.9 using --23file.


Converting Raw DNA to 23andMe Format with AWK

Windows users can use WSL to access awk; see How to Download the AADR Dataset (Linux & WSL).

If your DNA file is already in 23andMe format, skip this section.

Before running these commands, extract the raw DNA file from its compressed archive (e.g.,.zip or .gz).

FTDNA to 23andMe

The assumed FTDNA format is:

RSID,CHROMOSOME,POSITION,RESULT
"rs4477212","1","82154","--"

Convert it with:

awk -F'[,\t ]+' 'BEGIN{OFS="\t"} NR>1 && NF>=4 {gsub(/"/,""); gsub(/\r/,"",$4); print $1,$2,$3,$4}' input.csv > 23file.txt

AncestryDNA to 23andMe

The assumed AncestryDNA format is tab-separated with five columns. Comment lines beginning with # will be skipped by the command:

rsid	chromosome	position	allele1	allele2
rs3094315	1	752566	A	A

Convert the two allele columns into a single genotype column:

awk -F'\t' 'BEGIN{OFS="\t"} !/^#/ && $1!="rsid" && NF>=5 {gsub(/\r/,"",$5); print $1,$2,$3,$4 $5}' input.txt > 23file.txt

MyHeritage to 23andMe

The assumed MyHeritage format is:

RSID,CHROMOSOME,POSITION,RESULT
rs12564807,1,734462,--

Convert it with:

awk -F',' 'BEGIN{OFS="\t"} $1!="RSID" && NF>=4 {gsub(/^[ \t]+|[ \t\r]+$/,"",$1); gsub(/^[ \t]+|[ \t\r]+$/,"",$4); print $1,$2,$3,$4}' input.txt > 23file.txt

The resulting 23file.txt should contain four tab-separated columns:

rsid	chromosome	position	genotype

A header is not required by PLINK.


For this step, use PLINK 1.9. PLINK 2 currently lists --23file, but it is not implemented.

You can download PLINK 1.9 from the PLINK 1.9 page and select the appropriate binary for your operating system.

Before running the command, make sure the PLINK executable is available in your system PATH. This allows you to run PLINK simply by typing plink in the terminal. Alternatively, move the executable to the directory containing your DNA file and run it from there on Linux, macOS, or WSL:

./plink --23file 23file.txt 0 sample1 1 1 --make-bed --out sample

If PLINK is in your PATH, use:

plink --23file 23file.txt 0 sample1 1 1 --make-bed --out sample

The relevant arguments are:

23file.txt = input file in 23andMe format
0          = family ID (FID)
sample1    = individual ID (IID)
1          = sex: 1 = male, 2 = female, 0 = unknown
1          = 1 means unaffected/control and 2 means affected/case
sample     = output filename prefix

After conversion, you will have the standard PLINK binary dataset:

sample.bed
sample.bim
sample.fam

These files can then be used for downstream PLINK analyses or merged with other compatible PLINK datasets.

Important: This procedure only converts the file format. It does not handle strand orientation. If you plan to merge the result with AADR or another PLINK dataset, you might need to handle or exclude SNPs with strand or allele conflicts. If you prefer an all-in-one solution, see: Convert Raw DNA Files to EIGENSTRAT for ADMIXTOOLS and Merge with AADR.