Correlation mutual rank calculation
1
1
Entering edit mode
5.4 years ago
pr2009 ▴ 10

Hi

I have a correlation matrix for 34704 genes (size: 24GB). Is it possible to calculate the mutual rank of this file in R studio?

# correlation rank matrix
R <- t(apply(1-C, 1, rank))

# mutual rank matrix
M <- sqrt(R * t(R))
R gene correlation matrix • 2.4k views
ADD COMMENT
0
Entering edit mode

R studio is a development environment/tool, R is the language. You're looking for a solution in R, not R studio.

Please use the formatting bar (especially the code option) to present your post better. I've done it for you this time.
code_formatting

ADD REPLY
0
Entering edit mode

Thank you for your suggestions.

I am aware of the difference between R and R studio. My question was whether I can use a big file of 24GB in R studio (Desktop)

Apologies for not being clear.

Best Regards

ADD REPLY
0
Entering edit mode

You can do it in RStudio as long as your computer does have enough RAM. The main issue will probably be the time it takes to read the file.

ADD REPLY
4
Entering edit mode
5.4 years ago

The correlation ranks have to be calculated relative to each gene separately. Try something like this:

R <- matrix(NA, nrow = number.of.genes, ncol = number.of.genes)   
# Compute correlation ranks for each gene
for(i in 1:number.of.genes) {
    # Rank all genes relative to gene i
    # Use 1-cor() because rank() uses ascending order
    R[i,] <- rank(apply(gene.data, 1, function(x) 1-cor(t(gene.data[i,]),x)))
}
M <- sqrt(R *t(R)) # Mutual rank
ADD COMMENT
0
Entering edit mode

Thank you for getting back. Much appreciated.

ADD REPLY

Login before adding your answer.

Traffic: 3030 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6