2
$\begingroup$

Very conceptual doubt not sure if im doing it right or something terribly wrong so im using this corrplot library to calucate the correlation of my desired data frame after that i rounding it off but when i use my original calculated matrix such as M i get a different plot again when i used the round of matrix i get a different plot in terms of correlation ,in case of M all seems to be positively correlated but when i used the corr i get plot which shows my cell types are both positively and negatively correlated .

Im posting my code below as well as the plot along with the data

library(corrplot)
gendat = read.csv("NEW_RBP/TF_MYELOID_DISEASE.txt",row.names = 1,sep = "\t")

dim(gendat)
head(gendat)
gen <- gendat
head(gen)
M<- cor(gen, use="complete.obs", method="spearman")
corr <- round(cor(M),1)




names(gen)
dim(gen)

mycolors <- rep(NA,23)
names(mycolors) <- names(gen)
mycolors[1:4]   <- 'black' # mpg, cyl, disp, hp
mycolors[5:15]   <- 'red'   # drat, wt, qsec, vs, am
mycolors[16:23] <- 'blue'
mycolors[13:16] <- 'darkgreen'



ord <- corrMatOrder(corr, order="hclust")
newcolours <- mycolors[ord]
newcolours
corrplot(M, tl.col = newcolours, method = "color",is.corr = FALSE, 
         tl.srt = 45,diag = TRUE
         ,order = "hclust",hclust.method = c("complete"),addrect = 5,tl.cex = 3,number.cex=1.5)

corrplot(corr, tl.col = newcolours, method = "color",is.corr = TRUE, 
         tl.srt = 45,diag = TRUE
         ,order = "hclust",hclust.method = c("complete"),addrect = 3,tl.cex = 3,number.cex=1.5)

plot when the corr matrix is used

plot when i the M matrix is used

I would like to know what is happening in both the cases

data file

$\endgroup$
2
  • 3
    $\begingroup$ corr <- round(cor(M),1) Are you supposed to be calling cor on the result of your previous call to cor? should it just be round(M, 1)? $\endgroup$
    – GWW
    Dec 17 '18 at 18:00
  • $\begingroup$ my goodness that is the mistake im doing. $\endgroup$
    – kcm
    Dec 17 '18 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.