normalise_counts: Convert raw read counts in to normalised values.

View source: R/general_bioinfo.R

normalise_countsR Documentation

Convert raw read counts in to normalised values.

Description

Reads Per Kilo Base Per Million (RPKM) and Tags Per Million (TPM) are two most waidely used normalisation methods in RNA-seq experiments. This function convert raw read counts either into RPKM or TPM values.

Usage

normalise_counts(x, .vars = NULL, method = "TPM")

Arguments

x

A dataframe of raw counts along with mandatory columns which are GeneID, Chr, Start, End, Strand, Length.

.vars

A character vector containing columns from x. Normalization will be performed only on these columns. If NULL (default) all columns normlaisation will be performed on all columns.

method

A character string, default TPM. Choices are one of TPM, RPKM.

Details

implemntaion of RPKM and TPM can be seen in functions get_tpm() and get_rpkm() respectively.

Value

A dataframe with all mandatory columns along with columns mentioned in .vars. Remaining columns from x will be dropped.

See Also

get_tpm() get_rpkm()

Examples

set.seed(123)
tt <- tibble::tibble(gene_id = c(paste("Gene_",1:5,sep = "")),
                     chr = "Chr1",
                     start = sample(1:100, 5),
                     end = sample(100:200,5),
                     strand = sample(c("+" ,"-"), 5, replace = TRUE),
                     length = (end - start )+ 1 )

tt %<>% dplyr::mutate(sample_1 = sample(c(1:100),5)*10 ,
                      sample_2 = sample(c(1:100),5)*10 ,
                      sample_3 = sample(c(1:100),5)*100,
                      sample_4 = sample(c(1:100),5)*100 )

normalise_counts(x = tt ,method = "RPKM")
normalise_counts(x = tt, .vars = c("sample_1","sample_2") ,method = "TPM")
normalise_counts(x = tt, .vars = c("sample_1","sample_2") ,method = "RPKM")

cparsania/parcutils documentation built on Oct. 27, 2024, 4:55 a.m.