Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ############################
- ### CREATE EMBEDSOM PLOT ###
- ############################
- #you might need this:
- #devtools::install_github('exaexa/EmbedSOM')
- set.seed(1234)
- # run FlowSOM (initial steps prior to meta-clustering)
- out <- FlowSOM::ReadInput(data_FlowSOM, transform = FALSE, scale = FALSE)
- out <- FlowSOM::BuildSOM(out)
- esom <- EmbedSOM::EmbedSOM(out, smooth=1,k=20)
- # load cluster labels (if not still loaded)
- labels <- paste(raw_data,"_cluster.txt")
- #data_labels <- read.table(file_labels, header = TRUE, sep = "\t", stringsAsFactors = FALSE)
- labels <- r_data[, "cluster"]
- data_plot <- data.frame(EmbedSOM1=esom[,1], EmbedSOM2=esom[,2], Cluster=labels)
- ggsave("embedsom.png", dpi=100,
- ggplot(data_plot, aes(x = EmbedSOM1, y = EmbedSOM2, color = Cluster)) +
- geom_point(aes(colour = as.factor(labels)),
- size = .5, alpha=.3) +
- scale_color_manual(name = "Cluster",
- values = c("1" = "#F8766D",
- "2" = "#CD9600",
- "3" = "#7CAE00",
- "4" = "#00BE67",
- "5" = "#00BFC4",
- "6" = "#00A9FF",
- "7" = "#C77CFF",
- "8" = "#FF61CC")) +
- guides(colour = guide_legend(override.aes = list(size=5))) +
- coord_fixed(ratio = 1) +
- ggtitle(paste0("EmbedSOM: ",raw_data)) +
- theme(plot.title = element_text(size = 10, face = "bold"),panel.background = element_rect(fill='white', colour='white'))
- )
- ggsave("embedsom-contour.png", dpi=100,
- ggplot(data_plot, aes(x = EmbedSOM1, y = EmbedSOM2, color = Cluster)) +
- geom_point(aes(colour = as.factor(labels)),
- size = .5, alpha=.3) +
- geom_density_2d(bins=6, color='black') +
- scale_color_manual(name = "Cluster",
- values = c("1" = "#F8766D",
- "2" = "#CD9600",
- "3" = "#7CAE00",
- "4" = "#00BE67",
- "5" = "#00BFC4",
- "6" = "#00A9FF",
- "7" = "#C77CFF",
- "8" = "#FF61CC")) +
- guides(colour = guide_legend(override.aes = list(size=5))) +
- coord_fixed(ratio = 1) +
- ggtitle(paste0("EmbedSOM: ",raw_data)) +
- theme(plot.title = element_text(size = 10, face = "bold"),panel.background = element_rect(fill='white', colour='white'))
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement