tidygenomics (version 0.1.2)

genome_intersect: Intersect data frames based on chromosome, start and end.

Description

Intersect data frames based on chromosome, start and end.

Usage

genome_intersect(x, y, by = NULL, mode = "both")

Arguments

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: by=c("Chromosome"="chr", "Start"="start", "End"="end")

mode

One of "both", "left", "right" or "anti".

Value

The intersected dataframe of x and y with the new boundaries.

Examples

Run this code
# NOT RUN {
library(dplyr)

x1 <- data.frame(id = 1:4, bla=letters[1:4],
                 chromosome = c("chr1", "chr1", "chr2", "chr2"),
                 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", "chr2", "chr1"),
                 start = c(140, 210, 400, 300),
                 end = c(160, 240, 415, 320))
j <- genome_intersect(x1, x2, by=c("chromosome", "start", "end"), mode="both")
print(j)



# }

Run the code above in your browser using DataLab