R/subtract.R
genome_subtract.Rd
Subtract one data frame from another based on chromosome, start and end.
genome_subtract(x, y, by = NULL)
x | A dataframe. |
---|---|
y | A dataframe. |
by | A character vector with 3 entries which are used to match the chromosome, start and end column.
For example: |
The subtracted dataframe of x
and y
with the new boundaries.
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)) x2 <- data.frame(id = 1:4, BLA=LETTERS[1:4], chromosome = c("chr1", "chr2", "chr1", "chr1"), start = c(120, 210, 300, 400), end = c(125, 240, 320, 415)) j <- genome_subtract(x1, x2, by=c("chromosome", "start", "end")) print(j)#> id bla chromosome start end #> 1 1 a chr1 100 119 #> 2 1 a chr1 126 150 #> 3 2 b chr1 200 250 #> 4 3 c chr2 300 350 #> 5 4 d chr1 416 450