# Can you model a correlations as a dependent variable?

I am working on a dataset where each the data for each individual can be seen as a vector of numbers between zero and one. To be precise, this is the methylation level at each cytosine in the genome. We are interested in the extent to which methylation depends on the genotype of the individual, the environment it is grown in and the interaction between genotype and environment. We have replicate individuals from 10 genotypes grown in four experimental sites.

So far I have taken the mean over the vector for each individuals and estimated the variance due to genotype, site and their interaction between those means. Here is some R code to simulate a comparable data set of vectors of 100 elements of zeroes and ones for each individual (in reality there would be ~30 million elements for each individual):

# Simulate true methylation levels for four sites and 10
# genotypes.
p <- expand.grid(
env   = rbeta(4, 1, 10),
geno = rbeta(10, 1,10)
)
p$$sum <- p$$env + p$geno # 6 replicates per site-genotype combination p <- p[rep(1:nrow(p), each = 6), ] # Simulate a matrix of genomes of 100 elements, where each row is # a vector for a single individual genomes <- sapply(p$sum, function(x) rbinom(100, 1, x))

# Create a data frame for mean methylation
dat = expand.grid(
env = paste('env_', LETTERS[1:4], sep=""),
geno = paste('geno_', LETTERS[1:10], sep="")
)
dat <- dat[rep(1:nrow(dat), each=6), ]
# Column for genome-wide methylation
dat\$mean_methylation <- colMeans(genomes)

# Fit a model
library("lme4")
lmer(mean_methylation ~ (1 | env) + (1 | geno) + (1 | geno:env),
data = dat)


(I am aware that you probably wouldn't model proportion data with lmer, but this will do for an example)

However, we suspect that this is not entirely biologically appropriate, and we are really interested in (a summary of) differences at individual elements of vectors between pairs of individuals. It is straightforward to calculate correlations between vectors for each pair of individuals, but I don't know how to scale this to modelling the effects of genotype, environment and their interaction.

So, my question is: is there some kind of (regression?) framework for modelling similarities between pairs of individuals?

I had thought of somehow modelling a covariance matrix as a response variable in a similar way to how we use covariance matrices as explanatory variables as random effects, but I haven't found any helpful sources about this. Obviously I cannot just use pairwise correlations as a 'standard' response variable, because they would not be independent and confidence intervals would be artificially shrunk. It also seems that it would be difficult to model the whole vector as a multivariate response, because they are massive (~30 million elements).

• We wrote something about regression of distances and the involved dependence issue here: onlinelibrary.wiley.com/doi/pdfdirect/10.1111/1755-0998.13184 Not sure whether this makes sense in your situation; the hypotheses you may want to test may be simpler (just coefficient=0?). Mantel or partial Mantel tests as discussed in Sec. 4.2 may apply to your situation. As far as I did literature research on this at the time, there isn't much else. Commented Oct 4, 2021 at 11:21
• Just to add (if this was not already clear) that the issue with correlations and "similarities" is really the same as with distances, so those methods should appy to correlations as well. Commented Oct 4, 2021 at 11:23