This is a test version of Biostars. For the public version, visit https://www.biostars.org.
SelectVariant JEXL expression to select private variants from multisample VCF

Dear all,

I have a multi-sample VCF file from which i need to extract shared private variants(variants shared only a specific group) . I have used the below command to find shared variants.

java -Xmx4g -jar GenomeAnalysisTK.jar -T SelectVariants -R ref.fa --variant goodAA.final.vcf -select 'vc.getGenotype("LJ1A2").isHomVar() && vc.getGenotype("LJA3").isHomVar()' > shared.vcf

This gives the shared variants in LJ1A2 and LJA3. And I can use the below expression to find shared private variants

'vc.getGenotype("LJ1A2").isHomVar() && vc.getGenotype("LJA3").isHomVar()  &&  vc.getGenotype("JLA4").isHomRef()'

this gives the shared hom varaints in LJ1A2, LJA3 and REF in JLA4. i.e. shared private hom variants with respect to one control (JLA4).

How can specify all the other samples (100's) in the vcf file to have '.isHomRef()' except those specified to have '.isHomVar' ?

It would be complex to specify each and every sample manually when there are >200 samples. COuld someone suggest a smoother way of doing this by using any wild cards?

gatk jexl

1 answer

try using vcffilterjs https://github.com/lindenb/jvarkit/wiki/VCFFilterJS or picard/FilterVCF using a javascript expression. The script could look like this. (no tested)

function accept(ctx) {
for(var i=0;i< ctx.getNSamples();++i)
{
var g = ctx.getGenotype(i);
var sample = g.getSampleName();
if ( (sample=="LJ1A2"  || sample=="LJA3") && g.isHomVar()) continue;
if( g.isHomRef() || g.isNoCall()) continue;
return false;
}
return true;
}

accept(variant);

Tried to use the above script using vcffilterjs. but the installation failed with long error message with few shown below:

lindenb/jvarkit/util/Pedigree.java:92: error: illegal start of type
    default int compareTo(final Family o) {
    ^/jvarkit/src/main/java/com/github/lindenb/jvarkit/util/Pedigree.java:92: error: = expected
    default int compareTo(final Family o) {
            ^
/jvarkit/src/main/java/com/github/lindenb/jvarkit/util/Pedigree.java:92: error: ';' expected
    default int compareTo(final Family o) {
               ^
/jvarkit/src/main/java/com/github/lindenb/jvarkit/util/Pedigree.java:92: error: illegal start of type
    default int compareTo(final Family o) {
                         ^
/jvarkit/src/main/java/com/github/lindenb/jvarkit/util/Pedigree.java:92: error: <identifier> expected
    default int compareTo(final Family o) {

Then tried with picard, it worked but the output looks wierd which writes all the variants in the input to the output in a different format for the FORMAT columns as shown below:

GT:FT:PL        0/0:LowDP;LowGQ:0,151,3000      0/0:LowDP;LowGQ:0,193,3840

which does not output any private variants.

Could you suggest further.

error: illegal start of type

The manual says : java 1.8 is required. Did you check that ?

Then tried with picard

picard adds an item in the FILTER column.

jvarkit: Yes, i did used Java 8:

`$ java -version
 Picked up _JAVA_OPTIONS: -Xmx10g
 java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

make vcffilterjs`

Picard: Yes, it has AllGtsFiltered and AllGtsFiltered;JavaScript items in FILTER column. Then i picked the variants with AllGtsFiltered in FILTER column . And it does the trick. Thanks!!!

I tried to get heterozygous variants by using if( g.isHomRef() || g.isNoCall() || g.isHetVar()) which is not valid. and could not find a valid expression in the documentation. Any suggestion?

Tried if( g.isHomRef() || g.isNoCall() || g.isHet()) and if( g.isHomRef() || g.isNoCall() || g.isHetNonRef()) . In both cases it worked without any error but all the input variants have AllGtsFiltered which does not make sense. The idea is to have all the other samples to be 0/0 or 0/1 or ./.

g.isHomRef() || g.isNoCall() || g.isHet()

would select ANY genotype but the g.isHomVar()

i did not understand your previous post. The aim is that the selected samples should have 1/1 and the rest can be 0/1 or 0/0 or ./.

could you briefly explain.

Log in to answer this question.