Skip to content
Pierre Lindenbaum edited this page Mar 26, 2015 · 13 revisions

##Motivation

Compare two VCFs and print common/exclusive information for each sample/genotype

##Compilation

See also Compilation.

$  make vcfcomparecallers

##Synopsis

$ java -jar dist/vcfcomparecallers.jar file1.vcf(.gz) stdin 
$ java -jar dist/vcfcomparecallers.jar file1.vcf(.gz) file2.vcf(.gz) 

##Options

Option Description
-o (filename) output file. default:stdout
-e (filename.xml) Save some examples of variant/genotype in each category. Optional
-n (int) Number of example to save with option '-e '
-h get help (this screen) and exit.
-v print version and exit.
-L (level) log level. One of java.util.logging.Level . Optional.

##Source Code

Main code is: https://github.com/lindenb/jvarkit/blob/master/src/main/java/com/github/lindenb/jvarkit/tools/vcfcmp/VcfCompareCallers.java

##Example

$ java -jar dist-1.128/vcfcomparecallers.jar  Proj1.samtools.vcf.gz  Proj1.varscan.vcf.gz
#Sample	unique_to_file_1	unique_to_file_1_snp	unique_to_file_1_indel	unique_to_file_2	unique_to_file_2_snp	unique_to_file_2_indel	common	common_snp	common_indel	called_and_same	called_but_discordant
NA12892	5	4	1	1	0	1	14	14	0	14	0
NA12891	4	3	1	1	0	1	13	13	0	13	0
NA12878	3	2	1	1	0	1	13	13	0	13	0
$ java -jar dist-1.128/vcfcomparecallers.jar  Proj1.samtools.vcf.gz  Proj1.varscan.vcf.gz | verticalize

>>> 2
$1                  #Sample : NA12892
$2         unique_to_file_1 : 5
$3     unique_to_file_1_snp : 4
$4   unique_to_file_1_indel : 1
$5         unique_to_file_2 : 1
$6     unique_to_file_2_snp : 0
$7   unique_to_file_2_indel : 1
$8                   common : 14
$9               common_snp : 14
$10            common_indel : 0
$11         called_and_same : 14
$12   called_but_discordant : 0
<<< 2

>>> 3
$1                  #Sample : NA12891
$2         unique_to_file_1 : 4
$3     unique_to_file_1_snp : 3
$4   unique_to_file_1_indel : 1
$5         unique_to_file_2 : 1
$6     unique_to_file_2_snp : 0
$7   unique_to_file_2_indel : 1
$8                   common : 13
$9               common_snp : 13
$10            common_indel : 0
$11         called_and_same : 13
$12   called_but_discordant : 0
<<< 3

>>> 4
$1                  #Sample : NA12878
$2         unique_to_file_1 : 3
$3     unique_to_file_1_snp : 2
$4   unique_to_file_1_indel : 1
$5         unique_to_file_2 : 1
$6     unique_to_file_2_snp : 0
$7   unique_to_file_2_indel : 1
$8                   common : 13
$9               common_snp : 13
$10            common_indel : 0
$11         called_and_same : 13
$12   called_but_discordant : 0
<<< 4

Examples

the following XSLT stylesheet can be used to produce a HTML table for a few differences:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
  <xsl:output method="xml"/>
  <xsl:template match="/">
  	<table>
  	<thead>
  		<tr><th>Category</th><th>Sample</th><th>Variant 1</th><th>Genotype 1</th><th>Variant 2</th><th>Genotype 2</th></tr>
  	</thead>
  	<tbody>
    <xsl:apply-templates select="compare-callers/diff">
    	 <xsl:sort select="@sample" />
    	 <xsl:sort select="@type" /> 
    </xsl:apply-templates>
    </tbody>
    </table>
  </xsl:template>
  
  <xsl:template match="diff">
  	<tr>
  		<td><xsl:value-of select="@type"/></td>
  		<td><xsl:value-of select="@sample"/></td>
  		<td><xsl:apply-templates select="variant[@file='1']"/></td>
  		<td><xsl:apply-templates select="variant[@file='1']/genotype"/></td>
  		<td><xsl:apply-templates select="variant[@file='2']"/></td>
  		<td><xsl:apply-templates select="variant[@file='2']/genotype"/></td>
  	</tr>
  	<xsl:text>
</xsl:text>
  </xsl:template>
 
   <xsl:template match="variant">
    <xsl:value-of select="concat('(',@type,') ',chrom,':',pos,' ',id,' ',ref,'/',alts)"/>
   </xsl:template>
 
  <xsl:template match="genotype">
  	<xsl:value-of select="concat('(',@type,')')"/>
  	<xsl:for-each select="allele">
  	<xsl:if test="position()>1">/</xsl:if>
  	<xsl:value-of select="."/>
  	</xsl:for-each>
  	<xsl:if test="dp"> DP:<xsl:value-of select="dp"/></xsl:if>
   </xsl:template>
 

 
</xsl:stylesheet>

Contribute

##See also

##History

  • 2015 : Creation

License

The project is licensed under the MIT license.

Clone this wiki locally