Newer
Older
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/SCESet-functions.R
\name{addGeneLengths}
\alias{addGeneLengths}
\title{Add gene lengths}
\usage{
addGeneLengths(sce, method = c("generate", "sample"), loc = 7.9,
scale = 0.7, lengths = NULL)
}
\arguments{
\item{sce}{SCESet to add gene lengths to.}
\item{method}{Method to use for creating lengths.}
\item{loc}{Location parameter for the generate method.}
\item{scale}{Scale parameter for the generate method.}
\item{lengths}{Vector of lengths for the sample method.}
}
\value{
SCESet with added gene lengths
}
\description{
Add gene lengths to an SCESet object
}
\details{
This function adds simulated gene lengths to the \code{fData} slot of an
\code{SCESet} object that can be used for calculating length normalised
expression values such as TPM or FPKM. The \code{generate} simulates lengths
using a (rounded) log-normal distribution, with the default \code{loc} and
\code{scale} parameters based on human coding genes. Alternatively the
\code{sample} method can be used which randomly samples lengths (with
replacement) from a supplied vector.
}
\examples{
# Default generate method
sce <- simpleSimulate()
sce <- addGeneLengths(sce)
head(fData(sce))
# Sample method (human coding genes)
\dontrun{
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
library(GenomicFeatures)
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
tx.lens <- transcriptLengths(txdb, with.cds_len = TRUE)
tx.lens <- tx.lens[tx.lens$cds_len > 0, ]
gene.lens <- max(splitAsList(tx.lens$tx_len, tx.lens$gene_id))
sce <- addGeneLengths(sce, method = "sample", lengths = gene.lens)
}
}