%\VignetteIndexEntry{About diffcoexp}
\documentclass{article}
\usepackage{authblk}
\title{About \emph{diffcoexp}}
\date{November 23, 2020}
\author{Wenbin Wei, Sandeep Amberkar, Winston Hide}
\affil{Sheffield Institute of Translational Neuroscience, University of Sheffield, Sheffield, United Kingdom}
\usepackage[utf8]{inputenc}
\begin{document}
\SweaveOpts{concordance=TRUE}
\maketitle
\tableofcontents
\section{Description}
This package identifies differentially coexpressed links (DCLs) and differentially
coexpressed genes (DCGs). DCLs are gene pairs with significantly different correlation
coefficients under two conditions (de la Fuente 2010, Jiang et al., 2016). DCGs are genes
with significantly more DCLs than by chance (Yu et al., 2011, Jiang et al., 2016). It
takes two gene expression matrices or data frames under two conditions as input,
calculates gene-gene correlations under two conditions and compares them with Fisher's Z
transformation(Fisher 1915 and Fisher 1921). It filters gene pairs with the thresholds for correlation coefficients
and their adjusted p value as well as the thresholds for the difference between the two
correlation coefficients and its adjusted p value. It identifies DCGs using binomial
probability model (Jiang et al., 2016).\smallskip

\noindent
The main steps are as follows:

a). Correlation coefficients and p values of all gene pairs under two conditions are
calculated.

b). The differences between the correlation coefficients under two conditions are
calculated and their p values are calculated using Fisher's Z-transformation.

c). p values are adjusted.

d). Gene pairs (links) coexpressed in at least one condition are identified using the
criteria that at least one of the correlation coefficients under two conditions has
absolute value greater than the threshold \emph{rth} and adjusted p value less than the
threshold \emph{qth}. The links that meet the criteria are included in co-expressed links(CLs).

e). Differentially coexpressed links (gene pairs) are identified from CLs using the
criteria that the absolute value of the difference between the two correlation
coefficients is greater than the threshold \emph{r.diffth} and adjusted p value is less than
the threshold \emph{q.diffth}. The links that meet the criteria are included in differentially coexpressed links (DCLs).

f). The DCLs are classified into three categories: \emph{same signed}, \emph{diff signed}, or
\emph{switched opposites}. \emph{same signed} indicates that the gene pair has same signed
correlation coefficients under both conditions. \emph{diff signed} indicates that the gene
pair has oppositely signed correlation coefficients under two conditions and only one of
them meets the criteria that absolute correlation coefficient is greater than the
threshold \emph{rth} and adjusted p value less than the threshold \emph{qth}. \emph{switched opposites}
indicates that the gene pair has oppositely signed correlation coefficients under two
conditions and both of them meet the criteria that absolute correlation coefficient
is greater than the threshold \emph{rth} and adjusted p value less than the threshold \emph{qth}.

g). All the genes in DCLs are tested for their enrichment of DCLs, i.e, whether they have
more DCLs than by chance using binomial probability model (Jiang et al., 2016). Those
with adjusted p value less than the threshold \emph{q.dcgth} are included in DCGs.
\section{Installation and removal}
\noindent
This package is available from Bioconductor and can be installed within R as follows: \par
\#\# try http:// if https:// URLs are not supported \par
if (!requireNamespace("BiocManager", quietly=TRUE)) \par
    install.packages("BiocManager") \par
BiocManager::install("diffcoexp") \smallskip
\par
\noindent
To install this package from GitHub, start R and enter: \par
library(devtools) \par
devtools::install\_git("git://github.com/hidelab/diffcoexp.git", \par
    branch = "master") \smallskip
\par
\noindent
The above method does not build and install vignette. To install the package with
vignette, enter the following from command line: \par
\par
git clone https://github.com/hidelab/diffcoexp.git \par
R CMD build diffcoexp \par
R CMD check diffcoexp\_1.11.1.tar.gz \par
R CMD INSTALL diffcoexp\_1.11.1.tar.gz \smallskip
\par
\noindent
To remove this package, start R and enter: \par
\par
@
remove.packages("diffcoexp")
\section{Input and output of \emph{diffcoexp} function}
The main function of this package is \emph{diffcoexp} function. The first two arguments, \emph{exprs.1} and \emph{exprs.2}, are normalized gene expression data under two conditions with rows as genes and columns as samples. They should be objects of classes \emph{SummarizedExperiment}, \emph{data.frame} or \emph{matrix}. Both should have the same number of genes in the same order. The third argument \emph{r.method} is passed to the \emph{cor} function of the \emph{WGCNA} package as argument \emph{method}, details of which can be found by typing
<<results=hide>>=
help(cor, WGCNA)
@
The fourth argument \emph{q.method} is passed to the \emph{p.adjust} function of the \emph{stats} package as argument \emph{method}, details of which can be found by typing
<<results=hide>>=
help(p.adjust, stats)
@
Details of other arguments of \emph{diffcoexp} function can be found by typing
<<results=hide>>=
help(diffcoexp, diffcoexp)
@
The output of \emph{diffcoexp} function is a list of two data frames, one for differentially co-expressed links (DCLs), the other for differentially co-expressed genes (DCGs). Further details of the output can be seen on the help page.
\section{Analysis and interpretation of DCGs and DCLs}
\noindent
DCGs are a list of genes and therefore can be further analysed using other tools such as FGNet (https://bioconductor.org/packages/release/bioc/html/FGNet.html), clusterProfiler (https://bioconductor.org/packages/release/bioc/html/clusterProfiler.html) and enrichr (http://amp.pharm.mssm.edu/Enrichr/). DCLs are a list of differentially co-expressed gene pairs and can be assembled into a differential coexpression network. The network is scale-free but not smallworld (Hsu et al., 2017). The network can be visualized and analyzed using igraph (https://cran.r-project.org/web/packages/igraph/index.html). DCLs can also be further analyzed to identify upstream causal regulators using other tools such as DCGL v2.0 (Yang et al., 2013).
\section{Example}
This example illustrates the identification of differentially coexpressed links (gene
pairs) and differentially coexpressed genes of yeast after pulses of 2 g/l and 0.2 g/l
glucose separately. The data were downloaded from GEO (GSE4158). Only 400 genes were
analysed in this example. Analysis of all the genes (6104) will take about 20 minutes on
a computer with 8 cores and 16GB RAM.
<<results=hide>>=
library(diffcoexp)
data(gse4158part)
@
<<>>=
allowWGCNAThreads()
res=diffcoexp(exprs.1 = exprs.1, exprs.2 = exprs.2, r.method = "spearman" )
@
The results are a list of two data frames, one for differentially co-expressed links
(DCLs), the other for differentially co-expressed genes (DCGs).
<<>>=
str(res)
@
\section{References}
de la Fuente A (2010). From “differential expression” to “differential networking” –
identification of dysfunctional regulatory networks in diseases. \emph{Trends in Genetics}, 26(7):326-33.\smallskip
\par
\noindent
Fisher, R. A. (1915). Frequency distribution of the values of the correlation coefficient in samples of an indefinitely large population. \emph{Biometrika}, 10 (4): 507–521. \smallskip
\par
\noindent
Fisher, R. A. (1921). On the 'probable error' of a coefficient of correlation deduced from a small sample. \emph{Metron}, 1: 3–32.\smallskip
\par
\noindent
Hsu C-L, Juan H-F, Huang H-C (2015). Functional analysis and characterization of differential coexpression networks. \emph{Scientific Reports}, 5: 13295\smallskip
\par
\noindent
Jiang Z, Dong X, Li Z-G, He F, Zhang Z (2016). Differential coexpression analysis reveals extensive rewiring of Arabidopsis gene coexpression in response to Pseudomonas syringae infection. \emph{Scientific Reports}, 6(1):35064.\smallskip
\par
\noindent
Yang J, Yu H, Liu B-H, Zhao Z, Liu L, Ma L-X, et al. (2013) DCGL v2.0: An R package for unveiling differential regulation from differential co-expression. \emph{PLoS ONE}, 8(11):e79729.\smallskip
\par
\noindent
Yu H, Liu B-H, Ye Z-Q, Li C, Li Y-X, Li Y-Y (2011). Link-based quantitative methods to identify differentially coexpressed genes and gene pairs. \emph{BMC bioinformatics}, 12(1):315.

\end{document}
