This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConservation_analysis.R
49 lines (40 loc) · 2.05 KB
/
Conservation_analysis.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
setwd("~/Documents/IFN_enhancer/R/")
bin_smooth <- function(x, bin, step = 1) {
out <- NULL
for (i in c(1:(length(x) + 1 - bin))) {
out <- c(out, mean(x[i:(i + bin - 1)]))
}
return(out)
}
#########################################################################################################################
plt <- function(tag, xlim, bin) {
fg <- read.csv(paste("Data/phastCons44way", tag, "Induced_EP_enhancer_1.profile", sep = "_"), sep = "\t", header = T)
bg <- read.csv(paste("Data/phastCons44way", tag, "Synteney_bg_random200kb_1.profile", sep = "_"), sep = "\t", header = T)
plot(bin_smooth(fg[, 1], bin), bin_smooth(fg[, 2], bin),
type = "l", col = "blue", lwd = 2, xlim = xlim, main = tag, xlab = "Distance to center (bp)", ylab = "PhastCons Score"
)
lines(bin_smooth(bg[, 1], bin), bin_smooth(bg[, 2], bin), col = "grey", lwd = 2)
legend("topright", c("EP Enh", "Random"), col = c("blue", "grey"), lwd = 2)
}
pdf("Figure/PhastCons_of_Enhancer.pdf")
# par(mfrow=c(3,1))
plt("primate", c(-5000, 5000), bin = 20)
plt("mammal", c(-5000, 5000), bin = 20)
plt("vertebrate", c(-5000, 5000), bin = 20)
dev.off()
#########################################################################################################################
plt <- function(tag, xlim, bin) {
fg <- read.csv(paste("Data/phastCons44way", tag, "Early_enhancer_1.profile", sep = "_"), sep = "\t", header = T)
bg <- read.csv(paste("Data/phastCons44way", tag, "Synteney_bg_random200kb_1.profile", sep = "_"), sep = "\t", header = T)
plot(bin_smooth(fg[, 1], bin), bin_smooth(fg[, 2], bin),
type = "l", col = "blue", lwd = 2, xlim = xlim, main = tag, xlab = "Distance to center (bp)", ylab = "PhastCons Score"
)
lines(bin_smooth(bg[, 1], bin), bin_smooth(bg[, 2], bin), col = "grey", lwd = 2)
legend("topright", c("EP Enh", "Random"), col = c("blue", "grey"), lwd = 2)
}
par(mfrow = c(3, 1))
pdf("Figure/PhastCons_of_Early_enhancer.pdf")
plt("primate", c(-5000, 5000), bin = 20)
plt("mammal", c(-5000, 5000), bin = 20)
plt("vertebrate", c(-5000, 5000), bin = 20)
dev.off()