Skip to contents

Calculate the range of dna_seg, comparison or annotation objects.

Usage

# S3 method for class 'annotation'
range(x, ...)

# S3 method for class 'comparison'
range(x, overall = TRUE, ...)

# S3 method for class 'dna_seg'
range(x, ...)

Arguments

x

An object to calculate the range from.

...

Unused.

overall

Used only when x is a comparison object, a logical. If FALSE, will calculate the range of each side separately instead of calculating the overall range of x.

Value

A numeric of length 2, unless x is a comparison object and overall is FALSE, in which case it will be a data.frame object with two rows and two named columns, xlim1 and xlim2

Author

Lionel Guy

Examples

## Create dna_segs and comparison
df1 <- data.frame(name = c("feat1", "feat2", "feat3"),
                  start = c(2, 1000, 1050),
                  end = c(600, 800, 1345),
                  strand = c(-1, -1, 1))
df2 <- data.frame(name = c("feat1", "feat2", "feat3"),
                  start = c(50, 800, 1200),
                  end = c(900, 1100, 1322),
                  strand = c(-1, 1, 1))
dna_seg1 <- dna_seg(df1)
dna_seg2 <- dna_seg(df2)
df3 <- data.frame(start1 = dna_seg1$start,
                  end1 = dna_seg1$end,
                  start2 = dna_seg2$start,
                  end2 = dna_seg2$end)
comparison1 <- comparison(df3)

## Range calculation
range(dna_seg1)
#> [1]    2 1345
range(comparison1)
#> [1]    2 1345
range(comparison1, overall = FALSE)
#>   xlim1 xlim2
#> 1     2    50
#> 2  1345  1322