# NOT RUN {
#-- Read HIV protease alignment
aln <- read.fasta(system.file("examples/hivp_xray.fa",package="bio3d"))
# Generate consensus
con <- consensus(aln)
print(con$seq)
# Plot residue frequency matrix
##png(filename = "freq.png", width = 1500, height = 780)
col <- mono.colors(32)
aa <- rev(rownames(con$freq))
image(x=1:ncol(con$freq),
y=1:nrow(con$freq),
z=as.matrix(rev(as.data.frame(t(con$freq)))),
col=col, yaxt="n", xaxt="n",
xlab="Alignment Position", ylab="Residue Type")
# Add consensus along the axis
axis(side=1, at=seq(0,length(con$seq),by=5))
axis(side=2, at=c(1:22), labels=aa)
axis(side=3, at=c(1:length(con$seq)), labels =con$seq)
axis(side=4, at=c(1:22), labels=aa)
grid(length(con$seq), length(aa))
box()
# Add consensus sequence
for(i in 1:length(con$seq)) {
text(i, which(aa==con$seq[i]),con$seq[i],col="white")
}
# Add lines for residue type separation
abline(h=c(2.5,3.5, 4.5, 5.5, 3.5, 7.5, 9.5,
12.5, 14.5, 16.5, 19.5), col="gray")
# }
Run the code above in your browser using DataLab