Skip to contents

comparison objects are collections of similarities between two DNA segments. These functions are class functions to create, convert, and test comparison objects.

Usage

comparison(x)

as.comparison(df)

is.comparison(comparison)

Arguments

x

An object to be coerced. Can be a list, data.frame or data.table object. See details for necessary columns.

df

Same as x.

comparison

An object to test.

Value

as.comparison and comparison both return a comparison object.

is.comparison returns a logical.

Details

A comparison object requires at least the start1, end1, start2, and end2 columns. A color can be provided as well using the col column. Additional numeric columns can be used for color-coding using [gradient_color_scheme], or the "gradient" color scheme in the global_color_scheme argument in [plot_gene_map].

These objects inherit from data.table, and can therefore be manipulated using data.table syntax.

is.comparison returns TRUE if the object tested is a comparison object.

Author

Lionel Guy

Examples

## Get some values
starts1 <- c(2, 1000, 1050)
ends1 <- c(600, 800, 1345)
starts2 <- c(50, 800, 1200)
ends2 <- c(900, 1100, 1322)

## From a data.frame
comparison1 <- as.comparison(data.frame(start1 = starts1, end1 = ends1,
                                        start2 = starts2, end2 = ends2))
print_comparison(comparison1)
#>    start1  end1 start2  end2 direction
#>     <num> <num>  <num> <num>     <num>
#> 1:      2   600     50   900         1
#> 2:   1000   800    800  1100        -1
#> 3:   1050  1345   1200  1322         1
is.comparison(comparison1)
#> [1] TRUE
is.data.frame(comparison1)
#> [1] TRUE
print_comparison(data.frame(start1 = starts1, end1 = ends1,
                            start2 = starts2, end2 = ends2))
#>    start1  end1 start2  end2
#>     <num> <num>  <num> <num>
#> 1:      2   600     50   900
#> 2:   1000   800    800  1100
#> 3:   1050  1345   1200  1322

## From a list
print_comparison(list(start1 = starts1, end1 = ends1,
                      start2 = starts2, end2 = ends2))
#>    start1  end1 start2  end2
#>     <num> <num>  <num> <num>
#> 1:      2   600     50   900
#> 2:   1000   800    800  1100
#> 3:   1050  1345   1200  1322


## Printing out a comparison like this can occasionally throw an error:
if (FALSE) { # \dontrun{
comparison1
print(comparison1)
} # }
## This can happen when print.comparison is loaded from the testthat package
## To avoid this, use print_comparison as shown above