Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert vcf to plink step missing id setting #1

Open
trptyrphe11 opened this issue Sep 7, 2018 · 4 comments
Open

convert vcf to plink step missing id setting #1

trptyrphe11 opened this issue Sep 7, 2018 · 4 comments

Comments

@trptyrphe11
Copy link

Hi,

I found using the current command will result in all variant id specified as "." in the bim file. Is that wrong? Shall we set variant id manually using the parameter --set-missing-var-ids?

@MareesAT
Copy link
Owner

MareesAT commented Sep 21, 2018 via email

@trptyrphe11
Copy link
Author

trptyrphe11 commented Sep 21, 2018 via email

@MareesAT
Copy link
Owner

MareesAT commented Sep 21, 2018 via email

@ttbek
Copy link

ttbek commented Aug 6, 2019

In general, the best way to convert from VCF to plink is to split multi-allelic sites, left align/normalize, give unique IDs, and then convert. This is described here: http://apol1.blogspot.com/2014/11/best-practice-for-converting-vcf-files.html

The command is:

  bcftools norm -Ou -m -any input.vcf.gz |
  bcftools norm -Ou -f human_g1k_v37.fasta |
  bcftools annotate -Ob -x ID \
    -I +'%CHROM:%POS:%REF:%ALT' |
  plink --bcf /dev/stdin \
    --keep-allele-order \
    --vcf-idspace-to _ \
    --const-fid \
    --allow-extra-chr 0 \
    --split-x b37 no-fail \
    --make-bed \
    --out output

This requires bcftools 1.9 and Plink 1.9 or 2.0 (is still alpha as of Aug 6th, 2019), it also requires you to have the reference genome in fasta format (.fa or .fasta).
Setting the IDs this way also lets you keep track of which is ref vs. alt.

rs numbers as IDs are kind of wonky in general despite being a very common practice, please see the discussion freeseek references in his/her blog post (http://annovar.openbioinformatics.org/en/latest/articles/dbSNP/) written by the author of Annovar.

Normalization is well described here: https://genome.sph.umich.edu/wiki/Variant_Normalization

It's pretty cool that bcftools can be piped that way, but sometimes you want to keep the intermediate files, the tee utility will let you save these, it writes what it gets on standard in to a file while also to standard out for the next pipe, e.g.

echo "Testing, 1, 2, 3..." | tee ./test_file.txt | grep Test

Will both show the output of grep on screen and write "Testing, 1, 2, 3..." to the file test_file.txt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants