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
m.row.sum<- cbind(m1, rowSums(m1)) | |
o1<- rev(order(m.row.sum[,602])) | |
m.row.sum<- m.row.sum[o1,] | |
bk = unique(c(seq(-0.1,3, length=100),seq(3,10.35,length=100))) | |
hmcols<- colorRampPalette(c("white","red"))(length(bk)-1) | |
pheatmap( m.row.sum[,1:601], cluster_rows = F, cluster_cols = F, col= hmcols, breaks = bk, legend=FALSE, show_rownames=FALSE, show_colnames=FALSE) |
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
#The X axis is -3 kb to 3 kb around TSS. | |
#It turns out that the heatmap.2 function use default hclust ( Hierachical Clustering) to cluster the #matrix. | |
#alternatively, we can use K-means clustering to cluster the data and to see what's the pattern look like. | |
km<- kmeans(m1,2) # determine how many cluster you want, I specify 2 here | |
m1.kmeans<- cbind(m1, km$cluster) # combine the cluster with the matrix | |
dim(m1.kmeans) |
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
# This R script is to generate the TF or histone modification heatmap | |
# at certain genomic features (TSS, enhancers) from the ChIP-seq data | |
# the input matrix is got from Homer software. alternative to R, use cluster3 to cluster, and visualize by # java Treeviewer | |
# generate the matrix by Homer: annotatePeaks.pl peak_file.txt hg19 -size 6000 -hist 10 -ghist -d TF1/ # > outputfile_matrix.txt | |
# see several posts for heatmap: | |
# http://davetang.org/muse/2010/12/06/making-a-heatmap-with-r/ | |
# http://www.r-bloggers.com/r-using-rcolorbrewer-to-colour-your-figures-in-r/ | |
# 08/20/13 by Tommy Tang | |
# it is such a simple script but took me several days to get it work...I mean the desired |
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
# Bland-Altman plot R function. | |
# Author: jmmateos@mce.hggm.es | |
baplot <- function(m1, m2, ...) { | |
# m1 and m2 are the measurements | |
means <- (m1 + m2) / 2 | |
diffs <- m1 - m2 | |
mdiff <- mean(diffs) | |
sddiff <- sd(diffs) | |
# Compute the figure limits |