Calculates the complement to the intervals covered by the intervals in a data frame. It can optionally take a chromosome_size data frame that contains 2 or 3 columns, the first the names of chromosome and in case there are 2 columns the size or first the start index and lastly the end index on the chromosome.

genome_complement(x, chromosome_size = NULL, by = NULL)

Arguments

x

A data frame for which the complement is calculated

chromosome_size

A dataframe with at least 2 columns that contains first the chromosome name and then the size of that chromosome. Can be NULL in which case the largest value per chromosome from x is used.

by

A character vector with 3 entries which are the chromosome, start and end column. For example: by=c("chr", "start", "end")

Examples

library(dplyr) x1 <- data.frame(id = 1:4, bla=letters[1:4], chromosome = c("chr1", "chr1", "chr2", "chr1"), start = c(100, 200, 300, 400), end = c(150, 250, 350, 450)) genome_complement(x1, by=c("chromosome", "start", "end"))
#> # A tibble: 4 x 3 #> chromosome start end #> <fct> <int> <int> #> 1 chr1 1 99 #> 2 chr1 151 199 #> 3 chr1 251 399 #> 4 chr2 1 299