#' Assigning labels to the metaclusters
#'
#' This function takes the object from emb(), user need to assign
#' the label_names and this function will generate a labeled plot
#'
#'
#' @param input An object from emb().
#' @param labels_names User defined labels.
#' @return A labeled plot.
#' @import tibble ggplot2 magrittr dplyr tidyr
#' @export plotlabels
plotlabels <- function(input, labels_names){
if (is.null(labels_names)) {
print("No label provided!")
} else {
label<- input %>% select(EmbedSOM1,
EmbedSOM2, Metacluster) %>%
group_by(Metacluster) %>% summarize_all(median)
label$Metacluster <- labels_names
ggplot(input, aes(x = EmbedSOM2, y=EmbedSOM1, col=as.factor(Metacluster))) +
geom_point(size =0.2) + theme_bw() +
geom_label_repel(aes(label = Metacluster),
data = label) + guides(colour = FALSE) +
ggtitle("Labeled_Plot")
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.