Last active
November 25, 2015 01:12
-
-
Save Swarchal/3f18465a4455c402bef8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dat <- df_expression[,2:78] # numerical columns | |
rownames(dat) <- df_expression[,1] | |
row.order <- hclust(dist(dat))$order # clustering | |
col.order <- hclust(dist(t(dat)))$order | |
dat_new <- dat[row.order, col.order] # re-order matrix accoring to clustering | |
df_molten_dat <- melt(as.matrix(dat_new)) # reshape into dataframe | |
names(df_molten_dat)[c(1:2)] <- c("MouseID", "Protein") | |
ggplot(data = df_molten_dat, | |
aes(x = Protein, y = MouseID, fill = value)) + | |
geom_raster() + | |
scale_fill_distiller(palette = "RdYlBu", trans = "log10") + | |
theme(axis.text.x = element_text(angle = 90, hjust = 1), | |
axis.text.y = element_blank()) + | |
ggtitle("Clustered ggplot heatmap") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment