Strand utilities
A bunch of useful strand and invertStrand 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 'RleList' strand(x) ## S4 method for signature 'DataFrame' strand(x) ## S4 replacement method for signature 'DataFrame,ANY' strand(x) <- value ## S4 method for signature 'character' invertStrand(x) ## S4 method for signature 'factor' invertStrand(x) ## S4 method for signature 'integer' invertStrand(x) ## S4 method for signature 'logical' invertStrand(x) ## S4 method for signature 'Rle' invertStrand(x) ## S4 method for signature 'RleList' invertStrand(x)
For the strand methods:
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 is an RleList object, each list element in
x is transformed by calling strand() on it and
the resulting RleList object is returned. More precisely
the returned object is endoapply(x, strand).
Note that in addition to being parallel to x, this
object also has the same shape as x (i.e. its list
elements have the same lengths as in x).
If x is a DataFrame object, the "strand"
column is passed thru strand() and returned.
If x has no "strand" column, this return value is
populated with *s.
Each invertStrand method returns the same object as its corresponding
strand method but with "+" and "-" switched.
M. Lawrence and H. Pagès
strand()
x1 <- c("-", "*", "*", "+", "-", "*")
x2 <- factor(c("-", "-", "+", "-"))
x3 <- c(-1L, NA, NA, 1L, -1L, NA)
x4 <- c(TRUE, NA, NA, FALSE, TRUE, NA)
strand(x1)
invertStrand(x1)
strand(x2)
invertStrand(x2)
strand(x3)
invertStrand(x3)
strand(x4)
invertStrand(x4)
strand(Rle(x1))
invertStrand(Rle(x1))
strand(Rle(x2))
invertStrand(Rle(x2))
strand(Rle(x3))
invertStrand(Rle(x3))
strand(Rle(x4))
invertStrand(Rle(x4))
x5 <- RleList(x1, character(0), as.character(x2))
strand(x5)
invertStrand(x5)
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))))Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.