|
\name{gglegend}
|
|
\alias{gglegend}
|
|
\title{gglegend}
|
|
\usage{
|
|
gglegend(data, x, y, var, stat="median", color="black", ...)
|
|
}
|
|
\arguments{
|
|
\item{data}{A data frame from where to take x and y axis, and the grouping variable.}
|
|
\item{x}{The variable that will be used for X axis in the heatmap.}
|
|
\item{y}{The variable that will be used for Y axis in the heatmap.}
|
|
\item{value}{The variable that will be used for grouping the heatmap. The labels will be taken from it}
|
|
\item{stat}{The statistical central test that will be used to calculate the label coordinates. "mean" or "median" are posible, defaulting to "median".}
|
|
\item{color}{The color of the labels, "black" by default. If NULL, nothig will be passed to the geom_label so it may be taken from aesthetics.}
|
|
\item{...}{Other arguments that will be passed to the geom_label function.}
|
|
}
|
|
\description{
|
|
Generates a geom_label object with labels in the center of each population or agrupation.
|
|
}
|
|
\examples{
|
|
library(tidyverse)
|
|
library(Rtsne)
|
|
library(Rphenograph)
|
|
library(igraph)
|
|
|
|
## We will generate an example using tSNE and Phenograph algorithms, but can be applied to any other situation.
|
|
|
|
iris_unique <- unique(iris) # Remove duplicates
|
|
iris_matrix <- as.matrix(iris_unique[,1:4])
|
|
|
|
# Set a seed if you want reproducible results
|
|
set.seed(42)
|
|
tsne_out <- Rtsne(iris_matrix,pca=FALSE,perplexity=30,theta=0.0) # Run TSNE
|
|
|
|
rpheno<-Rphenograph(tsne_out$Y)
|
|
df<-data.frame(as.data.frame(tsne_out$Y), "Clust"=factor(membership(rpheno[[2]])))
|
|
head(df)
|
|
|
|
ggplot(df, aes(V1,V2, color=Clust))+
|
|
geom_point()+
|
|
gglegend(df, V1, V2, Clust)+
|
|
guides(color="none")
|
|
|
|
}
|