Corrplot heatmap crunched up and unreadable
0
0
Entering edit mode
22 months ago
mropri ▴ 150

I have the following code which created a heatmap for my correlation matrix.

corrplot(cor, method = "circle", type = "full", is.corr = TRUE, p.mat = pAdj, sig.level = 0.05, insig = "label_sig" )

my matrix cor has 816 rows and 11 columns. is there a way I can stretch the heatmap so it is readable. At the moment it looks like this:

enter image description here

Corrplot heatmap • 1.9k views
ADD COMMENT
0
Entering edit mode

Play around with it. What have you tried to do by yourself before deciding to ask people here?

How is your cor matrix not square? Have you understood what corrplot needs or are you just passing it your raw matrix?

ADD REPLY
0
Entering edit mode

Looking at your past posts, it looks like you're asking here where you could just be Googling for answers. Please invest some effort and come to us only when you've tried your best.

ADD REPLY
0
Entering edit mode

Hi Ram,

Thank you for your help. I have tried multiple ways and researching on google. I tried playing with the par function to correct margin size and other ways to stretch out the heatmap. Also, i kept order = "original" since my matrix is not square and yes it is a matrix of correlations. I have tried my best, but I am sorry for the bother and will keep trying. Thank you again for the help.

ADD REPLY
0
Entering edit mode

The raw 816x11 matrix should work and you should see 11 rows and 11 columns in your corrplot. Your reasoning for order doesn't really make sense - it doesn't matter that your matrix is not square as it looks like the order is applied after internally creating the correlation square matrix.

For starters, try creating the corr matrix yourself. What does cor(the_816_by_11_data) give you? It should give you a 11-by-11 array. I think your data is being transposed somehow into 11 by 816 instead of 816 by 11.

ADD REPLY
0
Entering edit mode

Hi Ram,

I created the cor matrix myself and then gave it as an input into the corrplot function.

enter image description here

The reason I am confused is because when I plot the upper triangle of the matrix it looks like what I want. However when I do the full matrix plot it gets crunched up. The cor data frame I have is 816 rows by 11 columns data frame.

ADD REPLY
0
Entering edit mode

Can you show me head(rownames(cor)) and head(colnames(cor))?

ADD REPLY
0
Entering edit mode
head(rownames(cor))

[1] "1433E_HUMAN" "1433F_HUMAN" "1433G_HUMAN" "1433S_HUMAN" "1433Z_HUMAN" "4F2_HUMAN" 


head(colnames(cor))

[1] "bam"            "tau"             "Ab40.Mean.Conc." "Ab42.Mean.Conc." "Tau.Mean.Conc." 
[6] "NFL.Mean.Conc."
ADD REPLY
0
Entering edit mode

Try this:

cor2 <- cor
rownames(cor2) <- NULL
corrplot(cor2, ...)
ADD REPLY
0
Entering edit mode

Tried it out, produces this:

enter image description here

I feel its plotting it fine, its just a large matrix so the figure just needs to be enlarged. Appreciate your help on this and sorry for the bother. I will try it out and if I can not get it, not a big deal.

ADD REPLY
0
Entering edit mode

Can you show me your full code please? Maybe that'll help debug what's happening. If that doesn't solve it, we can look at your full dataset.

ADD REPLY
0
Entering edit mode

Sorry for the late response. Here is my code and you truly are helpful. Cannot thank you enough

y = as.matrix(datTraitsProt)  #matrix of trait values
x = as.matrix(norm_prot2)    #matrix of protein expression values

test <- corr.test(x, y, method="spearman", adjust="BH")  # getting correlation #between protein expression and traits

par(mar = c(.1, .1, .1, .1))

pAdj <- test$p.adj     # getting FDR adjusted p-values
cor <- test$r             # getting correlation values between the two matrices

cor2 <- cor
rownames(cor2) <- NULL

corrplot(cor2, method = "circle", type = "full", is.corr = FALSE, p.mat = pAdj, sig.level = 0.05, insig = "label_sig" )
ADD REPLY
0
Entering edit mode

This does not make sense to me. I thought you were correlating one matrix's columns against one another, not 2 matrices.

Can you show me the output to:

xsub1 <- as.matrix(datTraitsProt[1:5,1:5])
ysub1 <- as.matrix(norm_prot2[1:5,1:5])
corrsub1 <- corr.test(xsub1, ysub1, ...) #other params from your call
corrsub1$p.adj
corrsub1$r
ADD REPLY
0
Entering edit mode

enter image description here

ADD REPLY
0
Entering edit mode

I think the matrix is just too big for it to be readable. Because the code the you asked me to give the output gives the plot perfectly fine.

ADD REPLY

Login before adding your answer.

Traffic: 2681 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