diff plot.r @ 0:e3afe097e80a draft default tip

First commit
author moneycat
date Thu, 27 Jul 2017 22:24:59 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plot.r	Thu Jul 27 22:24:59 2017 -0400
@@ -0,0 +1,20 @@
+cluster_plot <- function(result){
+  library(ggdendro)
+  library(ggplot2)
+  hc=hclust(dist(as.matrix(rbind(result))))
+  cluster_plot=ggdendrogram(hc, theme_dendro = FALSE)+ labs(title="Cluster Dendrogram",x=NULL,y=NULL)
+  cluster_plot
+}
+
+bar_plot <- function(result){
+  library(ggplot2)
+  library(reshape2)
+  library(plyr)
+  df.m <- melt(result)
+  df.m <- rename(df.m, c(Var1 = "Sample", Var2 = "Cell_type"))
+  a <- ggplot(df.m,aes(x=Sample,y=value,fill=Cell_type))+labs(x=NULL, y="Cell %",fill = NULL,title = "Barplot")
+  bar_plot <- a + geom_bar(stat = "identity", position = "stack")
+  immigration_theme <- theme_update(axis.text.x = element_text(angle = 90))
+  bar_plot
+}
+