Skip to content

Commit 574f8df

Browse files
author
Digp
committed
Added code to reproduce the figure in the paper
1 parent b9b5177 commit 574f8df

File tree

309 files changed

+32603
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

309 files changed

+32603
-0
lines changed

FigurePaper/example1/dependencies.R

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
## "cache" saves trinucleotide backbones in RAM for latter RMSD calculations
2+
cache <-
3+
function(ntID, name, ntinfo) {
4+
## Trim trinucleotide backbone
5+
pdb <- trimByID(ntID=ntID, ntinfo=ntinfo, prev=1, post=1,
6+
alt=c("uniq"), cutoff=0, justbackbone=TRUE,
7+
verbose=FALSE)
8+
## Save as an independent pdb file in RAM
9+
assign(name, pdb, envir=.GlobalEnv)
10+
}
11+
12+
## "pwrmsd" calculates pair wise RMSD between nucleotides presaved in RAM
13+
pwrmsd <-
14+
function(ntIDs) {
15+
pdb1 <- get(paste("nt", ntIDs[1], sep=""))
16+
pdb2 <- get(paste("nt", ntIDs[2], sep=""))
17+
sel1 <- atom.select(pdb1)
18+
sel2 <- atom.select(pdb2)
19+
fit=fit.xyz(pdb1$xyz, pdb2$xyz,
20+
fixed.inds=sel1$xyz, mobile.inds=sel2$xyz)
21+
return(rmsd(pdb1$xyz[,sel1$xyz],fit[,sel2$xyz]))
22+
}
23+
24+
## "filter_pyle" reproduces the iterative process of RMSD comparison to chose
25+
## an helical nucleotide of reference
26+
filter_pyle <-
27+
function(ntinfo, helicalntID, RMSD, bandwidths=c(40,40), cutoff=0.85) {
28+
29+
twideMatrix <- t(acast(RMSD, nt1~nt2, value.var="rmsd"))
30+
twideMatrix<-rbind(rep(NA,length(helicalntID)-1),twideMatrix)
31+
twideMatrix<-cbind(twideMatrix,rep(NA,length(helicalntID)))
32+
rownames(twideMatrix)[1]<-helicalntID[1]
33+
colnames(twideMatrix)[length(helicalntID)]<-helicalntID[length(helicalntID)]
34+
35+
Matrix <- twideMatrix
36+
while (length(helicalntID) > 1) {
37+
Matrix <- Matrix[which(rownames(Matrix) %in% helicalntID),
38+
which(colnames(Matrix) %in% helicalntID)]
39+
40+
column_sums <- colSums(Matrix, na.rm=TRUE)
41+
row_sums <- rowSums(Matrix, na.rm=TRUE)
42+
RMSDaverages <- (column_sums + row_sums)/(length(row_sums) - 1)
43+
index <- which.min(RMSDaverages)
44+
lowestaverage <- RMSDaverages[index]
45+
reference_nt <- helicalntID[index]
46+
A <- Matrix[which(rownames(Matrix) == reference_nt), ]
47+
names(A) <- colnames(Matrix)
48+
A <- A[complete.cases(A)]
49+
B <- Matrix[, which(colnames(Matrix) == reference_nt)]
50+
names(B) <- colnames(Matrix)
51+
B <- B[complete.cases(B)]
52+
reference_nt_RMSD <- append(A,B); rm(list=c("A","B"))
53+
helicalntID <- sort(append(reference_nt, as.numeric(
54+
names(reference_nt_RMSD)[which(
55+
reference_nt_RMSD < lowestaverage)])))
56+
}
57+
58+
return(helicalntID)
59+
}

FigurePaper/example1/etatheta.R

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/Rscript
2+
## EXAMPLE 1
3+
## Description: From Leontis non-redundant RNA list, get eta-theta plot
4+
## following Pyle's method.
5+
## Author: Diego Gallego
6+
7+
## ----------------------------------------------------------------------------
8+
## Preprocess
9+
## ----------------------------------------------------------------------------
10+
## Load necessary packages for the example
11+
library(veriNA3d)
12+
library(bio3d)
13+
library(reshape2) ## Specific dependency for this example!
14+
15+
## Load specific functions for the example
16+
source("dependencies.R")
17+
18+
## ----------------------------------------------------------------------------
19+
## Get Raw data
20+
cat("Getting data\n")
21+
## ----------------------------------------------------------------------------
22+
23+
## Get latest Leontist non-redundant list of RNA structures
24+
infochains <- getLeontisList(threshold="2.5A", as.df=TRUE)
25+
26+
## Get structural data
27+
ntinfo <- pipeNucData(pdbID=infochains$pdb, model=infochains$model,
28+
chain=infochains$chain, cores=1)
29+
30+
## ----------------------------------------------------------------------------
31+
## Clean data. Raw -> Tidy
32+
cat("Cleaning data\n")
33+
## ----------------------------------------------------------------------------
34+
35+
## Subset north nucleotides
36+
north <- ntinfo[cleanByPucker(ntinfo, surenorth=TRUE), ]
37+
38+
## Find non-broken canonical nucleotides
39+
id <- which(north$puc_valid==TRUE & north$Break==FALSE & north$big_b == FALSE &
40+
north$eta_valid == TRUE & north$theta_valid == TRUE &
41+
grepl("^[GAUC]-[GAUC]-[GAUC]$", north$localenv, perl=TRUE))
42+
usefulnt <- north$ntID[id]
43+
44+
## Filter helical nucleotides before ploting =================================
45+
46+
## Create all the necessary trinucleotides for pair-wise RMSD calculations
47+
invisible(mapply(FUN=cache, ntID=usefulnt, name=paste("nt", usefulnt, sep=""),
48+
MoreArgs=list(ntinfo=ntinfo)))
49+
50+
## Find helical nucleotides
51+
HDR <- findHDR(ntID=usefulnt, ntinfo=ntinfo, x="eta", y="theta", SD_DENS=15)
52+
53+
## Compute pair-wise RMSD between helical nucleotides
54+
pairwise <- t(combn(HDR[[1]], 2))
55+
RMSD_calc <- apply(FUN=pwrmsd, MARGIN=1, X=pairwise)
56+
RMSD <- data.frame(nt1=pairwise[, 1], nt2=pairwise[, 2], rmsd=RMSD_calc)
57+
58+
## Apply Pyle method
59+
ref <- filter_pyle(ntinfo=ntinfo, helicalntID=HDR[[1]], RMSD=RMSD)
60+
61+
pairs <- data.frame(usefulnt=usefulnt, reference=rep(ref, length(usefulnt)))
62+
RMSD2 <- apply(FUN=pwrmsd, MARGIN=1, X=pairs)
63+
64+
## ===========================================================================
65+
## ----------------------------------------------------------------------------
66+
## Exploratory analysis. Plot
67+
cat("Plotting data\n")
68+
## ----------------------------------------------------------------------------
69+
tiff("example1.tiff", height=10.5, width=16.5, units="cm", res=300)
70+
plot2D(ntinfo=ntinfo, x="eta", y="theta", etatheta=TRUE,
71+
ntID=pairs[which(RMSD2 > 0.85), 1])
72+
dev.off()

FigurePaper/example1/example1.tiff

6.91 MB
Binary file not shown.

0 commit comments

Comments
 (0)