Question: Compare samples in one multisample VCF file
1
gravatar for Alice
4.8 years ago by
Alice300
USA
Alice300 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.2k views
ADD COMMENTlink modified 4.8 years ago by Pierre Lindenbaum131k • written 4.8 years ago by Alice300
2
gravatar for Pierre Lindenbaum
4.8 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum131k 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 2.2 years ago by _r_am31k • written 4.8 years ago by Pierre Lindenbaum131k

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 2.2 years ago by _r_am31k • written 4.8 years ago by Alice300

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

You should test it before validating my answer :-)

ADD REPLYlink modified 2.2 years ago by _r_am31k • written 4.8 years ago by Pierre Lindenbaum131k

Ok, I see.

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

ADD REPLYlink modified 2.2 years ago by _r_am31k • written 4.8 years ago by Alice300
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: 1288 users visited in the last hour