Arreglando la función ggcorrplot, que siempre llamaba a las columnas Cyt y Value.

This commit is contained in:
2022-02-06 08:40:51 +01:00
parent 62547fecd5
commit cb575ac297
2 changed files with 6 additions and 4 deletions
+3 -2
View File
@@ -1,5 +1,6 @@
ggcorrplot<-function(df, var, color="#FFFFFF00", stat="signif", tri="all", method="pearson"){ ggcorrplot<-function(df, var, value,color="#FFFFFF00", stat="signif", tri="all", method="pearson"){
m.df<-df %>% spread(Cyt, Value) %>% select(-pats) allnames<-colnames(df)
m.df<-df %>% spread(all_of(var), all_of(value)) %>% select(!any_of(allnames))
mcor<-cor(m.df, m.df, use="pairwise.complete.obs", method = method) # Por defecto usa el método de Pearson. mcor<-cor(m.df, m.df, use="pairwise.complete.obs", method = method) # Por defecto usa el método de Pearson.
mpval<-Hmisc::rcorr(as.matrix(m.df), type=method)$P mpval<-Hmisc::rcorr(as.matrix(m.df), type=method)$P
+3 -2
View File
@@ -2,11 +2,12 @@
\alias{ggcorrplot} \alias{ggcorrplot}
\title{ggcorrplot} \title{ggcorrplot}
\usage{ \usage{
ggcorrplot(df, var, color="#FFFFFF00", stat="signif", tri="all", method="pearson") ggcorrplot(df, var, value, color="#FFFFFF00", stat="signif", tri="all", method="pearson")
} }
\arguments{ \arguments{
\item{df}{A data frame in "long" format.} \item{df}{A data frame in "long" format.}
\item{var}{The column that will be used to analyze correlation all against all.} \item{var}{The column that will be used to analyze correlation all against all.}
\item{value}{The column that will be used as numeric data to analyze correlation.}
\item{color}{The color of the lines of geom_tile (the border). By default, its transparent.} \item{color}{The color of the lines of geom_tile (the border). By default, its transparent.}
\item{stat}{The stats that will be on the tiles. They can be "signif", "pval", "none". By default, it presents "signif" (stars representing pvalue).} \item{stat}{The stats that will be on the tiles. They can be "signif", "pval", "none". By default, it presents "signif" (stars representing pvalue).}
\item{tri}{It specifies which half of the correlation matrix is shown. Can be "all" (the default), "upper" or "lower".} \item{tri}{It specifies which half of the correlation matrix is shown. Can be "all" (the default), "upper" or "lower".}
@@ -25,5 +26,5 @@ df<-data.frame("pats"=paste0("PAT", 1:20), "CytA"=rnorm(20,5), "CytB"=rnorm(20,5
df<-gather(df, Cyt, Value,-pats) df<-gather(df, Cyt, Value,-pats)
head(df) head(df)
ggcorrplot(df, Cyt) ggcorrplot(df, Cyt, Value)
} }