my.NPCgain.ordered
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_gained")
get_nuc_heatmaps <- function(my.ordered.matrix, my.tissue){
### get data range and scale for plotting (cf NGS plots hacked function)
m1 <- log2(my.ordered.matrix[,-1] +1e-6)
my.max <- max(m1)
bk <-  unique(c(seq(-0.1,3, length=100),seq(3,my.max,length=100)))
my.heat.cols <- c("white","skyblue","deepskyblue","dodgerblue","royalblue1","royalblue4","midnightblue")
#my.heat.cols <- c("white","snow","lavenderblush","lavender","plum1","mediumorchid","magenta3","purple","purple4")
#my.heat.cols <- c("white","snow","papayawhip","peachpuff","orangered","red1","red3","red4")
hmcols <- colorRampPalette(my.heat.cols)(length(bk)-1)
# export to png
my.pngname <- paste(Sys.Date(),my.tissue,"H3_ChIP_seq_heatmap.png",sep="_")
pheatmap( log2( my.ordered.matrix [,-1] +1e-6) , cluster_rows = F, cluster_cols = F,
col = hmcols, breaks = bk, show_rownames=FALSE, legend = F,
show_colnames = FALSE,
cellwidth = 0.75,
cellheight = 0.1,
filename = my.pngname
)
}
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_gained")
get_nuc_heatmaps <- function(my.ordered.matrix, my.tissue){
### get data range and scale for plotting (cf NGS plots hacked function)
m1 <- log2(my.ordered.matrix[,-1] +1e-6)
my.max <- max(m1)
bk <-  unique(c(seq(-0.1,3, length=100),seq(3,my.max,length=100)))
my.heat.cols <- c("snow","deepskyblue","dodgerblue","royalblue1","royalblue4","midnightblue")
#my.heat.cols <- c("white","snow","lavenderblush","lavender","plum1","mediumorchid","magenta3","purple","purple4")
#my.heat.cols <- c("white","snow","papayawhip","peachpuff","orangered","red1","red3","red4")
hmcols <- colorRampPalette(my.heat.cols)(length(bk)-1)
# export to png
my.pngname <- paste(Sys.Date(),my.tissue,"H3_ChIP_seq_heatmap.png",sep="_")
pheatmap( log2( my.ordered.matrix [,-1] +1e-6) , cluster_rows = F, cluster_cols = F,
col = hmcols, breaks = bk, show_rownames=FALSE, legend = F,
show_colnames = FALSE,
cellwidth = 0.75,
cellheight = 0.1,
filename = my.pngname
)
}
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_gained")
## get the heatmaps on reordered data
get_nuc_heatmaps <- function(my.ordered.matrix, my.tissue){
### get data range and scale for plotting (cf NGS plots hacked function)
m1 <- log2(my.ordered.matrix[,-1] +1e-6)
my.max <- max(m1)
bk <-  unique(c(seq(-0.1,3, length=100),seq(3,my.max,length=100)))
my.heat.cols <- c("snow","deepskyblue","dodgerblue","royalblue1","royalblue4")
hmcols <- colorRampPalette(my.heat.cols)(length(bk)-1)
# export to png
my.pngname <- paste(Sys.Date(),my.tissue,"H3_ChIP_seq_heatmap.png",sep="_")
pheatmap( log2( my.ordered.matrix [,-1] +1e-6) , cluster_rows = F, cluster_cols = F,
col = hmcols, breaks = bk, show_rownames=FALSE, legend = F,
show_colnames = FALSE,
cellwidth = 0.75,
cellheight = 0.1,
filename = my.pngname
)
}
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_gained")
get_nuc_heatmaps <- function(my.ordered.matrix, my.tissue){
### get data range and scale for plotting (cf NGS plots hacked function)
m1 <- log2(my.ordered.matrix[,-1] +1e-6)
my.max <- max(m1)
bk <-  unique(c(seq(-0.1,3, length=100),seq(3,my.max,length=100)))
my.heat.cols <- c("snow","deepskyblue","dodgerblue","royalblue4")
hmcols <- colorRampPalette(my.heat.cols)(length(bk)-1)
# export to png
my.pngname <- paste(Sys.Date(),my.tissue,"H3_ChIP_seq_heatmap.png",sep="_")
pheatmap( log2( my.ordered.matrix [,-1] +1e-6) , cluster_rows = F, cluster_cols = F,
col = hmcols, breaks = bk, show_rownames=FALSE, legend = F,
show_colnames = FALSE,
cellwidth = 0.75,
cellheight = 0.05,
filename = my.pngname
)
}
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_gained")
## get the heatmaps on reordered data
get_nuc_heatmaps <- function(my.ordered.matrix, my.tissue){
### get data range and scale for plotting (cf NGS plots hacked function)
m1 <- log2(my.ordered.matrix[,-1] +1e-6)
my.max <- max(m1)
bk <-  unique(c(seq(-0.1,3, length=100),seq(3,my.max,length=100)))
my.heat.cols <- c("snow","dodgerblue3","royalblue4")
hmcols <- colorRampPalette(my.heat.cols)(length(bk)-1)
# export to png
my.pngname <- paste(Sys.Date(),my.tissue,"H3_ChIP_seq_heatmap.png",sep="_")
pheatmap( log2( my.ordered.matrix [,-1] +1e-6) , cluster_rows = F, cluster_cols = F,
col = hmcols, breaks = bk, show_rownames=FALSE, legend = F,
show_colnames = FALSE,
cellwidth = 0.75,
cellheight = 0.05,
filename = my.pngname
)
}
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_gained")
### get the heatmaps on reordered data
get_nuc_heatmaps <- function(my.ordered.matrix, my.tissue){
### get data range and scale for plotting (cf NGS plots hacked function)
m1 <- log2(my.ordered.matrix[,-1] +1e-6)
my.max <- max(m1)
bk <-  unique(c(seq(-0.1,3, length=100),seq(3,my.max,length=100)))
my.heat.cols <- c("snow","dodgerblue3","royalblue3","royalblue4")
hmcols <- colorRampPalette(my.heat.cols)(length(bk)-1)
# export to png
my.pngname <- paste(Sys.Date(),my.tissue,"H3_ChIP_seq_heatmap.png",sep="_")
pheatmap( log2( my.ordered.matrix [,-1] +1e-6) , cluster_rows = F, cluster_cols = F,
col = hmcols, breaks = bk, show_rownames=FALSE, legend = F,
show_colnames = FALSE,
cellwidth = 0.75,
cellheight = 0.05,
filename = my.pngname
)
}
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_gained")
setwd('/Volumes/MyBook_3/BD_aging_project/ChIP-seq/All_tissues_analysis/Signal_analyses/Nucleosome_changes/')
source('Make_nucleosome_heatmaps_functions.R')
# 2017-03-08
# build heatmaps nucleosome remodeling
######################  NPCs  ######################
my.NPCgain <- read.csv('./Other_ref/NPCs_3-12-29m_H3_age_gain_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.NPCloss <- read.csv('./Other_ref/NPCs_3-12-29m_H3_age_lost_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.NPCgain.ordered <- get_kmeans_hclust(my.NPCgain)
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_gained")
my.NPCloss.ordered <- get_kmeans_hclust(my.NPCloss)
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_loss")
######################################################
######################  cereb  ######################
my.cerebgain <- read.csv('./Other_ref/Cerebellum_3-12-29m_H3_age_gain_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.cerebloss <- read.csv('./Other_ref/Cerebellum_3-12-29m_H3_age_lost_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.cerebgain.ordered <- get_kmeans_hclust(my.cerebgain)
get_nuc_heatmaps(my.cerebgain.ordered, "cerebellum_gained")
my.cerebloss.ordered <- get_kmeans_hclust(my.cerebloss)
get_nuc_heatmaps(my.cerebloss.ordered, "cerebellum_loss")
######################################################
######################  Heart  ######################
my.heartgain <- read.csv('./Other_ref/Heart_3-12-29m_H3_age_gain_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.heartloss <- read.csv('./Other_ref/Heart_3-12-29m_H3_age_lost_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.heartgain.ordered <- get_kmeans_hclust(my.heartgain)
get_nuc_heatmaps(my.heartgain.ordered, "heart_gained")
my.heartloss.ordered <- get_kmeans_hclust(my.heartloss)
options(stringsAsFactors=F)
library('pheatmap')
# process HOMER data for clustering and heatmaps
# do k-means clustering
get_kmeans_hclust <- function(my.matrix) {
my.centers = 100
rownames(my.matrix) <- my.matrix[,1]
km <- kmeans(my.matrix[,-1], centers=my.centers,iter.max=50, nstart=10, algorithm="Hartigan-Wong")
kHc<-hclust(dist(km$centers), method="centroid") # get an ordering of the clusters that makes more sense
my.reorder <- c()
for (i in 1:length(kHc$order)){
currentCluster <- kHc$order[i]
my.members.ids <- which(km$cluster == currentCluster)
my.line.nums <- names(km$cluster[my.members.ids])
my.reorder <- c(my.reorder,my.line.nums)
}
return(my.matrix[my.reorder,])
}
### get the heatmaps on reordered data
get_nuc_heatmaps <- function(my.ordered.matrix, my.tissue){
### get data range and scale for plotting (cf NGS plots hacked function)
m1 <- log2(my.ordered.matrix[,-1] +1e-6)
my.max <- max(m1)
bk <-  unique(c(seq(-0.1,3, length=100),seq(3,my.max,length=100)))
my.heat.cols <- c("snow","dodgerblue3","royalblue3","royalblue4")
hmcols <- colorRampPalette(my.heat.cols)(length(bk)-1)
# export to png
my.pngname <- paste(Sys.Date(),my.tissue,"H3_ChIP_seq_heatmap.png",sep="_")
pheatmap( log2( my.ordered.matrix [,-1] +1e-6) , cluster_rows = F, cluster_cols = F,
col = hmcols, breaks = bk, show_rownames=FALSE, legend = F,
show_colnames = FALSE,
cellwidth = 0.75,
cellheight = 0.01,
filename = my.pngname
)
}
setwd('/Volumes/MyBook_3/BD_aging_project/ChIP-seq/All_tissues_analysis/Signal_analyses/Nucleosome_changes/')
source('Make_nucleosome_heatmaps_functions.R')
# 2017-03-08
# build heatmaps nucleosome remodeling
######################  NPCs  ######################
my.NPCgain <- read.csv('./Other_ref/NPCs_3-12-29m_H3_age_gain_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.NPCloss <- read.csv('./Other_ref/NPCs_3-12-29m_H3_age_lost_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.NPCgain.ordered <- get_kmeans_hclust(my.NPCgain)
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_gained")
my.NPCloss.ordered <- get_kmeans_hclust(my.NPCloss)
get_nuc_heatmaps(my.NPCloss.ordered, "NPCs_loss")
######################################################
######################  cereb  ######################
my.cerebgain <- read.csv('./Other_ref/Cerebellum_3-12-29m_H3_age_gain_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.cerebloss <- read.csv('./Other_ref/Cerebellum_3-12-29m_H3_age_lost_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.cerebgain.ordered <- get_kmeans_hclust(my.cerebgain)
get_nuc_heatmaps(my.cerebgain.ordered, "cerebellum_gained")
my.cerebloss.ordered <- get_kmeans_hclust(my.cerebloss)
get_nuc_heatmaps(my.cerebloss.ordered, "cerebellum_loss")
######################################################
######################  Heart  ######################
my.heartgain <- read.csv('./Other_ref/Heart_3-12-29m_H3_age_gain_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.heartloss <- read.csv('./Other_ref/Heart_3-12-29m_H3_age_lost_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.heartgain.ordered <- get_kmeans_hclust(my.heartgain)
get_nuc_heatmaps(my.heartgain.ordered, "heart_gained")
my.heartloss.ordered <- get_kmeans_hclust(my.heartloss)
get_nuc_heatmaps(my.heartgain.ordered, "heart_loss")
######################################################
######################  Liver  ######################
my.livergain <- read.csv('./Other_ref/Liver_3-12-29m_H3_age_gain_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.liverloss <- read.csv('./Other_ref/Liver_3-12-29m_H3_age_lost_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.livergain.ordered <- get_kmeans_hclust(my.livergain)
get_nuc_heatmaps(my.livergain.ordered, "liver_gained")
my.liverloss.ordered <- get_kmeans_hclust(my.liverloss)
get_nuc_heatmaps(my.livergain.ordered, "liver_loss")
######################################################
######################  OB  ######################
my.OBgain <- read.csv('./Other_ref/Olfactory_Bulb_3-12-29m_H3_age_gain_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.OBloss <- read.csv('./Other_ref/Olfactory_Bulb_3-12-29m_H3_age_lost_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.OBgain.ordered <- get_kmeans_hclust(my.OBgain)
get_nuc_heatmaps(my.OBgain.ordered, "OB_gained")
my.OBloss.ordered <- get_kmeans_hclust(my.OBloss)
get_nuc_heatmaps(my.OBgain.ordered, "OB_loss")
######################################################
get_nuc_heatmaps <- function(my.ordered.matrix, my.tissue){
### get data range and scale for plotting (cf NGS plots hacked function)
m1 <- log2(my.ordered.matrix[,-1] +1e-6)
my.max <- max(m1)
bk <-  unique(c(seq(-0.1,3, length=100),seq(3,my.max,length=100)))
my.heat.cols <- c("snow","royalblue4","midnightblue")
hmcols <- colorRampPalette(my.heat.cols)(length(bk)-1)
# export to png
my.pngname <- paste(Sys.Date(),my.tissue,"H3_ChIP_seq_heatmap.png",sep="_")
pheatmap( log2( my.ordered.matrix [,-1] +1e-6) , cluster_rows = F, cluster_cols = F,
col = hmcols, breaks = bk, show_rownames=FALSE, legend = F,
show_colnames = FALSE,
cellwidth = 0.75,
cellheight = 0.01,
filename = my.pngname
)
}
setwd('/Volumes/MyBook_3/BD_aging_project/ChIP-seq/All_tissues_analysis/Signal_analyses/Nucleosome_changes/')
source('Make_nucleosome_heatmaps_functions.R')
# 2017-03-08
# build heatmaps nucleosome remodeling
######################  NPCs  ######################
my.NPCgain <- read.csv('./Other_ref/NPCs_3-12-29m_H3_age_gain_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.NPCloss <- read.csv('./Other_ref/NPCs_3-12-29m_H3_age_lost_dposREF_nucleosome_signal.txt',header=T,sep="\t")
#my.NPCgain.ordered <- get_kmeans_hclust(my.NPCgain)
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_gained")
#my.NPCloss.ordered <- get_kmeans_hclust(my.NPCloss)
get_nuc_heatmaps(my.NPCloss.ordered, "NPCs_loss")
######################################################
######################  cereb  ######################
my.cerebgain <- read.csv('./Other_ref/Cerebellum_3-12-29m_H3_age_gain_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.cerebloss <- read.csv('./Other_ref/Cerebellum_3-12-29m_H3_age_lost_dposREF_nucleosome_signal.txt',header=T,sep="\t")
#my.cerebgain.ordered <- get_kmeans_hclust(my.cerebgain)
get_nuc_heatmaps(my.cerebgain.ordered, "cerebellum_gained")
summary(my.NPCgain.ordered)
### get the heatmaps on reordered data
get_nuc_heatmaps <- function(my.ordered.matrix, my.tissue){
### get data range and scale for plotting (cf NGS plots hacked function)
m1 <- my.ordered.matrix[,-1]
my.max <- max(m1)
bk <-  unique(c(seq(-0.1,3, length=100),seq(3,my.max,length=100)))
my.heat.cols <- c("snow","royalblue4","midnightblue")
hmcols <- colorRampPalette(my.heat.cols)(length(bk)-1)
# export to png
my.pngname <- paste(Sys.Date(),my.tissue,"H3_ChIP_seq_heatmap.png",sep="_")
pheatmap( my.ordered.matrix [,-1], cluster_rows = F, cluster_cols = F,
col = hmcols, breaks = bk, show_rownames=FALSE, legend = F,
show_colnames = FALSE,
cellwidth = 0.75,
cellheight = 0.01,
filename = my.pngname
)
}
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_gained")
### get the heatmaps on reordered data
get_nuc_heatmaps <- function(my.ordered.matrix, my.tissue){
### get data range and scale for plotting (cf NGS plots hacked function)
m1 <- my.ordered.matrix[,-1]
my.max <- max(m1)
bk <-  unique(c(seq(-0.1,3, length=100),seq(3,my.max,length=100)))
my.heat.cols <- c("snow","dodgerblue","royalblue4")
hmcols <- colorRampPalette(my.heat.cols)(length(bk)-1)
# export to png
my.pngname <- paste(Sys.Date(),my.tissue,"H3_ChIP_seq_heatmap.png",sep="_")
pheatmap( my.ordered.matrix [,-1], cluster_rows = F, cluster_cols = F,
col = hmcols, breaks = bk, show_rownames=FALSE, legend = F,
show_colnames = FALSE,
cellwidth = 0.75,
cellheight = 0.02,
filename = my.pngname
)
}
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_gained")
get_nuc_heatmaps <- function(my.ordered.matrix, my.tissue){
### get data range and scale for plotting (cf NGS plots hacked function)
m1 <- my.ordered.matrix[,-1]
my.max <- max(m1)
bk <-  unique(c(seq(-0.1,3, length=100),seq(3,my.max,length=100)))
#my.heat.cols <- c("white","dodgerblue","royalblue4")
my.heat.cols <- c("white","snow","aliceblue","lightskyblue1","skyblue","deepskyblue","dodgerblue","royalblue1","royalblue4","midnightblue")'
hmcols <- colorRampPalette(my.heat.cols)(length(bk)-1)
# export to png
my.pngname <- paste(Sys.Date(),my.tissue,"H3_ChIP_seq_heatmap.png",sep="_")
pheatmap( my.ordered.matrix [,-1], cluster_rows = F, cluster_cols = F,
col = hmcols, breaks = bk, show_rownames=FALSE, legend = F,
show_colnames = FALSE,
cellwidth = 0.75,
cellheight = 0.025,
filename = my.pngname
)
}
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_gained")
>>>
<>
|}}
}}}}
)))))))
)))))
}}}}}}}}}}}}}}}}}}}}
''
get_nuc_heatmaps <- function(my.ordered.matrix, my.tissue){
### get data range and scale for plotting (cf NGS plots hacked function)
m1 <- my.ordered.matrix[,-1]
my.max <- max(m1)
bk <-  unique(c(seq(-0.1,3, length=100),seq(3,my.max,length=100)))
#my.heat.cols <- c("white","dodgerblue","royalblue4")
my.heat.cols <- c("white","snow","aliceblue","lightskyblue1","skyblue","deepskyblue","dodgerblue","royalblue1","royalblue4","midnightblue")
hmcols <- colorRampPalette(my.heat.cols)(length(bk)-1)
# export to png
my.pngname <- paste(Sys.Date(),my.tissue,"H3_ChIP_seq_heatmap.png",sep="_")
pheatmap( my.ordered.matrix [,-1], cluster_rows = F, cluster_cols = F,
col = hmcols, breaks = bk, show_rownames=FALSE, legend = F,
show_colnames = FALSE,
cellwidth = 0.75,
cellheight = 0.025,
filename = my.pngname
)
}
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_gained")
get_nuc_heatmaps <- function(my.ordered.matrix, my.tissue){
### get data range and scale for plotting (cf NGS plots hacked function)
m1 <- my.ordered.matrix[,-1]
my.max <- max(m1)
bk <-  unique(c(seq(-0.1,3, length=100),seq(3,my.max,length=100)))
#my.heat.cols <- c("white","dodgerblue","royalblue4")
my.heat.cols <- c("white","deepskyblue","dodgerblue","royalblue1","royalblue4","midnightblue")
hmcols <- colorRampPalette(my.heat.cols)(length(bk)-1)
# export to png
my.pngname <- paste(Sys.Date(),my.tissue,"H3_ChIP_seq_heatmap.png",sep="_")
pheatmap( my.ordered.matrix [,-1], cluster_rows = F, cluster_cols = F,
col = hmcols, breaks = bk, show_rownames=FALSE, legend = F,
show_colnames = FALSE,
cellwidth = 0.75,
cellheight = 0.025,
filename = my.pngname
)
}
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_gained")
### get the heatmaps on reordered data
get_nuc_heatmaps <- function(my.ordered.matrix, my.tissue){
### get data range and scale for plotting (cf NGS plots hacked function)
m1 <- my.ordered.matrix[,-1]
my.max <- max(m1)
bk <-  unique(c(seq(-0.1,3, length=100),seq(3,my.max,length=100)))
#my.heat.cols <- c("white","dodgerblue","royalblue4")
my.heat.cols <- c("white","dodgerblue","royalblue1","royalblue4","midnightblue")
hmcols <- colorRampPalette(my.heat.cols)(length(bk)-1)
# export to png
my.pngname <- paste(Sys.Date(),my.tissue,"H3_ChIP_seq_heatmap.png",sep="_")
pheatmap( my.ordered.matrix [,-1], cluster_rows = F, cluster_cols = F,
col = hmcols, breaks = bk, show_rownames=FALSE, legend = F,
show_colnames = FALSE,
cellwidth = 0.75,
cellheight = 0.025,
filename = my.pngname
)
}
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_gained")
setwd('/Volumes/MyBook_3/BD_aging_project/ChIP-seq/All_tissues_analysis/Signal_analyses/Nucleosome_changes/')
source('Make_nucleosome_heatmaps_functions.R')
# 2017-03-08
# build heatmaps nucleosome remodeling
######################  NPCs  ######################
my.NPCgain <- read.csv('./Other_ref/NPCs_3-12-29m_H3_age_gain_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.NPCloss <- read.csv('./Other_ref/NPCs_3-12-29m_H3_age_lost_dposREF_nucleosome_signal.txt',header=T,sep="\t")
#my.NPCgain.ordered <- get_kmeans_hclust(my.NPCgain)
get_nuc_heatmaps(my.NPCgain.ordered, "NPCs_gained")
#my.NPCloss.ordered <- get_kmeans_hclust(my.NPCloss)
get_nuc_heatmaps(my.NPCloss.ordered, "NPCs_loss")
######################################################
######################  cereb  ######################
my.cerebgain <- read.csv('./Other_ref/Cerebellum_3-12-29m_H3_age_gain_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.cerebloss <- read.csv('./Other_ref/Cerebellum_3-12-29m_H3_age_lost_dposREF_nucleosome_signal.txt',header=T,sep="\t")
#my.cerebgain.ordered <- get_kmeans_hclust(my.cerebgain)
get_nuc_heatmaps(my.cerebgain.ordered, "cerebellum_gained")
my.cerebloss.ordered <- get_kmeans_hclust(my.cerebloss)
#get_nuc_heatmaps(my.cerebloss.ordered, "cerebellum_loss")
######################################################
######################  Heart  ######################
my.heartgain <- read.csv('./Other_ref/Heart_3-12-29m_H3_age_gain_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.heartloss <- read.csv('./Other_ref/Heart_3-12-29m_H3_age_lost_dposREF_nucleosome_signal.txt',header=T,sep="\t")
#my.heartgain.ordered <- get_kmeans_hclust(my.heartgain)
get_nuc_heatmaps(my.heartgain.ordered, "heart_gained")
#my.heartloss.ordered <- get_kmeans_hclust(my.heartloss)
get_nuc_heatmaps(my.heartgain.ordered, "heart_loss")
######################################################
######################  Liver  ######################
my.livergain <- read.csv('./Other_ref/Liver_3-12-29m_H3_age_gain_dposREF_nucleosome_signal.txt',header=T,sep="\t")
get_nuc_heatmaps(my.cerebloss.ordered, "cerebellum_loss")
get_nuc_heatmaps(my.heartloss.ordered, "heart_loss")
get_nuc_heatmaps(my.livergain.ordered, "liver_gained")
#my.liverloss.ordered <- get_kmeans_hclust(my.liverloss)
get_nuc_heatmaps(my.liverloss.ordered, "liver_loss")
######################################################
######################  OB  ######################
my.OBgain <- read.csv('./Other_ref/Olfactory_Bulb_3-12-29m_H3_age_gain_dposREF_nucleosome_signal.txt',header=T,sep="\t")
my.OBloss <- read.csv('./Other_ref/Olfactory_Bulb_3-12-29m_H3_age_lost_dposREF_nucleosome_signal.txt',header=T,sep="\t")
#my.OBgain.ordered <- get_kmeans_hclust(my.OBgain)
get_nuc_heatmaps(my.OBgain.ordered, "OB_gained")
#my.OBloss.ordered <- get_kmeans_hclust(my.OBloss)
get_nuc_heatmaps(my.OBloss.ordered, "OB_loss")
######################################################
setwd('/Volumes/MyBook_3/BD_aging_project/ChIP-seq/All_tissues_analysis/Nucleosome_analyses/Beds_of_changed_Nucleosomes/consensus')
my.cerebgain <- read.csv('HOMER_Cerebellum_DiNUP_DANPOS_GAINED.xls',header=T,sep="\t")
my.cerebloss <- read.csv('HOMER_Cerebellum_DiNUP_DANPOS_LOST.xls',header=T,sep="\t")
my.heartgain <- read.csv('HOMER_Heart_DiNUP_DANPOS_GAINED.xls',header=T,sep="\t")
my.heartloss <- read.csv('HOMER_Heart_DiNUP_DANPOS_LOST.xls',header=T,sep="\t")
my.livergain <- read.csv('HOMER_Liver_DiNUP_DANPOS_GAINED.xls',header=T,sep="\t")
my.liverloss <- read.csv('HOMER_Liver_DiNUP_DANPOS_LOST.xls',header=T,sep="\t")
my.npcgain <- read.csv('HOMER_NPCs_DiNUP_DANPOS_GAINED.xls',header=T,sep="\t")
my.npcloss <- read.csv('HOMER_NPCs_DiNUP_DANPOS_LOST.xls',header=T,sep="\t")
my.obgain <- read.csv('HOMER_OlfactoryBulb_DiNUP_DANPOS_GAINED.xls',header=T,sep="\t")
my.obloss <- read.csv('HOMER_OlfactoryBulb_DiNUP_DANPOS_LOST.xls',header=T,sep="\t")
head(my.cerebgain)
hist(my.cerebgain$Distance.to.TSS)
?hist
hist(my.cerebgain$Distance.to.TSS, breaks = c(-500000,-50,-5,0,5,50,500000))
hist(my.cerebgain$Distance.to.TSS, breaks = c(-150000,-50,-5,0,5,50,150000))
summary(my.cerebgain$Distance.to.TSS)
hist(my.cerebgain$Distance.to.TSS, breaks = c(-2e6,-500000,-50,-5,0,5,50,500000,2e6))
my.min500 <- sum(my.cerebgain$Distance.to.TSS < -500000)
my.min500_50 <- sum(my.cerebgain$Distance.to.TSS >= -500000 & my.cerebgain$Distance.to.TSS < -50000)
my.min50_5 <- sum(my.cerebgain$Distance.to.TSS >= -50000 & my.cerebgain$Distance.to.TSS < -5000)
my.min5_0 <- sum(my.cerebgain$Distance.to.TSS >= -5000 & my.cerebgain$Distance.to.TSS < 0)
my.0_5 <- sum(my.cerebgain$Distance.to.TSS >= 0 & my.cerebgain$Distance.to.TSS < 5000)
my.5_50 <- sum(my.cerebgain$Distance.to.TSS >= 5000 & my.cerebgain$Distance.to.TSS < 50000)
my.500_50 <- sum(my.cerebgain$Distance.to.TSS >= 50000 & my.cerebgain$Distance.to.TSS < 500000)
my.500 <- sum(my.cerebgain$Distance.to.TSS >= 500000)
my.500
my.500_50
my.numbers <- c(my.min500,my.min500_50,my.min50_5,my.min5_0,my.0_5,my.5_50,my.500_50,my.500)
my.numbers
my.names <- c("< -500kb","-500 to -50kb","-50 to -5kb","-5 to 0kb","0 to 5kb","5 to 50kb","50 to 500kb","> 500kb")
my.numbers <- c(my.min500,my.min500_50,my.min50_5,my.min5_0,my.0_5,my.5_50,my.500_50,my.500)
my.names <- c("< -500kb","-500 to -50kb","-50 to -5kb","-5 to 0kb","0 to 5kb","5 to 50kb","50 to 500kb","> 500kb")
barplot(my.numbers, names =my.names )
my.norm.numbers <- 100* c(my.min500,my.min500_50,my.min50_5,my.min5_0,my.0_5,my.5_50,my.500_50,my.500)/my.norm
my.norm <- sum(my.numbers)
my.norm.numbers <- 100* c(my.min500,my.min500_50,my.min50_5,my.min5_0,my.0_5,my.5_50,my.500_50,my.500)/my.norm
my.norm.numbers
barplot(my.norm.numbers, names =my.names, ylim = c(0,50))
barplot(my.norm.numbers, names =my.names, ylim = c(0,50), las = 2)
barplot(my.norm.numbers, names =my.names, ylim = c(0,50), las = 2, col = "royalblue4")
?barplot
my.coords <- barplot(my.norm.numbers, names =my.names, ylim = c(0,50), las = 2, col = "royalblue4")
my.coords
text(my.coords,my.norm.numbers+5,my.numbers)
text(my.coords,my.norm.numbers+3,my.numbers, cex = 0.5)
my.coords <- barplot(my.norm.numbers, names =my.names, ylim = c(0,50), las = 2, col = "royalblue4",
ylab = "Nucleosome-gene associations")
text(my.coords,my.norm.numbers+3,my.numbers, cex = 0.75)
box()
my.coords <- barplot(my.norm.numbers, names =my.names, ylim = c(0,50), las = 2, col = "royalblue3",
ylab = "Nucleosome-gene associations")
text(my.coords,my.norm.numbers+3,my.numbers, cex = 0.75)
box()
get_barplots <- function(my.cerebgain,my.name) {
my.min500 <- sum(my.cerebgain$Distance.to.TSS < -500000)
my.min500_50 <- sum(my.cerebgain$Distance.to.TSS >= -500000 & my.cerebgain$Distance.to.TSS < -50000)
my.min50_5 <- sum(my.cerebgain$Distance.to.TSS >= -50000 & my.cerebgain$Distance.to.TSS < -5000)
my.min5_0 <- sum(my.cerebgain$Distance.to.TSS >= -5000 & my.cerebgain$Distance.to.TSS < 0)
my.0_5 <- sum(my.cerebgain$Distance.to.TSS >= 0 & my.cerebgain$Distance.to.TSS < 5000)
my.5_50 <- sum(my.cerebgain$Distance.to.TSS >= 5000 & my.cerebgain$Distance.to.TSS < 50000)
my.500_50 <- sum(my.cerebgain$Distance.to.TSS >= 50000 & my.cerebgain$Distance.to.TSS < 500000)
my.500 <- sum(my.cerebgain$Distance.to.TSS >= 500000)
my.numbers <- c(my.min500,my.min500_50,my.min50_5,my.min5_0,my.0_5,my.5_50,my.500_50,my.500)
my.norm <- sum(my.numbers)
my.norm.numbers <- 100* c(my.min500,my.min500_50,my.min50_5,my.min5_0,my.0_5,my.5_50,my.500_50,my.500)/my.norm
my.names <- c("< -500kb","-500 to -50kb","-50 to -5kb","-5 to 0kb","0 to 5kb","5 to 50kb","50 to 500kb","> 500kb")
my.pdfname <- paste(Sys.Date(),my.name,"distribution_barplot.pdf")
pdf(my.pdfname)
my.coords <- barplot(my.norm.numbers, names =my.names,
ylim = c(0,50), las = 2, col = "royalblue3",
ylab = "Nucleosome-gene associations",
main = my.name)
text(my.coords,my.norm.numbers+3,my.numbers, cex = 0.75)
box()
dev.off()
}
get_barplots(my.cerebgain, "Cerebellum_Gained_H3")
get_barplots(my.cerebloss,"Cerebellum_Lost_H3")
get_barplots(my.heartgain,"Heart_Gained_H3")
get_barplots(my.heartloss,"Heart_Lost_H3")
get_barplots(my.livergain,"Liver_Gained_H3")
get_barplots(my.liverloss,"Liver_Lost_H3")
get_barplots(my.npcgain  ,"NSPCs_Gained_H3")
get_barplots(my.npcloss  ,"NSPCs_Lost_H3")
get_barplots(my.obgain   ,"OB_Gained_H3")
get_barplots(my.obloss   ,"OB_Lost_H3")
