filterByOverlaps() retains windows that overlap, while filterByNonOverlaps() retains windows that do not overlap a set of genomic regions. Inputs may use different chromosome styles (with or without the "chr" prefix); styles are harmonized automatically before overlap computation.

filterByOverlaps(qseaSet, regionsToOverlap)

filterByNonOverlaps(qseaSet, regionsToOverlap)

Arguments

qseaSet

qseaSet A qseaSet object containing methylation-enriched sequencing data.

regionsToOverlap

GRanges or data.frame Genomic regions used for filtering. If a data.frame, it must contain columns seqnames (character()), start (integer()), and end (integer()); the object is coerced internally to a GRanges.

Value

A qseaSet object:

  • filterByOverlaps(): returns the input qseaSet restricted to windows that overlap regionsToOverlap.

  • filterByNonOverlaps(): returns the input qseaSet restricted to windows that do not overlap regionsToOverlap.

Details

Chromosome naming is aligned using GenomeInfoDb::seqlevelsStyle() so that overlap computation is consistent even when one input uses "chr1" and the other uses "1". Only the window set is filtered; sample metadata and counts are subset accordingly.

Examples

data(exampleTumourNormal, package = "mesa")

# Data frame input
rgns <- data.frame(seqnames = 7L, start = 25002001L, end = 25017900L)
filterByOverlaps(exampleTumourNormal, regionsToOverlap = rgns)
#> qseaSet
#> =======================================
#> 10 Samples: 
#> Colon1_N, Colon1_T, Colon2_N, Colon2_T, Lung1_N, Lung1_T, Lung2_N, Lung2_T, Lung3_N, Lung3_T
#> 5 Regions in 22 chromosomes of BSgenome.Hsapiens.NCBI.GRCh38
filterByNonOverlaps(exampleTumourNormal, regionsToOverlap = rgns)
#> qseaSet
#> =======================================
#> 10 Samples: 
#> Colon1_N, Colon1_T, Colon2_N, Colon2_T, Lung1_N, Lung1_T, Lung2_N, Lung2_T, Lung3_N, Lung3_T
#> 814 Regions in 22 chromosomes of BSgenome.Hsapiens.NCBI.GRCh38

# GRanges input
gr <- GenomicRanges::GRanges("chr7", IRanges::IRanges(25002001L, 25017900L))
filterByOverlaps(exampleTumourNormal, regionsToOverlap = gr)
#> qseaSet
#> =======================================
#> 10 Samples: 
#> Colon1_N, Colon1_T, Colon2_N, Colon2_T, Lung1_N, Lung1_T, Lung2_N, Lung2_T, Lung3_N, Lung3_T
#> 5 Regions in 22 chromosomes of BSgenome.Hsapiens.NCBI.GRCh38
filterByNonOverlaps(exampleTumourNormal, regionsToOverlap = gr)
#> qseaSet
#> =======================================
#> 10 Samples: 
#> Colon1_N, Colon1_T, Colon2_N, Colon2_T, Lung1_N, Lung1_T, Lung2_N, Lung2_T, Lung3_N, Lung3_T
#> 814 Regions in 22 chromosomes of BSgenome.Hsapiens.NCBI.GRCh38