Question: Compare samples in one multisample VCF file
1
gravatar for Alice
4.5 years ago by
Alice290
USA
Alice290 wrote:

Hello biostars!

I was wondering, how to compare a few samples in my multisample vcf file?

Basically, I would like to get a venn diagram, but vcf-compare is working only on multiple vcf files, bcftools stats and plot-vcfstats do not help either (they do not compare positions across the samples).  

I can just split my vcf on three separate files and compare them using the approach described above, but I believe there should be more simple solution.

 

 

snp next-gen • 2.1k views
ADD COMMENTlink modified 4.5 years ago by Pierre Lindenbaum129k • written 4.5 years ago by Alice290
2
gravatar for Pierre Lindenbaum
4.5 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum129k wrote:

Using Bioalcidae and the following script?

var counts={};
while(iter.hasNext()) {
var ctx  = iter.next();
for(var i=0;i< ctx.getNSamples();++i)
    {
    var gi = ctx.getGenotype(i);
    for(var j=i+1;j< ctx.getNSamples();++j)
        {
        var gj = ctx.getGenotype(j);
        if(  gi.sameGenotype(gj) ) {
            var key = gi.getSampleName()+"-"+gj.getSampleName();
            var c= counts[key];
            if(c==null) c=0;
            ++c;
            counts[key]=c;
            }
        }
    }
}

for(var i in counts) {
    out.println("["+i+"]\t"+counts[i]);
    }

run:

gunzip -c input.vcf.gz| java -jar dist-2.0.1/bioalcidae.jar -F vcf -f script.js | column -t

[S1-S10]  35
[S1-S2]   16
[S1-S3]   20
[S10-S2]  16
[S10-S3]  20
[S2-S3]   19
[S1-S4]   16
[S10-S4]  16
[S3-S4]   19
[S2-S4]   15
ADD COMMENTlink modified 23 months ago by RamRS28k • written 4.5 years ago by Pierre Lindenbaum129k

Cool, I did not know about this package! And thanks for the script! I will try it asap.

I also need to get a list of snips themselves. As I believe, I can easily catch them using this file after BioAlcidae.

ADD REPLYlink modified 23 months ago by RamRS28k • written 4.5 years ago by Alice290

It's not a R package. It's a java program.

You should test it before validating my answer :-)

ADD REPLYlink modified 23 months ago by RamRS28k • written 4.5 years ago by Pierre Lindenbaum129k

Ok, I see.

No, I mean I will parse this file into R.

ADD REPLYlink modified 23 months ago by RamRS28k • written 4.5 years ago by Alice290
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 682 users visited in the last hour