# DiffObjects

A generic engine for comparing tree-structured objects

## Overview

Compares two record-oriented files, itemizing specific difference between equivalent records in the two files. Reports both itemized and summarized differences.

### What are the summarized differences and the DiffObjectsWalker?

The GATK contains a summarizing difference engine that compares hierarchical data structures to emit:

• A list of specific differences between the two data structures. This is similar to saying the value in field A in record 1 in file F differences from the value in field A in record 1 in file G.
• A summarized list of differences ordered by frequency of the difference. This output is similar to saying field A in 50 records in files F and G differed.

The GATK contains a private walker DiffObjects that allows you access to the DiffEngine capabilities on the command line. Simply provide the walker with the master and test files and it will emit summarized differences for you.

### Why?

The reason for this system is that it allows you to compare two structured files -- such as BAMs and VCFs -- for common differences among them. This is primarily useful in regression testing or optimization, where you want to ensure that the differences are those that you expect and not any others.

### Input

The DiffObjectsWalker works with BAM or VCF files.

### Output

The DiffEngine system compares to two hierarchical data structures for specific differences in the values of named nodes. Suppose I have two trees:

     Tree1=(A=1 B=(C=2 D=3))
Tree2=(A=1 B=(C=3 D=3 E=4))
Tree3=(A=1 B=(C=4 D=3 E=4))


where every node in the tree is named, or is a raw value (here all leaf values are integers). The DiffEngine traverses these data structures by name, identifies equivalent nodes by fully qualified names (Tree1.A is distinct from Tree2.A, and determines where their values are equal (Tree1.A=1, Tree2.A=1, so they are). These itemized differences are listed as:

     Tree1.B.C=2 != Tree2.B.C=3
Tree1.B.C=2 != Tree3.B.C=4
Tree2.B.C=3 != Tree3.B.C=4
Tree1.B.E=MISSING != Tree2.B.E=4


This conceptually very similar to the output of the unix command line tool diff. What's nice about DiffEngine though is that it computes similarity among the itemized differences and displays the count of differences names in the system. In the above example, the field C is not equal three times, while the missing E in Tree1 occurs only once. So the summary is:

     *.B.C : 3
*.B.E : 1


where the * operator indicates that any named field matches. This output is sorted by counts, and provides an immediate picture of the commonly occurring differences among the files.

Below is a detailed example of two VCF fields that differ because of a bug in the AC, AF, and AN counting routines, detected by the integrationtest integration (more below). You can see that in the although there are many specific instances of these differences between the two files, the summarized differences provide an immediate picture that the AC, AF, and AN fields are the major causes of the differences.

 [testng] path                                                             count
[testng] *.*.*.AC                                                         6
[testng] *.*.*.AF                                                         6
[testng] *.*.*.AN                                                         6
[testng] 64b991fd3850f83614518f7d71f0532f.integrationtest.20:10000000.AC  1
[testng] 64b991fd3850f83614518f7d71f0532f.integrationtest.20:10000000.AF  1
[testng] 64b991fd3850f83614518f7d71f0532f.integrationtest.20:10000000.AN  1
[testng] 64b991fd3850f83614518f7d71f0532f.integrationtest.20:10000117.AC  1
[testng] 64b991fd3850f83614518f7d71f0532f.integrationtest.20:10000117.AF  1
[testng] 64b991fd3850f83614518f7d71f0532f.integrationtest.20:10000117.AN  1
[testng] 64b991fd3850f83614518f7d71f0532f.integrationtest.20:10000211.AC  1
[testng] 64b991fd3850f83614518f7d71f0532f.integrationtest.20:10000211.AF  1
[testng] 64b991fd3850f83614518f7d71f0532f.integrationtest.20:10000211.AN  1
[testng] 64b991fd3850f83614518f7d71f0532f.integrationtest.20:10000598.AC  1


### Caveat

Because this is a walker, it requires that you pass a reference file. However the reference is not actually used, so it does not matter what you pass as reference.

These Read Filters are automatically applied to the data by the Engine before processing by DiffObjects.

### Downsampling settings

This tool applies the following downsampling settings by default.

• Mode: BY_SAMPLE
• To coverage: 1,000

## Command-line Arguments

### Inherited arguments

The arguments described in the entries below can be supplied to this tool to modify its behavior. For example, the -L argument directs the GATK engine restricts processing to specific genomic intervals (this is an Engine capability and is therefore available to all GATK walkers).

### DiffObjects specific arguments

This table summarizes the command-line arguments that are specific to this tool. For more details on each argument, see the list further down below the table or click on an argument name to jump directly to that entry in the list.

Argument name(s) Default value Summary
Required Inputs
--master
-m
NA Master file: expected results
--test
-t
NA Test file: new results to compare to the master file
Optional Outputs
--out
-o
NA File to which results should be written
Optional Parameters
--iterations
1 Number of iterations to perform, should be 1 unless you are doing memory testing
--maxCount1Diffs
-M1
0 Max. number of diffs occuring exactly once in the file to process
--maxDiffs
-M
0 Max. number of diffs to process
-motr
-1 Max. number of objects to read from the files. -1 [default] means unlimited
--maxRawDiffsToSummarize
-1 Max. number of differences to include in the summary. -1 [default] means unlimited
--minCountForDiff
-MCFD
1 Min number of observations for a records to display
Optional Flags
--doPairwise
NA If provided, we will compute the minimum pairwise differences to summary, which can be extremely expensive
--showItemizedDifferences
-SID
NA Should we enumerate all differences between the files?

### Argument details

Arguments in this list are specific to this tool. Keep in mind that other arguments are available that are shared with other tools (e.g. command-line GATK arguments); see Inherited arguments above.

### --doPairwise / -doPairwise

If provided, we will compute the minimum pairwise differences to summary, which can be extremely expensive

boolean

### --iterations / NA

Number of iterations to perform, should be 1 unless you are doing memory testing

int  [ [ -∞  ∞ ] ]

### --master / -m

Master file: expected results
The master file against which we will compare test. This is one of the two required files to do the comparison. Conceptually master is the original file contained the expected results, but this doesn't currently have an impact on the calculations, but might in the future.

R File

### --maxCount1Diffs / -M1

Max. number of diffs occuring exactly once in the file to process
The maximum number of singleton (occurs exactly once between the two files) to display when writing out the summary. Only applies if maxDiffs hasn't been exceeded. For example, if maxDiffs is 10 and maxCount1Diffs is 2 and there are 20 diffs with count > 1, then only 10 are shown, all of which have count above 1.

int  [ [ -∞  ∞ ] ]

### --maxDiffs / -M

Max. number of diffs to process
The max number of differences to display when summarizing. For example, if there are 10M differences, but maxDiffs is 10, then the comparison aborts after first ten summarized differences are shown. Note that the system shows differences sorted by frequency, so these 10 would be the most common between the two files. A value of 0 means show all possible differences.

int  [ [ -∞  ∞ ] ]

Max. number of objects to read from the files. -1 [default] means unlimited
The engine will read at most this number of objects from each of master and test files. This reduces the memory requirements for DiffObjects but does limit you to comparing at most this number of objects

int  [ [ -∞  ∞ ] ]

### --maxRawDiffsToSummarize / -maxRawDiffsToSummarize

Max. number of differences to include in the summary. -1 [default] means unlimited

int  [ [ -∞  ∞ ] ]

### --minCountForDiff / -MCFD

Min number of observations for a records to display
Only differences that occur more than minCountForDiff are displayed. For example, if minCountForDiff is 10, then a difference must occur at least 10 times between the two files to be shown.

int  [ [ -∞  ∞ ] ]

### --out / -o

File to which results should be written
Writes out a file of the DiffEngine format: See http://www.broadinstitute.org/gatk/guide/article?id=1299 for details.

PrintStream

### --showItemizedDifferences / -SID

Should we enumerate all differences between the files?
If provided, the system will write out the summarized, individual differences. May lead to enormous outputs, depending on how many differences are found. Note these are not sorted in any way, so if you have 10M common differences in the files, you will see 10M records, whereas the final summarize will just list the difference and its count of 10M.

boolean

### --test / -t

Test file: new results to compare to the master file
The test file against which we will compare to the master. This is one of the two required files to do the comparison. Conceptually test is the derived file from master, but this doesn't currently have an impact on the calculations, but might in the future.

R File