How to get nonvariant sites without the ref N sites.

I'm trying to get a vcf with the invariant sites i.e. select out ONLY the homozygous references sites in a multi-sample vcf (samples are either all 0/0 or a mix of 0/0 and ./.). I do not want the sites where the reference is N or all the sites are ./. (before filtering)

Is the only way to do this:
VariantFiltration with a filter QUAL > -1 (to remove the reference N sites)
Then
selectVariants with --selectTypeToInclude NO_VARIATION

Best Answer

  • prepagamprepagam
    Accepted Answer

    Thanks for that - I hadn't know of VcfFilter. I was kind of hoping for a GaTK solution.
    I had assumed I needed to do this in the variant filtration step, but I did find in SelectVariants just now
    --maxNOCALLfraction
    And I can use that I think.

Answers

  • lindenblindenb FranceMember ✭✭

    using vcffilterjdk ( http://lindenb.github.io/jvarkit/VcfFilterJdk.html ) , the following expression should work:

     java -jar dist/vcffilterjdk.jar  -e 'return !variant.getReference().getDisplayString().equals("N") && !variant.getGenotypes().stream().anyMatch(G->G.getAlleles().stream().anyMatch(A->A.isCalled() && !A.isReference())) && variant.getGenotypes().stream().anyMatch(G->G.getAlleles().stream().anyMatch(A->A.isReference())); '  input.vcf
    
  • prepagamprepagam Member
    Accepted Answer

    Thanks for that - I hadn't know of VcfFilter. I was kind of hoping for a GaTK solution.
    I had assumed I needed to do this in the variant filtration step, but I did find in SelectVariants just now
    --maxNOCALLfraction
    And I can use that I think.

  • SheilaSheila Broad InstituteMember, Broadie, Moderator admin

    @prepagam
    Hi,

    I think you can use SelectVariants with --excludeNonVariants. That will only output the sites which have variants. Then, you can use --discordance with that VCF against the original to get the sites with no variants.

    I hope that helps. I just tested it on a one sample VCF, and it seems to work. I hope it works on multi-sample VCFs too :smiley:

    -Sheila

Sign In or Register to comment.