Hi guys,
I have lots of submatrices where I need to compute proportionality between each other.
The code that Kevin Blighe gave it to me allows me to compute the proportionality only on one submatrix itself. I need to use this function to get what I want function(x) 1 - ((var(data[i,] - x)) / (var(data[i,]) + var(x)))
res <- foreach(i = seq_len(nrow(data)), #the matrix here is data
.combine = rbind,
.multicombine = TRUE,
.inorder = FALSE,
.packages = c('data.table', 'doParallel')) %dopar% {
apply(data, 2, function(x) 1 - ((var(data[i,] - x)) / (var(data[i,]) + var(x))))
}
I want to get the proportionnality between each submatrix. We suppose I have two matrices a and b which have the same dimensions.
I found this function which allows to compute the correlation between these two submatrices. What I would like to do is to implement my function into this code in order to get ALL the pairwise proportionality between all my submatrices a, b, c, d......
cor_blocks<- function(a,b) {
M <- rbind(a, b);
M <- M - rowMeans(M);
M <- M / sqrt(rowSums(M^2));
CR <- tcrossprod(M)
edge <- dim(a)[1]
CR <- t(cr[1:edge, -c(1:edge)])
return(CR)
}
Bests, Vincent
0 answers
No answers yet.
Log in to answer this question.
Hello vincentpailler!
We believe that this post does not fit the main topic of this site.
Not a bioinformatics question. Better ask on stackoverflow.com
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!
I post my problem here because it concerns compositional data (metagenomics data more particularly) .. I need to compute the proportionality between OTUs in order to make clusters then..
Before reinventing the wheel, did your try
bigcorpackage in R ? https://www.r-bloggers.com/bigcor-large-correlation-matrices-in-r/In fact, I tried it. The only problem I have, is that I work with compositional data. So, I can't use traditional methods. That's why I want to use the function I presented.
Not an expert in compositional data but check this : https://www.nature.com/articles/s41598-017-16520-0
I found the function I want to use in this paper. I tried to use this package too, but my main matrix is too big. That's why I want to split my matrix into submatrices, and then, compute the proportionality between each of them.
What I want to is only computing the proportionality from my function, between all pairwise combinations of matrices . Because my function only gives me the proportionality on one matrix..