Skip to content

Instantly share code, notes, and snippets.

@YulongNiu
Created April 24, 2019 17:39
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 YulongNiu/c88f5e9420d2ce6b8496d48b4a1237d2 to your computer and use it in GitHub Desktop.
Save YulongNiu/c88f5e9420d2ce6b8496d48b4a1237d2 to your computer and use it in GitHub Desktop.
R heatmap for Ja Yong (zeros and positive number)
library('pheatmap')
##~~~~~~~~~~~~~~~~~~simulating data~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rn <- 100
cn <- 12
testdat <- matrix(rnorm(rn * cn), rn, cn)
testdat[1 : (rn/2), seq(1, cn, 2)] <- testdat[1 : (rn/2), seq(1, cn, 2)] + 5
testdat[(rn/2 + 1) : rn, seq(2, cn, 2)] <- testdat[(rn/2 + 1) : rn, seq(2, cn, 2)] + 7
testdat <- apply(testdat, 1:2, function(x) ifelse(x < 0, 0, x))
colnames(testdat) <- paste('Sample', 1 : cn, sep = "")
rownames(testdat) <- paste('Protein', 1 : rn, sep = "")
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pheatmap(testdat, fontsize_row = 3)
pheatmap(testdat, color = colorRampPalette(c('navy', 'white', 'firebrick3'))(50), fontsize_row = 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment