knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
rm(list = ls())
library(precision.seq)
library(DESeq2)

This package provides functions for nine depth normalization methods and for two differential expression analysis methods.

Functions for Depth Normalization

Among the nine normalization methods, six are re-scaling-based and three are regression-based. The input for each normalization function includes (1) sequencing count data in the format of a data frame or a data matrix (with columns for samples and rows for miRNAs/markers) and (2) the sample groups in the form of a character vector. For re-scaling-based methods, the output is a matrix of the normalized data and a vector of the estimated sample-specific scaling factors. For regression-based methods, the output is a matrix of the un-normalized data and a vector of the estimated adjustment factors.

test.TC <- norm.TC(data.test, data.group)
test.UQ <- norm.UQ(data.test, data.group)
test.med <- norm.med(data.test, data.group)
test.TMM <- norm.TMM(data.test, data.group)
test.DESeq <- norm.DESeq(data.test, data.group)
test.PoissonSeq <- norm.PoissonSeq(data.test)
test.QN <- norm.QN(data.test)
test.SVA <- norm.SVA(data.test, data.group)
test.RUVg <- norm.RUVg(data.test, data.group)
test.RUVs <- norm.RUVs(data.test, data.group)
test.RUVr <- norm.RUVr(data.test, data.group)

head(test.TMM$scaling.factor)
head(test.TMM$dat.normed[,1:5])

head(test.SVA$adjust.factor)
head(test.SVA$dat.normed[,1:5])

Functions for Differential Expression Analysis

Two methods for assessing differential expression are edgeR and voom-limma. The input can be either the normalized dataset (from re-scaling normalization) or the un-normalized dataset plus adjustment factors (from regression-based normalization). The output includes the per-marker p-values, and the group mean differences, and the names of the significant markers (using a p-value cutoff specified by the user).

edgeR.benchmark <- DE.edgeR(data.benchmark, data.group)
voom.benchmark <- DE.voom(data.benchmark, data.group)

edgeR.test.TMM <- DE.edgeR(test.TMM$dat.normed, data.group)
voom.test.TMM <- DE.voom(test.TMM$dat.normed, data.group)

edgeR.test.RUVr <- DE.edgeR(data.test, data.group, 
                            normalized = FALSE,
                            adjust = test.RUVr$adjust.factor)
voom.test.RUVr <- DE.voom(data.test, data.group, 
                          normalized = FALSE,
                          adjust = test.RUVr$adjust.factor)

head(voom.benchmark$id.list)
head(voom.benchmark$p.val)

head(voom.test.RUVr$id.list)
head(voom.test.RUVr$p.val)

Functions for Connecting Normalization and Differential Expression Analysis

A function is included in the package for connecting the step of depth normalization and the step of differential expression analysis.

res.norm <- pip.norm(data.test, data.group, "norm.TMM")
res.DE <- pip.norm.DE(data.test, data.group, "norm.TMM")

Example usage for SVA Normalization

Some normalization methods, such as the SVA method, compute "adjustment" instead of normalized counts. For illustration, we repeat the PRECISION.seq analysis using SVA.

# Compute normalization 
sva.norm <- norm.SVA(data.test, data.group)
# sva.norm contains the 
res.sva <- precision.seq(sva.norm$dat.normed, 
                         method.name="sva", 
                         adjust.factors=sva.norm$adjust.factor, 
                         DE.method="DE.voom", 
                         Pval=0.01)


LXQin/PRECISION.seq documentation built on Dec. 18, 2021, 3:41 a.m.