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.

22 lines
888 B

  1. ggcorrplot<-function(df, var, color="#FFFFFF00", stat="signif"){
  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. if (stat=="signif"){
  10. df.pval$Value<-gtools::stars.pval(as.numeric(df.pval$Value))
  11. }
  12. order<- mcor %>% as.data.frame() %>% add_column(Var1=rownames(mcor),.before=1) %>% clustsort
  13. ggplot(df, aes(Var1, Var2, fill=Value))+
  14. scale_x_discrete(limits=order$x)+
  15. scale_y_discrete(limits=order$y)+
  16. theme_heatmap(line.color=color)+
  17. geom_text(data=df.pval, aes(label=round(Value, 2)))
  18. }