Skip to content

convert vcf to plink step missing id setting #1

Open

Description

@trptyrphe11

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?

Activity

  1. MareesAT commented on Sep 21, 2018

    @MareesAT
    Owner
  2. trptyrphe11 commented on Sep 21, 2018

    @trptyrphe11
    Author
  3. MareesAT commented on Sep 21, 2018

    @MareesAT
    Owner
  4. ttbek commented on Aug 6, 2019

    @ttbek

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions