Skip to contents

Narrow a RangedTupleList collection to an analysis window: elements that do not overlap it are dropped, and the survivors are trimmed to the overlapping variants. Elements that trim to zero variants are dropped too.

Usage

subsetRegion(x, region, ...)

# S4 method for class 'RangedTupleList'
subsetRegion(x, region, ...)

Arguments

x

A RangedTupleList collection.

region

A GRanges, a "chr:start-end" string, or a one-row data.frame with chrom / start / end.

...

Additional arguments passed to methods. Fine-mapping collections accept adjust to renormalize PIPs over the retained variants.

Value

An object of the same class as x, with the collection-level slots carried over and mcols narrowed to the surviving elements.

Details

This is deliberately a new verb rather than a redefinition of a Bioconductor generic, because three genuinely different operations are in play and all three are useful:

subsetByOverlaps(x, win)

selects elements, keeps them whole.

restrict(x, start, end)

trims elements, keeps empty ones.

subsetRegion(x, win)

selects AND trims AND drops empties.

subsetChr() is the whole-seqname special case of this verb.

Examples

data(qtlSumStatsMulticontextExample)
mc <- qtlSumStatsMulticontextExample
sum(lengths(mc))
#> [1] 600
# Every element is narrowed to the window; the collection keeps its shape,
# so an element with nothing left stays as an empty one rather than a
# dropped row.
sub <- subsetRegion(mc, "chr22:14560203-15000000")
sum(lengths(sub))
#> [1] 21
nrow(sub)
#> [1] 3