Title: | Analyzing and Visualizing Differential Correlation Networks in Biological Data |
---|---|
Description: | A method for identifying pattern changes between 2 experimental conditions in correlation networks (e.g., gene co-expression networks), which builds on a commonly used association measure, such as Pearson's correlation coefficient. This package includes functions to calculate correlation matrices for high-dimensional dataset and to test differential correlation, which means the changes in the correlation relationship among variables (e.g., genes and metabolites) between 2 experimental conditions. |
Authors: | Atsushi Fukushima [aut, cre], Kozo Nishida [aut] |
Maintainer: | Atsushi Fukushima <[email protected]> |
License: | GPL (> 3) |
Version: | 0.4.4 |
Built: | 2024-11-27 05:10:33 UTC |
Source: | https://github.com/afukushima/diffcorr |
A metabolite data set. The Arabidopsis metabolome of the aerial regions of individual WT plants and the mto1 and tt4 mutants were analyzed by GC-TOF/MS.
50 samples (WT, n = 17; mto1, n = 13; and tt4, n = 20, biological replicates).
A matrix containing 59 metabolites (rows) and 50 observations (columns).
MetaboLights accession no.: MTBLS40
For comparisons with data from roots (Fukushima et al. 2011) we selected 59 commonly-detected metabolites in both datasets using MetMask http://metmask.sourceforge.net.
Atsushi Fukushima
Miyako Kusano, Atsushi Fukushima et al. BMC Syst Biol 2007 1:53
A metabolite data set. The Arabidopsis metabolome of the roots of individual WT plants and the mto1 and tt4 mutants were analyzed by GC-TOF/MS.
53 root samples (WT, n = 17; mto1 n = 16; and tt4, n = 20, biological replicates).
A matrix containing 59 metabolites (rows) and 53 observations (columns).
MetaboLights accession no.: MTBLS45
For comparisons with data from aerial parts (Kusano, Fukushima et al. 2007) we selected 59 commonly-detected metabolites in both datasets using MetMask http://metmask.sourceforge.net.
Atsushi Fukushima
Atsushi Fukushima et al. BMC Syst Biol 2011 5:1.
Cluster molecules
cluster.molecule( data, method = "pearson", linkage = "average", absolute = FALSE )
cluster.molecule( data, method = "pearson", linkage = "average", absolute = FALSE )
data |
matrix or data frame |
method |
c("pearson", "spearman", "kendall", "euclidean", "maximum", "manhattan", "canberra", "binary", or "minkowski") |
linkage |
c("average", "ward", "single", "complete", "mcquitty", "median", "centroid") |
absolute |
if TRUE, then 1-|COR| else 1-COR, default is FALSE |
an object of class 'hclust'
Atsushi Fukushima
cluster.molecule(as.matrix(t(iris[,1:4])), "pearson", "average")
cluster.molecule(as.matrix(t(iris[,1:4])), "pearson", "average")
Export differential correlations of comparison of two correlation matrices
comp.2.cc.fdr( output.file = "res.txt", data1, data2, method = "pearson", p.adjust.methods = "local", threshold = 0.05, save = FALSE )
comp.2.cc.fdr( output.file = "res.txt", data1, data2, method = "pearson", p.adjust.methods = "local", threshold = 0.05, save = FALSE )
output.file |
can specify file name of the results exported |
data1 |
data matrix under condition 1 |
data2 |
data matrix under condition 2 |
method |
c("pearson", "spearman", "kendall") |
p.adjust.methods |
c("local", holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none") |
threshold |
a threshold of significance levels of differential correlation |
save |
exports the results as a text if TRUE (default: FALSE) |
data.frame
Atsushi Fukushima
Fukushima, A. Gene (2013) 518, 209-214
## Not run: data(AraMetRoots) AraMetRoots[AraMetRoots==0] <- NA AraMetRootsImp <- completeObs(pca(log2(AraMetRoots), nPcs=3, method="ppca")) comp.2.cc.fdr(output.file="res.txt", AraMetRootsImp[,1:17], method="spearman", AraMetRootsImp[,18:37], threshold=0.05) ## End(Not run)
## Not run: data(AraMetRoots) AraMetRoots[AraMetRoots==0] <- NA AraMetRootsImp <- completeObs(pca(log2(AraMetRoots), nPcs=3, method="ppca")) comp.2.cc.fdr(output.file="res.txt", AraMetRootsImp[,1:17], method="spearman", AraMetRootsImp[,18:37], threshold=0.05) ## End(Not run)
Compare two correlation coefficients using Fisher's Z-transformation
compcorr(n1, r1, n2, r2)
compcorr(n1, r1, n2, r2)
n1 |
sample size under condition 1 |
r1 |
correlation coefficient under condition 1 |
n2 |
sample size under condition 2 |
r2 |
correlation coefficient under condition 1 |
list of result (diff and p-value)
Atsushi Fukushima
http://www.fon.hum.uva.nl/Service/Statistics/Two_Correlations.html http://support.sas.com/ctx/samples/index.jsp?sid=494 http://support.sas.com/ctx/samples/index.jsp?sid=494
compcorr(10, 0.1, 10, 0.9)
compcorr(10, 0.1, 10, 0.9)
Additional distance functions Correlation distance (1-r)
cor.dist(data, methods = "pearson", absolute = FALSE)
cor.dist(data, methods = "pearson", absolute = FALSE)
data |
a data matrix ([data.frame object] row: metabolites, col: samples or replicates) |
methods |
a character string indicating which correlation coefficient is to be calculated. One of "pearson" (default), "spearman", or "kendall" can be abbreviated. |
absolute |
TRUE means that absolute value of the correlation coefficient is used (Default: FALSE). |
These functions were originally from 'hybridHclust' package. We modified the functions slightly. See also the reference manual in detail.
the resulting correlation matrix
Atsushi Fukushima
cor.dist(as.matrix(t(iris[,1:4])))
cor.dist(as.matrix(t(iris[,1:4])))
Correlation Test
cor2.test(n, r, method = c("pearson", "kendall", "spearman"))
cor2.test(n, r, method = c("pearson", "kendall", "spearman"))
n |
the number of samples |
r |
the correlation coefficient |
method |
"pearson" and "spearman" can be used. |
p-value
Atsushi Fukushima
http://aoki2.si.gunma-u.ac.jp/R/cor2.html
cor2.test(30, 0.6)
cor2.test(30, 0.6)
Generating graph from data matrix
generate_g( data, method = "pearson", cor.thr = 0.6, neg.flag = 1, node.col = "red", node.size = 7, edge.col = "blue", edge.width = 3 )
generate_g( data, method = "pearson", cor.thr = 0.6, neg.flag = 1, node.col = "red", node.size = 7, edge.col = "blue", edge.width = 3 )
data |
data matrix or data frame |
method |
c("Pearson", "Spearman", "Kendall") |
cor.thr |
a threshold of correlation coefficient (default: r >= 0.6) |
neg.flag |
flag where uses or not negative correlations |
node.col |
specifies color of nodes in a graph (default: red) |
node.size |
specifies size of nodes in a graph (default: 7) |
edge.col |
specifies color of edges in a graph (default: blue) |
edge.width |
specifies width of edges in a graph (default: 3) |
igraph object
Atsushi Fukushima
library(igraph) mat <- matrix(runif(100), nr=10) rownames(mat) <- as.character(1:10) generate_g(mat)
library(igraph) mat <- matrix(runif(100), nr=10) rownames(mat) <- as.character(1:10) generate_g(mat)
Get eigen molecule
get.eigen.molecule(data, groups, whichgroups = NULL, methods = "svd", n = 10)
get.eigen.molecule(data, groups, whichgroups = NULL, methods = "svd", n = 10)
data |
a data matrix ([data.frame object] row: molecules, col: samples or replicates) |
groups |
a vector of group memberships as returned by cutree |
whichgroups |
a vector of group numbers to examine |
methods |
c("svd", "nipals", "rnipals", "bpca", "ppca"). See also pca() function in pcaMethods package |
n |
top n principal components |
the resulting vector.
Atsushi Fukushima
library(pcaMethods) data(golub, package = "multtest") hc.mol1 <- cluster.molecule(golub[1:100, 1:27], "pearson", "average") g1 <- cutree(hc.mol1, h=0.6) res1 <- get.eigen.molecule(golub[1:100,], g1)
library(pcaMethods) data(golub, package = "multtest") hc.mol1 <- cluster.molecule(golub[1:100, 1:27], "pearson", "average") g1 <- cutree(hc.mol1, h=0.6) res1 <- get.eigen.molecule(golub[1:100,], g1)
Getting graph from eigengene module list
get.eigen.molecule.graph(eigen.list, label = "Module")
get.eigen.molecule.graph(eigen.list, label = "Module")
eigen.list |
the resulting vector from get.eigen.molecule |
label |
a label of module extracted (default: "Module") |
igraph object
Atsushi Fukushima
library(pcaMethods) library(igraph) data(golub, package = "multtest") hc.mol1 <- cluster.molecule(golub[, 1:27], "pearson", "average") g1 <- cutree(hc.mol1, h=0.4) res1 <- get.eigen.molecule(golub, g1) g1.eigen <- get.eigen.molecule.graph(res1)
library(pcaMethods) library(igraph) data(golub, package = "multtest") hc.mol1 <- cluster.molecule(golub[, 1:27], "pearson", "average") g1 <- cutree(hc.mol1, h=0.4) res1 <- get.eigen.molecule(golub, g1) g1.eigen <- get.eigen.molecule.graph(res1)
Getting local false discovery rate (lfdr) using 'fdrtool' package
get.lfdr(r)
get.lfdr(r)
r |
a vector of correlation coefficient under condition |
list of lfdr
Atsushi Fukushima
Strimmer, K. Bioinformatics (2008) 24, 1461-1462
library("fdrtool") data(pvalues) get.lfdr(pvalues)
library("fdrtool") data(pvalues) get.lfdr(pvalues)
Get minimum and maximum
get.min.max(d)
get.min.max(d)
d |
data matrix or data frame |
list object of minimum value or maximum value in a data
Atsushi Fukushima
get.min.max(iris[,1:2])
get.min.max(iris[,1:2])
Plot cluster molecules
plotClusterMolecules( data, groups = NULL, group.no = NULL, title = NULL, ylim = NULL, order = NULL, scale.center = FALSE, scale.scale = FALSE, frame = "white", col = NULL, bottom.mar = 5, xlab = "Samples", ylab = "Relative abundance" )
plotClusterMolecules( data, groups = NULL, group.no = NULL, title = NULL, ylim = NULL, order = NULL, scale.center = FALSE, scale.scale = FALSE, frame = "white", col = NULL, bottom.mar = 5, xlab = "Samples", ylab = "Relative abundance" )
data |
data matrix or data frame |
groups |
a vector of group memberships as returned by cutree |
group.no |
the group number to be plotted |
title |
a title for the graph |
ylim |
a vector indicating the upper and lower limit for the y-axis |
order |
whether or not to order the columns of the data matrix |
scale.center |
unless NULL, each row is scaled using scale |
scale.scale |
unless NULL, each row is scaled using scale. |
frame |
the color of the frame that is drawn as the background of the plot |
col |
If NULL, all genes will be drawn in the default color (blue). If the text "random" is given, then a set of colors will be generated by |
bottom.mar |
The size of the bottom margin of the plots as sent in par(mar=c(...)) |
xlab |
a lalel of x axis (defalt: "Samples") |
ylab |
a lalel of y axis (defalt: "Relative abundance") |
a graph
Atsushi Fukushima
this function was originally from Watson M (2005) BMC Bioinformatics 7:509
library(pcaMethods) data(golub, package = "multtest") hc.mol1 <- cluster.molecule(golub[, 1:27], "pearson", "average") g1 <- cutree(hc.mol1, h=0.4) plotClusterMolecules(golub[,1:27], g1, 3)
library(pcaMethods) data(golub, package = "multtest") hc.mol1 <- cluster.molecule(golub[, 1:27], "pearson", "average") g1 <- cutree(hc.mol1, h=0.4) plotClusterMolecules(golub[,1:27], g1, 3)
Plot DiffCorr group
plotDiffCorrGroup( data, groups1 = NULL, groups2 = NULL, group1.no = NULL, group2.no = NULL, g1, g2, g1.order = NULL, g2.order = NULL, title1 = NULL, title2 = NULL, ... )
plotDiffCorrGroup( data, groups1 = NULL, groups2 = NULL, group1.no = NULL, group2.no = NULL, g1, g2, g1.order = NULL, g2.order = NULL, title1 = NULL, title2 = NULL, ... )
data |
a data matrix or data frame |
groups1 |
a vector of row group membership as produced by cutree under condition 1 |
groups2 |
a vector of row group membership as produced by cutree under condition 2 |
group1.no |
the group number to be plotted (condition 1) |
group2.no |
the group number to be plotted (condition 2) |
g1 |
a vector describing the columns of the data belonging to condition 1 |
g2 |
a vector describing the columns of the data belonging to condition 2 |
g1.order |
whether or not to order the columns of the data matrix for condition 1. If "average", then the columns are ordered by the average expression value. If the name of a gene (row), then the columns are orderd according to the expression levels of that gene. If NULL, columns remain in their original order. |
g2.order |
See g1.order |
title1 |
A title for the left hand graph |
title2 |
A title for the right hand graph |
... |
other parameters to be passed to this function |
a graph
Atsushi Fukushima
library(pcaMethods) data(golub, package = "multtest") hc.mol1 <- cluster.molecule(golub[, 1:27], "pearson", "average") hc.mol2 <- cluster.molecule(golub[, 28:38], "pearson", "average") g1 <- cutree(hc.mol1, h=0.4) g2 <- cutree(hc.mol2, h=0.4) ## plotDiffCorrGroup(golub, g1, g2, 21, 24, 1:27, 28:38, scale.center=TRUE, scale.scale=TRUE, ylim=c(-5,5))
library(pcaMethods) data(golub, package = "multtest") hc.mol1 <- cluster.molecule(golub[, 1:27], "pearson", "average") hc.mol2 <- cluster.molecule(golub[, 28:38], "pearson", "average") g1 <- cutree(hc.mol1, h=0.4) g2 <- cutree(hc.mol2, h=0.4) ## plotDiffCorrGroup(golub, g1, g2, 21, 24, 1:27, 28:38, scale.center=TRUE, scale.scale=TRUE, ylim=c(-5,5))
The pre-treatment methods
scalingMethods( data, methods = c("auto", "range", "pareto", "vast", "level", "power") )
scalingMethods( data, methods = c("auto", "range", "pareto", "vast", "level", "power") )
data |
a data matrix ([data.frame object] row: molecules, col: samples or replicates) |
methods |
the chosen methods. |
the resulting data frame (or scaled data matrix)
Atsushi Fukushima
scalingMethods(iris[,1:4], "level")
scalingMethods(iris[,1:4], "level")
Additional distance functions correlation distance (uncentered)
uncent.cor2dist(data, i, absolute = FALSE)
uncent.cor2dist(data, i, absolute = FALSE)
data |
a data matrix ([data.frame object] row: metabolites, col: samples or replicates) |
i |
i-th row of data |
absolute |
TRUE means that absolute value of the correlation coefficient is used (Default: FALSE). |
These functions were originally from 'hybridHclust' package. We modified the functions slightly. See also the reference manual in detail.
the resulting correlation matrix
Atsushi Fukushima
uncent.cor2dist(as.matrix(t(iris[,1:4])), 1) ## NOT RUN!
uncent.cor2dist(as.matrix(t(iris[,1:4])), 1) ## NOT RUN!
Calculating all pairwise distances using correlation distance
uncent.cordist(data, absolute = FALSE)
uncent.cordist(data, absolute = FALSE)
data |
a data matrix ([data.frame object] row: metabolites, col: samples or replicates) |
absolute |
TRUE means that absolute value of the correlation coefficient is used (Default: FALSE). |
These functions were originally from 'hybridHclust' package. We modified the functions slightly. See also the reference manual in detail.
the resulting correlation matrix
Atsushi Fukushima
uncent.cordist(as.matrix(t(iris[,1:4]))) ## NOT RUN!
uncent.cordist(as.matrix(t(iris[,1:4]))) ## NOT RUN!
Writing modules into a text file
write.modules(cutree.res, mod.list, outfile = "module_list.txt")
write.modules(cutree.res, mod.list, outfile = "module_list.txt")
cutree.res |
the result of cutree function |
mod.list |
the result of get.eigen.molecule |
outfile |
file name of output |
a text file
Atsushi Fukushima
## Not run: data(golub, package = "multtest") hc.mol1 <- cluster.molecule(golub[, 1:27], "pearson", "average") g1 <- cutree(hc.mol1, h=0.4) res1 <- get.eigen.molecule(golub, g1) write.modules(g1, res1) ## End(Not run)
## Not run: data(golub, package = "multtest") hc.mol1 <- cluster.molecule(golub[, 1:27], "pearson", "average") g1 <- cutree(hc.mol1, h=0.4) res1 <- get.eigen.molecule(golub, g1) write.modules(g1, res1) ## End(Not run)