convert bgen v2 to bgen v1?

776 views
Skip to first unread message

stuart kim

unread,
Aug 6, 2017, 7:19:25 PM8/6/17
to plink2-users
Hi,

I would like to convert a bgen v2 file to bgen v1 (or bed) format to run in Plink1.9.

I used bgenix to do this. The resulting v1-format file runs OK with snptest. But it does not work with Plink1.9. I get an error message "Error: File read failure." 
I also used bgenix to convert bgen v2 to vcf format. Running the vcf genotype file with Plilnk1.9, I get "Error: No #CHROM header line in --vcf file."

Does anyone know how to do get bgen v2 into a format that will run with Plink1.9?

Is there another way to convert bgen v2 to bgen v1 format?
Is there some way to get Plink1.9 to use the bgen v1 format constructed by bgenix?
I can convert bgen v2 to pgen. Is there a way to convert pgen to bed? Plink 1.9 will use bed, so converting pgen to bed will also solve the problem.

thanks.
Stuart




 

Christopher Chang

unread,
Aug 6, 2017, 10:17:17 PM8/6/17
to plink2-users
"plink2 --pfile [.pgen+.pvar+.psam prefix] --make-bed --out ..." downcodes pgen to bed.

stuart kim

unread,
Aug 7, 2017, 1:05:37 PM8/7/17
to plink2-users
Chris, Thanks so much. that worked well. I was stuck for several days until your advice. 

ioanna.ta...@gmail.com

unread,
Oct 26, 2017, 5:42:25 AM10/26/17
to plink2-users
Hi both,

I also get the same error when using bgen v1.1 files in plink1.9 created by bgenix. 
I can't figure out how to convert bgen v2 to pgen though. Can someone help please?

Many thanks!

Best,
Ioanna

Christopher Chang

unread,
Oct 26, 2017, 12:29:14 PM10/26/17
to plink2-users
Hi,

Could you send me a small bgenix file which exhibits the problem you mention on plink 1.9, along with the plink .log file? Thanks.

(Also, can you clarify what you're confused about re: plink 2.0 bgen-1.2 -> pgen conversion?)

ioanna.ta...@gmail.com

unread,
Oct 27, 2017, 6:28:50 AM10/27/17
to plink2-users
Thanks Chris,

I am using the latest UKBiobank release with bgenix to extract specific regions for fine-mapping. An example code is:

bgenix -g ${inpath}/ukb_imp_chr${chr}.HRCvariantsOnly.bgen -incl-range ${chr}:${start}-${end} -v11 > ${outpath}/${trait}_${rsid}_${chr}_${start}_${end}.v1.1.bgen

Plink1.9 complains when I feed it in file ${outpath}/${trait}_${rsid}_${chr}_${start}_${end}.v1.1.bgen.

Regarding pgen, I have not used plink2, perhaps I need it to create this type of data? Does plink2 support bgen1.2, in which case I don't need pgen at all?

Best,
Ioanna

Christopher Chang

unread,
Oct 31, 2017, 2:37:18 AM10/31/17
to plink2-users
1. Yes, plink 2.0 is capable of importing bgen-1.2 data and (unlike plink 1.9) keeping the dosages.
2. However, the dosages must be stored in the new .pgen file format: use --make-pgen where you previously used --make-bed, and use --pfile where you previously used --bfile. If you use --make-bed, the dosages must be thrown away and only hard genotype calls will remain.
3. I don't currently have a UKB test dataset to work with, so it would be great if you could send me a small sample bgen-1.1 file that plink 1.9 can't load, along with the plink 1.9 .log file.

kaku...@gmail.com

unread,
Aug 1, 2018, 10:03:51 AM8/1/18
to plink2-users
Hi Christopher,

You are saying that transforming the BGEN/sample files into bed/bim/fam is incorrect and will lead to wrong results?

Christopher Chang

unread,
Aug 1, 2018, 12:45:24 PM8/1/18
to plink2-users
You'll still get approximately-correct results (unless imputation quality is horrible, anyway), but dosages improve regression accuracy.

kaku...@gmail.com

unread,
Aug 1, 2018, 2:48:35 PM8/1/18
to plink2-users
Thanks for the answer Christopher. I'm wondering what would you recommend me to do with a software called "trinculo" (https://sourceforge.net/projects/trinculo/files/). It accepts as input only plink files (bed/bim/fam) but also dosage files in the following format.
I need to run a gwas using ordinal regression and this is the only software that I've found so far to do it.

sampleID SNP1 SNP2 SNP3 SNP4 SNP5
IND1 0 0 0 0 1
IND2 1 1 0 0 0
IND3 0 1 1 1 0
IND4 2 2 2 0 2
IND5 2 1 1 0 1
IND6 0 0 0 1 1
IND7 0 0 0 1 1
IND8 0 0 1 1 2
IND9 1 1 0 0 1
IND10 0 0 0 1 1

Christopher Chang

unread,
Aug 1, 2018, 3:07:38 PM8/1/18
to plink2-users
plink 2.0's "--export A" command exports dosages to a very similar format; you should be able to convert its output to trinculo's format with a short script.
Reply all
Reply to author
Forward
0 new messages