-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_haddock_run.r
More file actions
143 lines (119 loc) · 3.69 KB
/
Copy pathplot_haddock_run.r
File metadata and controls
143 lines (119 loc) · 3.69 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
library(ggplot2)
library(gridExtra)
library(ggrepel)
library(bio3d)
library(parallel)
library(gplots)
library(gclus)
#bio3d parameters
myvol=15000 #volume of common core, select after looking at core.png and then rerun
#remove previous run
fn <- "pc1.pdb"
if (file.exists(fn))
file.remove(fn)
fn <- "pc2.pdb"
if (file.exists(fn))
file.remove(fn)
data<-read.table('structures_haddock-sorted.stat',
comment.char = '!',
header=TRUE)
data$X.struc[1]
#HADDOCK PLOTS---------------
#HADDOCK score vs rmsd, labels top10 structures by HADDOCK score
p1<-ggplot(data, aes(rmsd_all, haddock.score,label=X.struc, color=X.NOEviol)) +
geom_point()+
ggtitle(getwd())+
geom_text_repel(data= head(data))
#interaction restraints vs rmsd
p2<-ggplot(data, aes(rmsd_all, Eair, color=X.NOEviol))+
geom_point()
#interaction restraitns vs haddock score
p3<-ggplot(data, aes(Eair, haddock.score, color=rmsd_all))+
geom_point()
#total energy vs rmsd
p4<-ggplot(data, aes(rmsd_all,Einter, label=X.struc))+
geom_point()+
geom_text_repel(data= head(data))
grid.arrange(p1, p2, p3, p4)
#BIO3D PLOTS--------------------------------
#Use structures with chain ids and no DU.
myFileNames = list.files(path=".", pattern="*.pdb")
pdbs<-pdbaln(myFileNames, fit =TRUE, ncore = 4)
gaps <- gap.inspect(pdbs$xyz)
core <- core.find(pdbs)
col=rep("black", length(core$volume))
col[core$volume<myvol]="pink"; col[core$volume<10]="red"
png("core.png")
plot(core, col=col)
dev.off()
#
#
core.inds <- print(core, vol=myvol)
xyz <- pdbfit( pdbs, core.inds, outpath = "./fitdir", ncore=4)
#
##
#### Find gap regions
gaps.res <- gap.inspect(pdbs$ali)
gaps.pos <- gap.inspect(pdbs$xyz)
##
#### RMSD vs the first structure
#rmsd(pdbs$xyz[1,gaps.pos$f.inds], pdbs$xyz[,gaps.pos$f.inds], fit=TRUE)
##
#### RMSD all vs all
rd <- rmsd(xyz[,gaps.pos$f.inds])
##
colnames(rd) <- pdbs$id
rownames(rd) <- pdbs$id
##
#### Plot RMSD values in a heatmap, or histogram
title<-'structure-based alignment rmsd'
library(RColorBrewer)
#coul = colorRampPalette(brewer.pal(9,"Blues"))(200)
heatmap.2(rd,
main = title, # heat map title
density.info="none", # turns off density plot inside color legend
trace="none", # turns off trace lines inside the heat map
# col = coul, # use on color palette defined earlier
# breaks=lcol_breaks,
dendrogram="both", # only draw a row dendrogram
xlab = 'pdb',
ylab = 'pdb',
margins=c(17,17)
# lhei = c(1,30),
# Colv="NA"
# scale="row"
)
hist(rd[upper.tri(rd)], breaks = 30, main = "", xlab = "RMSD (Å)")
##
### RMSF
rf <- rmsf(xyz)
pdb<-read.pdb(file=as.character(data$X.struc[1]))
sse <- dssp(pdb)
plot.bio3d(rf, sse = sse, ylab = "RMSF (Å)", xlab = "Residue No.")
##
#### Clustering
dis <- as.dist(rd)
hc <- hclust(dis)
hc1 <- reorder.hclust(hc, dis)
id <- substr(basename(pdbs$id), 1, 6)
plot(hc1, labels = id, main = "", ylab = "RMSD (Å)", xlab = "")
##
##
#### PCA
pc.xray <- pca.xyz(xyz[, gaps.pos$f.inds], use.svd = TRUE)
##
plot(pc.xray)
##
##
a <- mktrj.pca(pc.xray, pc=1, file="pc1.pdb",
resno = pdbs$resno[1, gaps.res$f.inds],
resid = aa123(pdbs$ali[1, gaps.res$f.inds]) )
b <- mktrj.pca(pc.xray, pc=2, file="pc2.pdb",
resno = pdbs$resno[1, gaps.res$f.inds],
resid = aa123(pdbs$ali[1, gaps.res$f.inds]) )
#PCA-based clustering
hc <- hclust(dist(pc.xray$z[,1:2]))
plot(hc)
grps <- cutree(hc, h=400) #edit here to cut the tree at different points after seeing the plot
cols <- c("red", "green", "blue")[grps]
plot(pc.xray, pc.axes=1:2, col=cols)