deepTools相关代码

## replot normalize by signal of gene body
library(Rsamtools)
library(rjson)
library(colorBlindness)
safeColors <- safeColors[-1]

setwd(“deepTools”)
for(factor in c(“sh247”, “sh266”)){
for(direction in c(“up”, ‘lo’)){
for(strand in c(“+”, “-“)){
headerL <- readLines(gzfile(paste(“count”, factor, direction, strand, “txt”, “gz”, sep=”.”)), n=1)
header <- fromJSON(substring(headerL, 2))
d <- read.delim(gzfile(paste(“count”, factor, direction, strand, “txt”, “gz”, sep=”.”)),
header=FALSE, comment.char = “@”)
anno <- d[, seq.int(6)]
d <- d[, -seq.int(6)]
dd <- mapply(function(a, b){
d[, a:b]
}, header$sample_boundaries[-length(header$sample_boundaries)]+1, header$sample_boundaries[-1],
SIMPLIFY = FALSE)

dd.norm <- lapply(dd, function(.ele){
f <- rowMeans(.ele[, 175:225])
.ele[f>0, ] <- .ele[f>0, ]/f[f>0]
.ele
})

out <- do.call(cbind, dd.norm)
out <- cbind(anno, round(out, digits = 6))
writeLines(headerL, paste(“count”, factor, direction, strand, “norm.txt”, sep=”.”))
write.table(out, file= paste(“count”, factor, direction, strand, “norm.txt”, sep=”.”),
append = TRUE, quote=FALSE, sep=”\t”, row.names = FALSE, col.names = FALSE)
library(R.utils)
#unlink(paste(“count”, factor, direction, strand, “norm.txt.gz”, sep=”.”))
gzip(paste(“count”, factor, direction, strand, “norm.txt”, sep=”.”), overwrite=TRUE)

system(paste(“~/miniconda3/bin/plotHeatmap -m count”, factor, direction, strand, “norm.txt.gz -out heatmap”,
factor, direction, strand, “norm.pdf –colorMap Reds –missingDataColor 1 –refPointLabel TSS –xAxisLabel ‘distance (bp)’ –legendLocation none”,
sep=”.”))

}
}
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注