tpm.direct: Convert countsMatrix and geneLength to TPM units

View source: R/convertCounts.R

tpm.directR Documentation

Convert countsMatrix and geneLength to TPM units

Description

Takes a countsMatrix and geneLength as input and converts to TPM units using the equation from Harold Pimental.

Usage

tpm.direct(countsMatrix, geneLength, collapse = FALSE)

Arguments

countsMatrix

A numeric matrix of N genes x M samples. All columns must be numeric.

geneLength

Numeric matrix of gene lengths. Often the ExonLength item of a DGEobj.

collapse

Default = FALSE. TRUE or FALSE determines whether to use rowMeans on the geneLength matrix.

Details

The result should be the same as using convertCounts with normalize = 'tpm' and log = FALSE.

geneLength can be a vector (length == nrow(countsMatrix)) or a matrix (same dim as countsMatrix). The geneLength is used as is, or optionally collapsed to a vector by rowMeans.

Value

A matrix of TPM values

Examples

   dgeObj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj"))

   counts <- DGEobj::getItem(dgeObj, "counts")
   exonLength <- dgeObj$geneData$ExonLength
   tpm <- tpm.direct(counts, geneLength = exonLength)


DGEobj.utils documentation built on May 20, 2022, 1:08 a.m.