| count2tpm | R Documentation |
Transforms gene expression count data into Transcripts Per Million (TPM) values, normalizing for gene length and library size. Supports multiple gene ID types and can retrieve gene length information from BioMart or use local datasets.
count2tpm(
countMat,
idType = "Ensembl",
org = c("hsa", "mmus"),
source = c("local", "biomart"),
effLength = NULL,
id = "id",
gene_symbol = "symbol",
length = "eff_length",
check_data = FALSE
)
countMat |
Numeric matrix of raw read counts with genes in rows and samples in columns. |
idType |
Character string specifying the gene identifier type. Options are '"Ensembl"', '"Entrez"', or '"Symbol"'. Default is '"Ensembl"'. |
org |
Character string specifying the organism. Options include '"hsa"' (human) or '"mmus"' (mouse). Default is '"hsa"'. |
source |
Character string specifying the source for gene length information. Options are '"biomart"' (retrieve from Ensembl BioMart) or '"local"' (use local dataset). Default is '"local"'. |
effLength |
Data frame containing effective gene length information. If 'NULL', lengths are retrieved based on 'source'. Default is 'NULL'. |
id |
Character string specifying the column name in 'effLength' containing gene identifiers. Default is '"id"'. |
gene_symbol |
Character string specifying the column name in 'effLength' containing gene symbols. Default is '"symbol"'. |
length |
Character string specifying the column name in 'effLength' containing gene lengths. Default is '"eff_length"'. |
check_data |
Logical indicating whether to check for missing values in the count matrix. Default is 'FALSE'. |
Data frame of TPM-normalized expression values with genes in rows and samples in columns. Gene identifiers are converted to gene symbols in the output, regardless of the input 'idType'.
Wubing Zhang, Dongqiang Zeng, Yiran Fang
# Simulated count data
set.seed(123)
count_matrix <- matrix(
rpois(100, lambda = 10),
ncol = 5,
dimnames = list(
paste0("ENSG00000", 101:120),
paste0("Sample", 1:5)
)
)
# Simulated effective length data
eff_len <- data.frame(
id = paste0("ENSG00000", 101:120),
symbol = paste0("Gene", 1:20),
eff_length = runif(20, 500, 5000)
)
# Transform to TPM using local gene annotation
eset <- count2tpm(
countMat = count_matrix, effLength = eff_len,
id = "id", length = "eff_length", gene_symbol = "symbol"
)
head(eset)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.