plot.dccm axes labels

Issue #201 new
Former user created an issue

Does plot.dccm allow adding own axes labels from say rownames or colnames ? This will be useful when the residue numbering is not continuous or does not start from 1. How can matrix data be saved for plotting in other programs if this is not possible with dccm?

Comments (14)

  1. Xinqiu Yao

    Hi,

    Current version of bio3d does NOT support re-labeling x/y of dccm matrix. However, I have been doing experiment on updating the function to enable many new features including relabeling. I will come back soon later once the updating is finished and function is uploaded. Keep watching future replies in this issue or changes of the master branch.

    To use other programs, simple write the dccm matrix out to hard disk as a plain ascii file (make sure the program does support plain 2D matrix as input):

    write.table(cij, file="cij.txt", row.names=FALSE, col.names=FALSE)
    
  2. Xinqiu Yao

    Hi,

    Sorry for back a bit late. Please check out the updated plot.dccm.R under the directory "new_funs/" (Note that it is not included in the bio3d package yet for testing purpose), and the accompanied add.sse.R. Following illustrate how to use them:

    # put the two new files under your working directory
    
    library(bio3d)
    source("plot.dccm.R")
    source("add.sse.R")
    
    # the argument 'resno' provide a way to replace default tick labels to customized pdb residue numbers
    plot(cij, resno=pdb, sse=sse, ...)
    

    Let me know if you have any question!

  3. Barry Grant

    This looks very nice and I see it is based on lattice which I like but keep forgetting how to annotate. For example the outer box will be missing from the below, how would I add it back and add additional legends, sse gird etc.? A nice Rd file with good examples will be key here.

    > plot(cij, resno=pdb, sse=sse, contor=FALSE, outer.box=T, show="lower")
    > box()
    Error in box() : plot.new has not been called yet
    > axis(1)
    Error in axis(1) : plot.new has not been called yet
    
  4. Xinqiu Yao

    Yes, the function is based on high-level lattice plot and so all traditional plot functions, such as box(), axis(), lines(), points(), etc., will not work at all.

    I thought we designed plot in house and left users very limited flexibilities. We do have functions to add sse or other segment grids after plotting. For example,

    plot(cij, resno=pdb, show="lower")
    add.sse(sse, pos=c("bottom", "right"))
    add.segment(seg, pos=c("bottom", "right"))
    

    To have finer control, we need the update() function and a little bit experience of the lattice package. In above example, to get back the box and axis,

    p <- update(trellis.last.object(), par.settings=list(axis.line=list(col='black')), 
                             scales=list(draw=TRUE))
    print(p)
    

    However, I think this is probably out of the scop of documentation for bio3d functions. Btw, do you like keeping the outer box and x/y axis even showing only "lower" or "upper" triangles?

  5. Barry Grant

    Thats fine, I would just like to see the add.sse() and possibly renamed add.grid() documented along with a bit of code to customize the axis annotation.

    I like lattice but am aware that the rest of the world is transfixed on ggplot2 and perhaps that is a better way to go long term, what do you think?

  6. Xinqiu Yao

    Okay, I will do it soon later. Not sure ggplot2 and lattice which is better, although both are kind of high-level plotting. The only thing I noticed is 'lattice' is R recommended package (and so installed in most R libraries) while 'ggplot2' is not yet. Let's keep watching both lines and thinking what we can do in bio3d...

  7. Xinqiu Yao

    Update the function to support customized axes labels. (See this commit.)

    I will keep this issue open but change the version to future v2.4 or v3.0.

    We probably need a systematic design of plot functions for matrices. These include plot for

    • dccm
    • contact map
    • distance matrix
    • matrix loadings from pca.array()

    Currently we have a mixture of "scatter plot", "contour plot", and "image" methods to make these plots. Most functions support annotations with SSE and/or pdb resno. Some also support adding grids. However, every function has its own codes to do these labeling, which causes duplication and inconsistency.

    What about we write a "core" matrix plot function and put complicated treatment to specific advanced functions (Similar to the recent updates of plotb3() and associated plot.pdb(), plot.pdbs(), etc. for vector plot)?

  8. Xinqiu Yao

    Thanks for these nice updates! Should we create a new feature branch in bio3d repo or you prefer to developing them separately at current stage?

  9. Barry Grant

    I think separately makes sense for the moment until we see how useful these will be.

    Merging eventually will require us to add two more packages to the Imports and Depends list for Bio3D - which is no big deal just an annoyance when added to the others. There of course a col-wise data.frame() mind set required for working productively with these functions that does not play nicely with most Bio3D output currently...

  10. Log in to comment