Thank you for the response. The goal is to preserve allele order throughout this pipeline. Is there a general reason behind why someone would want to let plink assign major/minor alleles when using merge-x to merge PAR back in? My thought here is that he was really trying to make sure that allele order was kept at the lest step and just let it go at the merging step.
My friend is using plink 1.9, this is a simplified version of what I am reading from someones elses' code
He first reads in a vcf, split pseudoatuosomal regions
plink \
--vcf file.vcf \
--double-id \
--keep-allele-order \
--make-bed \
--split-x hg19 \
--out outname \
zeroes heterozygous haploid calls
plink
--bfile outname \
--keep-allele-order \
--make-bed \
--set-hh-missing \
--out outname_hh_fixed
Merges the PAR back in
plink \
--bfile outname_hh_fixed \
--merge-x \
--make-bed \
--out outname_hh_fixed_merged
Converts the PLINK to VCF
plink \
--bfile outname_hh_fixed_merged \
--keep-allele-order \
--recode vcf-iid \
--real-ref-alleles \
--a2-allele vcfinfo.txt 4 3 0 \
--out final_vcf.vcf
If I understand --keep-allele-order prevents plink from flipping around alleles and preserves the REF allele in the original VCF as A2 (major allele in plink)
I have two questions:
- Why is
--keep-allele-ordernot needed when merging PAR back in? - Why does PLINK need you specify
--keep-allele-orderand--a2-allelewhen writing the VCF in the last step? I think I understand from the documentation that column 4 of vcfinfo.txt will be used as a guide for setting alleles in that column to A2 (or REF in the final_vcf). I am just kind of stumped as to why you would need to supply a column of alleles to designate as A2 if we are already saying--keep-allele-order. Wouldn't the correct order already be baked into the .bim file then? Thank you.
1 answer
- It's okay for the correct REF/ALT allele ordering to be "forgotten" in intermediate steps, as long as the information is recovered in a later step by
--a2-allele. - Every time you run plink 1.x, it'll try to reorder the alleles to A1=minor, A2=major unless you specify
--keep-allele-order. (This looked like a reasonable idea at the time plink 1.0 was written...) So, because--keep-allele-orderwas omitted from the third step, the original REF/ALT ordering is lost there, and it's necessary to use--a2-alleleto recover it when exporting the VCF. With that said,--keep-allele-orderisn't needed in the last command, due to the order of operations (http://www.cog-genomics.org/plink/1.9/order ); the usual allele reordering happens before, not after,--a2-alleleexecutes.
No, there’s no specific reason to leave —keep-allele-order out in step 3. But including —a2-allele once is usually easier than remembering —keep-allele-order everywhere.
--a2-allele <uncompressed VCF filename> 4 3 '#'
Can you share more information about the last "#" in the --a2-allele option?
https://www.cog-genomics.org/plink/1.9/data#ax_allele
https://www.cog-genomics.org/plink/1.9/data#update_map
"The optional fourth 'skip' parameter is either a nonnegative integer, in which case it indicates the number of lines to skip at the top of the file, or a single nonnumeric character, which causes each line with that leading character to be skipped." This is useful because all VCF header lines start with '#'.
Clear!! Thanks Chris!!
Log in to answer this question.
Thank you for the response. The goal is to preserve allele order throughout this pipeline. Is there a general reason behind why someone would want to let plink assign major/minor alleles when using merge-x to merge PAR back in? My thought here is that he was really trying to make sure that allele order was kept at the lest step and just let it go at the merging step.