Browse Source

Añadiendo la opción (por defecto) de mostrar pvalue como estrellas.

main
Costa 2 years ago
parent
commit
4db08dc4f4
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      R/ggcorrplot.R

+ 5
- 1
R/ggcorrplot.R

@ -1,4 +1,4 @@
ggcorrplot<-function(df, var, color="#FFFFFF00"){
ggcorrplot<-function(df, var, color="#FFFFFF00", stat="signif"){
m.df<-df %>% spread(Cyt, Value) %>% select(-pats) 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. 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 mpval<-Hmisc::rcorr(as.matrix(m.df))$P
@ -8,6 +8,10 @@ ggcorrplot<-function(df, var, color="#FFFFFF00"){
df.pval<-mpval %>% as.data.frame() %>% add_column(Var1=rownames(mpval),.before=1) %>% df.pval<-mpval %>% as.data.frame() %>% add_column(Var1=rownames(mpval),.before=1) %>%
gather(Var2, Value, -Var1) gather(Var2, Value, -Var1)
if (stat=="signif"){
df.pval$Value<-gtools::stars.pval(df.pval$Value)
}
order<- mcor %>% as.data.frame() %>% add_column(Var1=rownames(mcor),.before=1) %>% clustsort order<- mcor %>% as.data.frame() %>% add_column(Var1=rownames(mcor),.before=1) %>% clustsort
ggplot(df, aes(Var1, Var2, fill=Value))+ ggplot(df, aes(Var1, Var2, fill=Value))+

Loading…
Cancel
Save