Skip to content

Instantly share code, notes, and snippets.

@dceoy
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dceoy/5f3d99084d604b847447 to your computer and use it in GitHub Desktop.
Save dceoy/5f3d99084d604b847447 to your computer and use it in GitHub Desktop.
#!/usr/bin/env Rscript
sapply(c('data.table', 'ggplot2'), function(p) require(p, character.only = TRUE))
mtx <- fread('matrix.csv')
heatmap <- ggplot(mtx, aes(x = col, y = row, fill = val)) +
geom_tile() +
scale_fill_gradient(trans = 'log', breaks = c(10, 100, 1000), low = 'grey', high = 'blue') +
labs(x = 'col', y = 'row')
svg('plot.svg', width = 6, height = 4)
plot(heatmap)
dev.off()
row col val
row0 col0 10.782
row0 col1 18.3689
row0 col2 4713.28
row0 col3 4.58176
row0 col4 349.105
row0 col5 6.92234
row1 col0 3315.05
row1 col1 5.67067
row1 col2 127.719
row1 col3 4.56595
row1 col4 39.2351
row1 col5 136.642
row2 col0 8963.72
row2 col1 14.1904
row2 col2 7569.45
row2 col3 9.05674
row2 col4 554.454
row2 col5 302.104
row3 col0 27.704
row3 col1 2.84211
row3 col2 152.827
row3 col3 291.181
row3 col4 5123.77
row3 col5 1.49393
row4 col0 2.94534
row4 col1 598.22
row4 col2 1.14009
row4 col3 1341.9
row4 col4 2.76805
row4 col5 125.142
row5 col0 12.7248
row5 col1 868.679
row5 col2 7846.49
row5 col3 1996.11
row5 col4 1343.35
row5 col5 8744.93
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment