% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/count2tpm.R
\name{count2tpm}
\alias{count2tpm}
\title{Convert Read Counts to Transcripts Per Million (TPM)}
\usage{
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
)
}
\arguments{
\item{countMat}{Numeric matrix of raw read counts with genes in rows and
samples in columns.}

\item{idType}{Character string specifying the gene identifier type. Options
are `"Ensembl"`, `"Entrez"`, or `"Symbol"`. Default is `"Ensembl"`.}

\item{org}{Character string specifying the organism. Options include
`"hsa"` (human) or `"mmus"` (mouse). Default is `"hsa"`.}

\item{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"`.}

\item{effLength}{Data frame containing effective gene length information. If
`NULL`, lengths are retrieved based on `source`. Default is `NULL`.}

\item{id}{Character string specifying the column name in `effLength`
containing gene identifiers. Default is `"id"`.}

\item{gene_symbol}{Character string specifying the column name in `effLength`
containing gene symbols. Default is `"symbol"`.}

\item{length}{Character string specifying the column name in `effLength`
containing gene lengths. Default is `"eff_length"`.}

\item{check_data}{Logical indicating whether to check for missing values in
the count matrix. Default is `FALSE`.}
}
\value{
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`.
}
\description{
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.
}
\examples{
# 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)
}
\author{
Wubing Zhang, Dongqiang Zeng, Yiran Fang
}
