Description Usage Arguments Value Methods (by generic) Slots See Also Examples
This s4 class is a tiny wrapper around a normal list (stored in the
signals
slot) and it is the output of the methods in the
bamsignals package.
Among other things the container provides an accessor method,
that returns single signals as vectors and matrices, and the
methods as.list
and alignSignals
, that convert the
container to a list or an array/matrix respectively. A CountSignals
object is read-only, i.e. it cannot be modified.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
x |
A CountSignals object |
i |
Index for subsetting. It can be a single index as well as a vector of indices. |
drop |
In case |
return values are described in the Methods section.
length
: Number of contained signals
width
: Width of each signal. If the CountSignals
object csig
is strand-specific then
width(csig)[i] == ncol(csig[i])
, otherwise
width(csig)[i] = length(csig[i])
.
[
: Access single signals or subset the CountSignals
object.
If i
is a single index and drop==TRUE
then the accessor returns
a single signal. If x
is strand-specific then a single signal is a
matrix with two rows, the first for the sense, the second for the antisense
strand. Otherwise a signle signal is simply a vector of integers. If i
is a vector of length different than 1, then the acessor returns a subset of
the CountSignals object. Invalid indices result into errors.
as.list
: Converts the container to a list l
such that
l[[i]]
is the i-th signal.
alignSignals
: Convert to a matrix or to an array. This is only
possible if all signals have the same width w
. If the CountSignals
object csig
is strand-specific, the result is an array of dimensions
[2, w, length(csig)]
, otherwise it will be a matrix of dimensions
[w, length(csig)]
.
ss
A single boolean value indicating whether all signals are strand-specific or not
signals
A list of integer vectors (if ss==TRUE
) or of integer
matrices, representing each signal
bamsignals-methods
for the functions that produce
this object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #get a CountSignals object
library(GenomicRanges)
bampath <-
system.file("extdata", "randomBam.bam", package="bamsignals")
genes <-
get(load(system.file("extdata", "randomAnnot.Rdata", package="bamsignals")))
csig <- bamProfile(bampath, genes, ss=TRUE)
#show it
show(csig)
#number of contained signals
len <- length(csig)
#width of each signal
w <- width(csig)
#get one element as a vector (or matrix)
v <- csig[1]
#use as if it was a list
tot_per_sig <- sapply(csig, sum)
#convert to a list
siglist <- as.list(csig)
#get regions and signals of the same width
proms <- promoters(genes, upstream=150, downstream=150)
csig <- bamCoverage(bampath, proms)
#convert to matrix
mat <- alignSignals(csig)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.