<p>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 <code>M</code> 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 <code>M</code> all seems to be positively correlated but when i used the <code>corr</code> i get plot which shows my cell types are both positively and negatively correlated .</p>

<p>Im posting my code below as well as the plot along with the data</p>

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

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




names(gen)
dim(gen)

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



ord &lt;- corrMatOrder(corr, order="hclust")
newcolours &lt;- 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)
</code></pre>

<p><a href="https://i.sstatic.net/AKvoq.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/AKvoq.jpg" alt="plot when the corr matrix is used "></a></p>

<p><a href="https://i.sstatic.net/obO8f.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/obO8f.jpg" alt="plot when i the M matrix is used"></a></p>

<p>I would like to know what is happening in both the cases</p>

<p><a href="https://drive.google.com/open?id=1DJLEg-jYiQxWH8EIWCIRcoZyG9wmxq3d" rel="nofollow noreferrer">data file</a></p>

CC BY-SA 4.0
2018-12-17T18:00:49.587Z
`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)?`
GWW
CC BY-SA 4.0
2018-12-17T18:22:53.837Z
my goodness that is the mistake im doing.
kcm
<r><visualization>
corrplot issue with correlation plot output
# corrplot issue with correlation plot output

(Asked by: username_0 on 2018-12-17)

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)



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

**Tags:** r, visualization
> **Comments:**
> **username_1**: `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)?`  
> **username_0**: my goodness that is the mistake im doing.  

---

## 0 answers

