Created
April 24, 2019 17:39
-
-
Save YulongNiu/c88f5e9420d2ce6b8496d48b4a1237d2 to your computer and use it in GitHub Desktop.
R heatmap for Ja Yong (zeros and positive number)
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
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