Compare commits
2 Commits
0f3f1f86a0
...
7d03719bf3
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d03719bf3 | |||
| ece3a80215 |
@@ -0,0 +1,18 @@
|
|||||||
|
ggcorrplot<-function(df, var){
|
||||||
|
m.df<-df %>% spread(Cyt, Value) %>% select(-pats)
|
||||||
|
mcor<-cor(m.df, m.df, use="pairwise.complete.obs") # Por defecto usa el método de Pearson.
|
||||||
|
mpval<-Hmisc::rcorr(as.matrix(m.df))$P
|
||||||
|
|
||||||
|
df<-mcor %>% as.data.frame() %>% add_column(Var1=rownames(mcor),.before=1) %>%
|
||||||
|
gather(Var2, Value, -Var1)
|
||||||
|
df.pval<-mpval %>% as.data.frame() %>% add_column(Var1=rownames(mpval),.before=1) %>%
|
||||||
|
gather(Var2, Value, -Var1)
|
||||||
|
|
||||||
|
order<- mcor %>% as.data.frame() %>% add_column(Var1=rownames(mcor),.before=1) %>% clustsort
|
||||||
|
|
||||||
|
ggplot(df, aes(Var1, Var2, fill=Value))+
|
||||||
|
scale_x_discrete(limits=order$x)+
|
||||||
|
scale_y_discrete(limits=order$y)+
|
||||||
|
theme_heatmap(line.color="black")+
|
||||||
|
geom_text(data=df.pval, aes(label=round(Value, 2)))
|
||||||
|
}
|
||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
theme_heatmap<-function(x){
|
theme_heatmap<-function(x,line.color="#FFFFFF00"){
|
||||||
list(geom_tile(),
|
list(geom_tile(color=line.color),
|
||||||
scale_fill_gradientn(colors=col2(200)),
|
scale_fill_gradientn(colors=col2(200)),
|
||||||
theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust=0.5),
|
theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust=0.5),
|
||||||
panel.background = element_blank(),
|
panel.background = element_blank(),
|
||||||
|
|||||||
Reference in New Issue
Block a user