setoptsMC-methods: Perform set operations retaining mcols

setoptsMCR Documentation

Perform set operations retaining mcols

Description

Perform set operations retaining all mcols from the query range

Usage

setdiffMC(x, y, ...)

intersectMC(x, y, ...)

unionMC(x, y, ...)

## S4 method for signature 'GRanges,GRanges'
setdiffMC(x, y, ignore.strand = FALSE, simplify = TRUE, ...)

## S4 method for signature 'GRanges,GRanges'
intersectMC(x, y, ignore.strand = FALSE, simplify = TRUE, ...)

## S4 method for signature 'GRanges,GRanges'
unionMC(x, y, ignore.strand = FALSE, simplify = TRUE, ...)

Arguments

x, y

GenomicRanges objects

...

Not used

ignore.strand

If set to TRUE, then the strand of x and y is set to "*" prior to any computation.

simplify

logical(1) If TRUE, any List columns will be returned as vectors where possible. This can only occur if single, unique entries are present in all initial elements.

Details

This extends the methods provided by setdiff, intersect and union so that mcols from x will be returned as part of the output.

Where output ranges map back to multiple ranges in x, CompressedList columns will be returned. By default, these will be simplified if possible, however this behaviour can be disabled by setting simplify = FALSE.

All columns will be returned which can also be time-consuming. A wise approach is to only provide columns you require as part of the query ranges x.

If more nuanced approaches are required, the returned columns can be further modified by many functions included in the plyranges package, such as mutate().

Value

A GRanges object with all mcols returned form the original object. If a range obtained by setdiff maps back to two or more ranges in the original set of Ranges, mcols will be returned as CompressedList columns

Examples

x <- GRanges("chr1:1-100:+")
x$id <- "range1"
y <- GRanges(c("chr1:51-60:+", "chr1:21-30:-"))
setdiffMC(x, y)
setdiffMC(x, y, ignore.strand = TRUE)

# The intersection works similarly
intersectMC(x, y)

# Union may contain ranges not initially in x
unionMC(x, y)
unionMC(x, y, ignore.strand = TRUE)



steveped/chipExtra documentation built on May 2, 2024, 12:11 p.m.