|
@ -1,12 +1,21 @@ |
|
|
ggcorrplot<-function(df, var, color="#FFFFFF00", stat="signif"){ |
|
|
|
|
|
|
|
|
ggcorrplot<-function(df, var, color="#FFFFFF00", stat="signif", tri="all"){ |
|
|
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 |
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
df<-mcor %>% as.data.frame() |
|
|
|
|
|
if (tri == "lower"){ |
|
|
|
|
|
df[lower.tri(df, diag=T)]<-NA |
|
|
|
|
|
} |
|
|
|
|
|
df<-df %>% add_column(Var1=rownames(mcor),.before=1) %>% |
|
|
|
|
|
gather(Var2, Value, -Var1) %>% filter(!is.na(Value)) |
|
|
|
|
|
|
|
|
|
|
|
df.pval<-mpval %>% as.data.frame() |
|
|
|
|
|
if (tri == "lower"){ |
|
|
|
|
|
df.pval[lower.tri(df.pval, diag=T)]<-NA |
|
|
|
|
|
} |
|
|
|
|
|
df.pval<-df.pval %>% add_column(Var1=rownames(mpval),.before=1) %>% |
|
|
|
|
|
gather(Var2, Value, -Var1) %>% filter(!is.na(Value)) |
|
|
|
|
|
|
|
|
df.pval$Value<-round(df.pval$Value, 3) |
|
|
df.pval$Value<-round(df.pval$Value, 3) |
|
|
|
|
|
|
|
|