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.

43 lines
1.6 KiB

  1. \name{gglegend}
  2. \alias{gglegend}
  3. \title{gglegend}
  4. \usage{
  5. gglegend(data, x, y, var, stat="median", color="black", ...)
  6. }
  7. \arguments{
  8. \item{data}{A data frame from where to take x and y axis, and the grouping variable.}
  9. \item{x}{The variable that will be used for X axis in the heatmap.}
  10. \item{y}{The variable that will be used for Y axis in the heatmap.}
  11. \item{value}{The variable that will be used for grouping the heatmap. The labels will be taken from it}
  12. \item{stat}{The statistical central test that will be used to calculate the label coordinates. "mean" or "median" are posible, defaulting to "median".}
  13. \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.}
  14. \item{...}{Other arguments that will be passed to the geom_label function.}
  15. }
  16. \description{
  17. Generates a geom_label object with labels in the center of each population or agrupation.
  18. }
  19. \examples{
  20. library(tidyverse)
  21. library(Rtsne)
  22. library(Rphenograph)
  23. library(igraph)
  24. ## We will generate an example using tSNE and Phenograph algorithms, but can be applied to any other situation.
  25. iris_unique <- unique(iris) # Remove duplicates
  26. iris_matrix <- as.matrix(iris_unique[,1:4])
  27. # Set a seed if you want reproducible results
  28. set.seed(42)
  29. tsne_out <- Rtsne(iris_matrix,pca=FALSE,perplexity=30,theta=0.0) # Run TSNE
  30. rpheno<-Rphenograph(tsne_out$Y)
  31. df<-data.frame(as.data.frame(tsne_out$Y), "Clust"=factor(membership(rpheno[[2]])))
  32. head(df)
  33. ggplot(df, aes(V1,V2, color=Clust))+
  34. geom_point()+
  35. gglegend(df, V1, V2, Clust)+
  36. guides(color="none")
  37. }