Combining partial covariance matrices using CovCombR package

The package is focused on combining partially overlapping relationship / covariance matrices to obtain a combined relationship / covariance matrix. At the moment the only function available to the users is the usage of which will be illustrated with an example from phenomics.

Illustration: Combining data from independent phenotypic experimets.

Lets load the package and datasets.

library(CovCombR)
## This is CovCombR version 1.0.
## A package for combining partial covariance
## matrices from independent experiments.
## Authors: Deniz Akdemir, Julio Isidro Sanchez
## Maintainer: Deniz, <[email protected]>
data("BarleyPheno")

The datasets are very heterogenous, each trial only involves a few traits. We can see this from the following image. Mean number of traits per trait is about 6.

library(plyr)
dataall<-rbind.fill(BarleyPheno)
image(as.matrix(dataall[,-c(1,2)]), xlab="trials x genotypes", ylab="traits", axes=FALSE)

To use the function, we first calculate the covariance matrices from all the trials. Then we turn these into positive definite correlation matrices to likelihood convergence failures due to differences in the scaling of variables. The lis to covariance / correlation matrices become the input to the function .

covlist<-lapply(BarleyPheno, function(x){cov(x,use="pairwise.complete.obs")})
covlist<-lapply(covlist,function(x){cov2cor(as.matrix(Matrix::nearPD(x)$mat))})
mean(c(unlist(lapply(covlist,function(x){nrow(x)}))))
## [1] 6.113402
BigK<-CovComb(Klist=covlist, maxiter=1000,  loglik = TRUE, plotll = TRUE)

Combined covariance matrix has 67 traits. Some of the relationships in this estimated relationship matrix have never been observed but wer infered by the Wishart EM algorithm.

dim(BigK[[1]])
## [1] 67 67

We can visualise the estimated phenomic covariance matrix.

heatmap(as.matrix(BigK[[1]]), cexRow = .2,cexCol = .2)

Adding sparsity to the estimated covariance

Once the covariance matrix is obtained sparsity can be introduced using many of the modern sparse covariance estimation methods, for example, the packages , , , etc,…, can be used to fit sparse covariance estimators.

Graph_lasso <- qgraph::qgraph(BigK[[1]], graph = "cor", directed=FALSE,details = FALSE,esize = 10,sampleSize=3000, layout="spring",nodeNames = rownames(BigK[[1]]),threshold = "hochberg", legend.cex=.15)

The Wishart EM-Algorithm

In this section, we briefly describe the estimation algorithm.

Let A = {a1, a2, …, am} be the set of not necessarily disjoint subsets of genotypes covering a set of K (i.e., K = ∪i = 1mai) with total n genotypes. Let Ga1, Ga2, …, Gam be the corresponding sample of covariance matrices.

Starting from an initial estimate Σ(0) = νΨ(0), the Wishart EM-Algorithm repeats updating the estimate of the covariance matrix until convergence: where Bb|a(t) = Ψab(t)(Ψaa(t))−1, Ψbb|a(t) = Ψbb(t) − Ψab(t)(Ψaa(t))−1Ψba(t), a is the set of genotypes in the given partial covariance matrix and b is the set difference of K and a. The matrices Pa are permutation matrices that put each matrix in the sum in the same order. The initial value, Σ(0) is usually assumed to be an identity matrix of dimesion n. The estimate Ψ(T) at the last iteration converts to the estimated covariance with Σ(T) = νΨ(T).

A weighted version of this algorithm can be obtained replacing Gaa in Equation~ with Gaa(wa) = waGaa + (1 − wa)νΨ(T) for a vector of weights (w1, w2, …, wm)′.

References

Adventures in Multi-Omics I: Combining heterogeneous data sets via relationships matrices Deniz Akdemir, Julio Isidro Sanchez, November 2019; https://www.biorxiv.org/content/10.1101/857425v1.

qgraph: Network Visualizations of Relationships in Psychometric Data. Sacha Epskamp, Angelique O. J. Cramer, Lourens J. Waldorp, Verena D. Schmittmann, Denny Borsboom (2012). Journal of Statistical Software, 48(4), 1-18. http://www.jstatsoft.org/v48/i04/.