strand-utils {GenomicRanges} | R Documentation |
Some useful strand
methods.
## S4 method for signature 'missing' strand(x) ## S4 method for signature 'character' strand(x) ## S4 method for signature 'factor' strand(x) ## S4 method for signature 'integer' strand(x) ## S4 method for signature 'logical' strand(x) ## S4 method for signature 'Rle' strand(x) ## S4 method for signature 'DataTable' strand(x) ## S4 replacement method for signature 'DataTable,ANY' strand(x) <- value
x |
The object from which to obtain a strand factor, can be missing. |
value |
Replacement value for the strand. |
If x
is missing, returns an empty factor with the
"standard strand levels" i.e. +
, -
, and *
.
If x
is a character vector or factor, it is coerced to a
factor with the levels listed above. NA
values in x
are not accepted.
If x
is an integer vector, it is coerced to a factor
with the levels listed above. 1
, -1
, and NA
values in x
are mapped to the +
, -
, and
*
levels respectively.
If x
is a logical vector, it is coerced to a factor
with the levels listed above. FALSE
, TRUE
, and NA
values in x
are mapped to the +
, -
, and
*
levels respectively.
If x
is a character-, factor-, integer-, or
logical-Rle, it is transformed with
runValue(x) <- strand(runValue(x))
and returned.
If x
inherits from DataTable
, the "strand"
column is passed thru strand()
and returned.
If x
has no "strand"
column, this return value is
populated with *
s.
A factor (or factor-Rle) with the "standard strand levels"
(i.e. +
, -
, and *
) and no NAs.
Michael Lawrence and H. Pages
strand() x1 <- c("-", "*", "*", "+", "-", "*") x2 <- factor(c("-", "-", "+", "-")) x3 <- c(-1L, NA, NA, 1L, -1L, NA) x4 <- c(TRUE, NA, NA, FALSE, TRUE, NA) strand(x1) strand(x2) strand(x3) strand(x4) strand(Rle(x1)) strand(Rle(x2)) strand(Rle(x3)) strand(Rle(x4)) strand(DataFrame(score=2:-3)) strand(DataFrame(score=2:-3, strand=x3)) strand(DataFrame(score=2:-3, strand=Rle(x3))) ## Sanity checks: target <- strand(x1) stopifnot(identical(target, strand(x3))) stopifnot(identical(target, strand(x4))) stopifnot(identical(Rle(strand(x1)), strand(Rle(x1)))) stopifnot(identical(Rle(strand(x2)), strand(Rle(x2)))) stopifnot(identical(Rle(strand(x3)), strand(Rle(x3)))) stopifnot(identical(Rle(strand(x4)), strand(Rle(x4))))