|
| 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() |
0 commit comments