Reppo for internal functions.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
763 B

  1. ggcorrplot<-function(df, var){
  2. m.df<-df %>% spread(Cyt, Value) %>% select(-pats)
  3. mcor<-cor(m.df, m.df, use="pairwise.complete.obs") # Por defecto usa el método de Pearson.
  4. mpval<-Hmisc::rcorr(as.matrix(m.df))$P
  5. df<-mcor %>% as.data.frame() %>% add_column(Var1=rownames(mcor),.before=1) %>%
  6. gather(Var2, Value, -Var1)
  7. df.pval<-mpval %>% as.data.frame() %>% add_column(Var1=rownames(mpval),.before=1) %>%
  8. gather(Var2, Value, -Var1)
  9. order<- mcor %>% as.data.frame() %>% add_column(Var1=rownames(mcor),.before=1) %>% clustsort
  10. ggplot(df, aes(Var1, Var2, fill=Value))+
  11. scale_x_discrete(limits=order$x)+
  12. scale_y_discrete(limits=order$y)+
  13. theme_heatmap(line.color="black")+
  14. geom_text(data=df.pval, aes(label=round(Value, 2)))
  15. }