Learn R Programming

Linnorm (version 1.0.2)

Linnorm.limma: Linnorm-limma pipeline for Differentially Expression Analysis

Description

This function first performs Linnorm transformation on the dataset. Then, it will perform limma for DEG analysis. Finally, it will correct fold change outputs from limma results, that will be wrong otherwise. Please cite both Linnorm and limma when you use this function for publications.

Usage

Linnorm.limma(datamatrix, design = NULL, output = "DEResults", noINF = TRUE, showinfo = FALSE, perturbation = 10, minZeroPortion = 2/3, robust = TRUE)

Arguments

datamatrix
The matrix or data frame that contains your dataset. Each row is a feature (or Gene) and each column is a sample (or replicate). Undefined values such as NA are not supported.
design
A design matrix required for limma. Please see limma's documentation or our vignettes for more detail.
output
Character. "DEResults" or "Both". Set to "DEResults" to output a matrix that contains Differential Expression Analysis Results. Set to "Both" to output a list that contains both Differential Expression Analysis Results and the transformed data matrix.
noINF
Logical. Prevent generating INF in the fold change column by using Linnorm's lambda and adding one. If it is set to FALSE, INF will be generated if one of the conditions has zero expression. Defaults to TRUE.
showinfo
Logical. Show lambda value calculated. Defaults to FALSE.
perturbation
Integer >=2. To search for an optimal minimal deviation parameter (please see the article), Linnorm uses the iterated local search algorithm which perturbs away from the initial local minimum. The range of the area searched in each perturbation is exponentially increased as the area get further away from the initial local minimum, which is determined by their index. This range is calculated by 10 * (perturbation ^ index).
minZeroPortion
Double >=0,
robust
Logical. In the eBayes function of Limma, run with robust setting with TRUE or FALSE. Defaults to TRUE.

Value

If output is set to "DEResults", this function will output a matrix with Differntial Expression Analysis Results with the following columns:
  • logFC: Log 2 Fold Change
  • XPM: Average Expression. If input is raw count or CPM, this column has the CPM unit. If input is RPKM, FPKM or TPM, this column has the TPM unit.
  • t: moderated t-statistic
  • P.Value: p value
  • adj.P.Val: Adjusted p value. This is also called False Discovery Rate or q value.
  • B: log odds that the feature is differential
If output is set to Both, this function will output a list with the following objects:
  • DEResults: Differntial Expression Analysis Results as described above.
  • TMatrix: A Linnorm Transformed Expression Matrix.

Details

This function performs both Linnorm and limma for users who are interested in differential expression analysis. Please note that if you directly use a Linnorm Nomralized dataset with limma, the output fold change and average expression with be wrong. (p values and adj.pvalues will be fine.) This is because the voom-limma pipeline assumes input to be in raw counts. This function is written to fix this problem.

Examples

Run this code
#Obtain example matrix:
library(seqc)
SampleA <- ILM_aceview_gene_BGI[,grepl("A_",colnames(ILM_aceview_gene_BGI))]
rownames(SampleA) <- ILM_aceview_gene_BGI[,2]
SampleB <- ILM_aceview_gene_BGI[,grepl("B_",colnames(ILM_aceview_gene_BGI))]
rownames(SampleB) <- ILM_aceview_gene_BGI[,2]
#Extract a portion of the matrix for an example
expMatrix <- cbind(SampleA[,1:3], SampleB[,1:3])
designmatrix <- c(1,1,1,2,2,2)
designmatrix <- model.matrix(~ 0+factor(designmatrix))
colnames(designmatrix) <- c("group1", "group2")
rownames(designmatrix) <- colnames(expMatrix)

#Example 1
DEGResults <- Linnorm.limma(expMatrix, designmatrix)
#Example 2
DEGResults <- Linnorm.limma(expMatrix, designmatrix, output="Both")

Run the code above in your browser using DataLab