annotate plot.r @ 0:e3afe097e80a draft default tip

First commit
author moneycat
date Thu, 27 Jul 2017 22:24:59 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e3afe097e80a First commit
moneycat
parents:
diff changeset
1 cluster_plot <- function(result){
e3afe097e80a First commit
moneycat
parents:
diff changeset
2 library(ggdendro)
e3afe097e80a First commit
moneycat
parents:
diff changeset
3 library(ggplot2)
e3afe097e80a First commit
moneycat
parents:
diff changeset
4 hc=hclust(dist(as.matrix(rbind(result))))
e3afe097e80a First commit
moneycat
parents:
diff changeset
5 cluster_plot=ggdendrogram(hc, theme_dendro = FALSE)+ labs(title="Cluster Dendrogram",x=NULL,y=NULL)
e3afe097e80a First commit
moneycat
parents:
diff changeset
6 cluster_plot
e3afe097e80a First commit
moneycat
parents:
diff changeset
7 }
e3afe097e80a First commit
moneycat
parents:
diff changeset
8
e3afe097e80a First commit
moneycat
parents:
diff changeset
9 bar_plot <- function(result){
e3afe097e80a First commit
moneycat
parents:
diff changeset
10 library(ggplot2)
e3afe097e80a First commit
moneycat
parents:
diff changeset
11 library(reshape2)
e3afe097e80a First commit
moneycat
parents:
diff changeset
12 library(plyr)
e3afe097e80a First commit
moneycat
parents:
diff changeset
13 df.m <- melt(result)
e3afe097e80a First commit
moneycat
parents:
diff changeset
14 df.m <- rename(df.m, c(Var1 = "Sample", Var2 = "Cell_type"))
e3afe097e80a First commit
moneycat
parents:
diff changeset
15 a <- ggplot(df.m,aes(x=Sample,y=value,fill=Cell_type))+labs(x=NULL, y="Cell %",fill = NULL,title = "Barplot")
e3afe097e80a First commit
moneycat
parents:
diff changeset
16 bar_plot <- a + geom_bar(stat = "identity", position = "stack")
e3afe097e80a First commit
moneycat
parents:
diff changeset
17 immigration_theme <- theme_update(axis.text.x = element_text(angle = 90))
e3afe097e80a First commit
moneycat
parents:
diff changeset
18 bar_plot
e3afe097e80a First commit
moneycat
parents:
diff changeset
19 }
e3afe097e80a First commit
moneycat
parents:
diff changeset
20