Last data update: 2014.03.03

R: Selection of ranges and columns
RangedSelection-classR Documentation

Selection of ranges and columns

Description

A RangedSelection represents a query against a table of interval data in terms of ranges and column names. The ranges select any table row with an overlapping interval. Note that the intervals are always returned, even if no columns are selected.

Details

Traditionally, tabular data structures have supported the subset function, which allows one to select a subset of the rows and columns from the table. In that case, the rows and columns are specified by two separate arguments. As querying interval data sources, especially those external to R, such as binary indexed files and databases, is increasingly common, there is a need to encapsulate the row and column specifications into a single data structure, mostly for the sake of interface cleanliness. The RangedSelection class fills that role.

Constructor

RangedSelection(ranges = RangesList(), colnames = character()): Constructors a RangedSelection with the given ranges and colnames.

Coercion

as(from, "RangedSelection"): Coerces from to a RangedSelection object. Typically, from is a RangesList, the ranges of which become the ranges in the new RangedSelection.

Accessors

In the code snippets below, x is always a RangedSelection.

ranges(x), ranges(x) <- value: Gets or sets the ranges, a RangesList, that select rows with overlapping intervals.

colnames(x), colnames(x) <- value: Gets the names, a character vector, indicating the columns.

Author(s)

Michael Lawrence

Examples

  rl <- RangesList(chr1 = IRanges(c(1, 5), c(3, 6)))

  RangedSelection(rl)
  as(rl, "RangedSelection") # same as above

  RangedSelection(rl, "score")

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(IRanges)
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

Loading required package: S4Vectors
Loading required package: stats4

Attaching package: 'S4Vectors'

The following objects are masked from 'package:base':

    colMeans, colSums, expand.grid, rowMeans, rowSums

> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/IRanges/RangedSelection-class.Rd_%03d_medium.png", width=480, height=480)
> ### Name: RangedSelection-class
> ### Title: Selection of ranges and columns
> ### Aliases: RangedSelection-class ranges,RangedSelection-method
> ###   colnames,RangedSelection-method ranges<-,RangedSelection-method
> ###   colnames<-,RangedSelection-method
> ###   coerce,RangesList,RangedSelection-method RangedSelection
> ### Keywords: methods classes
> 
> ### ** Examples
> 
>   rl <- RangesList(chr1 = IRanges(c(1, 5), c(3, 6)))
> 
>   RangedSelection(rl)
An object of class "RangedSelection"
Slot "ranges":
RangesList of length 1
$chr1
IRanges object with 2 ranges and 0 metadata columns:
          start       end     width
      <integer> <integer> <integer>
  [1]         1         3         3
  [2]         5         6         2


Slot "colnames":
character(0)

>   as(rl, "RangedSelection") # same as above
An object of class "RangedSelection"
Slot "ranges":
RangesList of length 1
$chr1
IRanges object with 2 ranges and 0 metadata columns:
          start       end     width
      <integer> <integer> <integer>
  [1]         1         3         3
  [2]         5         6         2


Slot "colnames":
character(0)

> 
>   RangedSelection(rl, "score")
An object of class "RangedSelection"
Slot "ranges":
RangesList of length 1
$chr1
IRanges object with 2 ranges and 0 metadata columns:
          start       end     width
      <integer> <integer> <integer>
  [1]         1         3         3
  [2]         5         6         2


Slot "colnames":
[1] "score"

> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>