Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. ############################
  2. ### CREATE EMBEDSOM PLOT ###
  3. ############################
  4.  
  5. #you might need this:
  6. #devtools::install_github('exaexa/EmbedSOM')
  7.  
  8. set.seed(1234)
  9.  
  10. # run FlowSOM (initial steps prior to meta-clustering)
  11. out <- FlowSOM::ReadInput(data_FlowSOM, transform = FALSE, scale = FALSE)
  12. out <- FlowSOM::BuildSOM(out)
  13.  
  14. esom <- EmbedSOM::EmbedSOM(out, smooth=1,k=20)
  15.  
  16. # load cluster labels (if not still loaded)
  17. labels <- paste(raw_data,"_cluster.txt")
  18. #data_labels <- read.table(file_labels, header = TRUE, sep = "\t", stringsAsFactors = FALSE)
  19.  
  20. labels <- r_data[, "cluster"]
  21.  
  22.  
  23. data_plot <- data.frame(EmbedSOM1=esom[,1], EmbedSOM2=esom[,2], Cluster=labels)
  24.  
  25. ggsave("embedsom.png", dpi=100,
  26. ggplot(data_plot, aes(x = EmbedSOM1, y = EmbedSOM2, color = Cluster)) +
  27. geom_point(aes(colour = as.factor(labels)),
  28. size = .5, alpha=.3) +
  29. scale_color_manual(name = "Cluster",
  30. values = c("1" = "#F8766D",
  31. "2" = "#CD9600",
  32. "3" = "#7CAE00",
  33. "4" = "#00BE67",
  34. "5" = "#00BFC4",
  35. "6" = "#00A9FF",
  36. "7" = "#C77CFF",
  37. "8" = "#FF61CC")) +
  38. guides(colour = guide_legend(override.aes = list(size=5))) +
  39. coord_fixed(ratio = 1) +
  40. ggtitle(paste0("EmbedSOM: ",raw_data)) +
  41. theme(plot.title = element_text(size = 10, face = "bold"),panel.background = element_rect(fill='white', colour='white'))
  42. )
  43.  
  44.  
  45. ggsave("embedsom-contour.png", dpi=100,
  46. ggplot(data_plot, aes(x = EmbedSOM1, y = EmbedSOM2, color = Cluster)) +
  47. geom_point(aes(colour = as.factor(labels)),
  48. size = .5, alpha=.3) +
  49. geom_density_2d(bins=6, color='black') +
  50. scale_color_manual(name = "Cluster",
  51. values = c("1" = "#F8766D",
  52. "2" = "#CD9600",
  53. "3" = "#7CAE00",
  54. "4" = "#00BE67",
  55. "5" = "#00BFC4",
  56. "6" = "#00A9FF",
  57. "7" = "#C77CFF",
  58. "8" = "#FF61CC")) +
  59. guides(colour = guide_legend(override.aes = list(size=5))) +
  60. coord_fixed(ratio = 1) +
  61. ggtitle(paste0("EmbedSOM: ",raw_data)) +
  62. theme(plot.title = element_text(size = 10, face = "bold"),panel.background = element_rect(fill='white', colour='white'))
  63. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement