Altering radius argument in view.dccm() function.

Issue #383 resolved
debra ragland created an issue

Hello all,

R version 3.1.3 (2015-03-09) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.9.5 (Mavericks)

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] bio3d_2.2-4

loaded via a namespace (and not attached): [1] grid_3.1.3 parallel_3.1.3 tools_3.1.3

Let me apologize in advance if this issue is elementary but I am not an avid R user so I am stuck. I did search for a similar issue as well.

What I am trying to do is alter the view.dccm() function itself so that the radius of the lines seen on the pdb in pymol (after running corr.py) have a width = to the absolute value of the correlation coefficient in the cij matrix. Unfortunately, I thought this would be as simple as running;

x <- abs(cij) view.dccm(cij, pdb, omit=0.6, radius=x)

And this in fact does do what I want, however, since I also need to (and have) alter(ed) the value of omit, there are more radius lines than there are values after removing those that have been omitted. And doing it this way also removes the binning that is produced from the step argument.

When looking at the view.dccm function, I have localized the area in which I need to change, perhaps by making a "radius" related helper function, but I just cannot seem to find a way to clearly edit this so that the function does what I need. I do not want help writing the function, just a push in the right direction.

view.dccm snippet scr <- c() if (type == "pymol") { scr <- c("from pymol import cmd") scr <- c(scr, "from pymol.cgo import ") scr <- c(scr, paste("cmd.load('", pdbfile, "', 'prot')", sep = "")) scr <- c(scr, "cmd.show('cartoon')") if (!is.pdb(pdb) || ca.pdb) scr <- c(scr, "cmd.set('cartoon_trace_atoms', 1)") blues <- colorRamp(c("white", "blue")) reds <- colorRamp(c("white", "red")) w <- radius* } else { m <- 0 } dccm[lower.tri(dccm, diag = TRUE)] <- NA lims <- c(-1, 1) intervals <- seq(lims[1], lims[2], by = step) if (!is.null(omit)) { i <- which(intervals > (omit - 0.001)) j <- which(intervals < (-omit + 0.001)) inds <- sort(c(i, j)) intervals <- sort(intervals[inds]) } for (i in 1:(length(intervals) - 1)) { lower <- intervals[i] upper <- intervals[i + 1] if (lower < 0 && upper > 0) next sele <- intersect(which(dccm > lower), which(dccm <= upper)) if (length(sele) == 0) next f <- matrix(FALSE, ncol(dccm), nrow(dccm)) f[sele] <- TRUE inds <- which(f, arr.ind = TRUE) if (type == "pymol") { scr <- c(scr, "obj=[]") } else { m <- m + 1 chain <- LETTERS[m] } for (j in 1:nrow(inds)) { x <- inds[j, 1] y <- inds[j, 2] if (x == y) next val <- dccm[x, y] k <- atom2xyz(inds[j, 1]) l <- atom2xyz(inds[j, 2]) if (type == "pymol") { a <- paste(xyz[k], collapse = ",") b <- paste(xyz[l], collapse = ",") if (val <= 0) col <- blues(abs(val)) else col <- reds(abs(val)) col <- round(col/256, 4) col <- paste(col, collapse = ", ") str <- paste("obj.extend([CYLINDER", a, b, w, col, col, "])", sep = ", ") scr <- c(scr, str) } else { a <- paste(format(xyz[k], justify = "right", width = 8), collapse = "") b <- paste(format(xyz[l], justify = "right", width = 8), collapse = "") val <- format(round(val, 2), justify = "right", width = 6) res.str <- format(x, justify = "right", width = 4) str <- paste("ATOM ", res.str, " CA ALA ", chain, res.str, " ", a, " 0.00", val, sep = "") scr <- c(scr, str) res.str <- format(y, justify = "right", width = 4) str <- paste("ATOM ", res.str, " CA ALA ", chain, res.str, " ", b, " 0.00", val, sep = "") scr <- c(scr, str) str <- paste("CONECT", format(x, justify = "right", width = 5), format(y, justify = "right", width = 5), sep = "") scr <- c(scr, str) } } if (type == "pymol") { tmpa <- gsub("\.", "", as.character(lower)) tmpb <- gsub("\.", "", as.character(upper)) name <- paste("cor_", tmpa, "_", tmpb, sep = "") str <- paste("cmd.load_cgo(obj, '", name, "')", sep = "") scr <- c(scr, str) } else { str <- "TER" scr <- c(scr, str) } }

Comments (6)

  1. Lars Skjærven

    Hi Debra, I added the functionality to allow adjusting the cylinder radius corresponding to the correlation values. See recent commit 12f39db2f.

    Please see instructions on the bitbucket page (first page) on how to install bio3d from the master branch.

    Usage:

    pymol(cij, pdb, radius=cij)
    

    Note that the function has changed to pymol.dccm() since your version.

    Lars

  2. debra ragland reporter

    I'm sorry to bother you. exactly how do I use this function after I source('pymol.dccm.R')

    I try

    pymol.dccm(cij, pdb, radius=?) what's acceptable for the radius argument? currently when I try to add the cij I get the following; Error in pymol.dccm(cij, SLK, radius = cij) : object 'cij' not found

  3. debra ragland reporter

    I'm sorry to bother you. exactly how do I use this function after I source('pymol.dccm.R')

    I try

    pymol.dccm(cij, pdb, radius=?) what's acceptable for the radius argument? currently when I try to add the cij I get the following; Error in pymol.dccm(cij, SLK, radius = cij) : object 'cij' not found

  4. Log in to comment