Add gene lengths to an SCESet object
addGeneLengths(sce, method = c("generate", "sample"), loc = 7.9, scale = 0.7, lengths = NULL)
sce | SCESet to add gene lengths to. |
---|---|
method | Method to use for creating lengths. |
loc | Location parameter for the generate method. |
scale | Scale parameter for the generate method. |
lengths | Vector of lengths for the sample method. |
SCESet with added gene lengths
This function adds simulated gene lengths to the fData
slot of an
SCESet
object that can be used for calculating length normalised
expression values such as TPM or FPKM. The generate
simulates lengths
using a (rounded) log-normal distribution, with the default loc
and
scale
parameters based on human coding genes. Alternatively the
sample
method can be used which randomly samples lengths (with
replacement) from a supplied vector.
#>#>#>sce <- addGeneLengths(sce) head(fData(sce))#> Gene GeneMean Length #> Gene1 Gene1 1.885070e+00 2874 #> Gene2 Gene2 5.651522e+00 1169 #> Gene3 Gene3 1.109488e+01 2330 #> Gene4 Gene4 8.549893e-03 4415 #> Gene5 Gene5 5.620109e-04 7288 #> Gene6 Gene6 4.884267e-02 4316# Sample method (human coding genes)# NOT RUN { 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) # }