calc_norm_counts: Filter, normalize, and/or convert counts object

Description Usage Arguments Details Value

View source: R/calc_norm_counts.R

Description

This function performs a number of operations on a counts object. It filters the counts to include only samples matching a sample annotation object. It optionally filters out low-count genes. It optionally normalizes, log2-transforms, and/or transposes counts. Finally, it can return either a DGEList object or a data frame.

Usage

1
2
3
4
5
6
calc_norm_counts(
  counts, design, libID_col="lib.id",
  min_count=NULL, min_cpm=NULL, min_libs_perc=0.15,
  normalize=TRUE, norm_method="TMM",
  log2_transform=FALSE, transpose=FALSE, return_DGEcounts=FALSE,
  ...)

Arguments

counts

a matrix or data frame of gene expression counts. Should have sample in columns and genes in rows.

design

a data frame of sample information. At minimum, must contain a column corresponding to sample identifiers matching column names of counts. Passed to design_filter_counts.

libID_col

numeric index or character name of column in design containing sample identifers matching column names of counts. Passed to design_filter_counts.

min_count

numeric, the minimum count for a library to be considered passing threshold for a given gene.

min_cpm

numeric, the minimum counts per million for a library to be considered passing threshold for a given gene.

min_libs_perc

numeric, the minimum percentage of libraries that must meet min_count or min_cpm threshold for a gene to be retained.

normalize

logical, whether to normalize counts using edgeR::calcNormFactors.

norm_method

character, the method by which to normalize counts; passed to edgeR::calcNormFactors. Used only if normalize is TRUE. Defaults to "TMM".

log2_transform

logical, whether to log2 transform the counts. Defaults to FALSE.

transpose

logical, whether to transpose the matrix or data frame of counts.

return_DGEcounts

logical, whether to return return counts as a DGEList object. If FALSE, counts are returned as a data frame. Defaults to FALSE.

...

(optional) parameters passed to normalization functions.

Details

This function utilizes design_filter_counts and (optionally) min_filter_counts to filter the counts object. Genes are filtered by expression if a non-Null value is provided for either min_count or min_cpm. It then (optionally) normalizes the counts, using edgeR::calcNormFactors. It then (optionally) log2-transforms the counts and/or transposes the counts object. Finally, it returns the counts either as a data frame, or as a DGEList object. For WGCNA analyses, should use log2_transform=TRUE, transpose=TRUE, return_DGECounts=FALSE. For limma analyses, should use log2_transform=FALSE, transpose=FALSE, return_DGECounts=TRUE.

Value

a data frame or DGEList object containing the processed counts.


mjdufort/countSubsetNorm documentation built on Nov. 7, 2019, 6:37 p.m.