Learn R Programming

Rpdb (version 2.0)

visualize: Visualize a Molecular Structure

Description

Use the rgl library to visualize in 3D a molecular structure.

Usage

visualize(...)

## S3 method for class 'coords': visualize(x, elename = NULL, cryst1 = NULL, conect = NULL, type = "l", xyz = NULL, abc = NULL, pbc.box = NULL, lwd = 2, lwd.xyz = lwd, lwd.abc = lwd, lwd.pbc.box = lwd, cex.xyz = 2, cex.abc = 2, col = NULL, bg = "#FAFAD2", radii = "rvdw", add = FALSE, windowRect = c(0,0,800,600), FOV = 0, userMatrix=diag(4), ...)

## S3 method for class 'data.frame': visualize(x, elename = NULL, cryst1 = NULL, conect = NULL, type = "l", xyz = NULL, abc = NULL, pbc.box = NULL, lwd = 2, lwd.xyz = lwd, lwd.abc = lwd, lwd.pbc.box = lwd, cex.xyz = 2, cex.abc = 2, col = NULL, bg = "#FAFAD2", radii = "rvdw", add = FALSE, windowRect = c(0,0,800,600), FOV = 0, userMatrix=diag(4), ...)

## S3 method for class 'matrix': visualize(x, elename = NULL, cryst1 = NULL, conect = NULL, type = "l", xyz = NULL, abc = NULL, pbc.box = NULL, lwd = 2, lwd.xyz = lwd, lwd.abc = lwd, lwd.pbc.box = lwd, cex.xyz = 2, cex.abc = 2, col = NULL, bg = "#FAFAD2", radii = "rvdw", add = FALSE, windowRect = c(0,0,800,600), FOV = 0, userMatrix=diag(4), ...)

## S3 method for class 'atoms': visualize(x, cryst1 = NULL, conect = NULL, type = "l", xyz = NULL, abc = NULL, pbc.box = NULL, lwd = 2, lwd.xyz = lwd, lwd.abc = lwd, lwd.pbc.box = lwd, cex.xyz = 2, cex.abc = 2, col = NULL, bg = "#FAFAD2", radii = "rvdw", add = FALSE, windowRect = c(0,0,800,600), FOV = 0, userMatrix=diag(4), ...) ## S3 method for class 'pdb': visualize(x, type = "l", xyz = NULL, abc = NULL, pbc.box = NULL, lwd = 2, lwd.xyz = lwd, lwd.abc = lwd, lwd.pbc.box = lwd, cex.xyz = 2, cex.abc = 2, col = NULL, bg = "#FAFAD2", radii = "rvdw", add = FALSE, windowRect = c(0,0,800,600), FOV = 0, userMatrix=diag(4), ...)

Arguments

x
an object containing the molecular structure to visualize.
elename
a character vector containing the atomic names used to chose atom colors and radii.
cryst1
an object of class cryst1. See cryst1
conect
an object of class conect. See conect
type
a character string indicating the visualization mode (See details).
xyz
a logical value indicating whether the x, y and z axes have to be added to the scene. See details
abc
a logical value indicating whether the a, b and c axes have to be added to the scene. See details
pbc.box
a logical value indicating whether the pbc box has to be added to the scene. See details
lwd
a numeric value indication the line width used to plot the axes, the pbc box and atomic bonds when type = "l" (see details).
lwd.xyz
a numeric value indicating the line width used to plot the x, y and z axes.
lwd.abc
a numeric value indicating the line width used to plot the a, b and c axes.
lwd.pbc.box
a numeric value indicating the line width used to plot the pbc box.
cex.xyz
a numeric value indicating the magnification used to plot the labels of the x, y and z axes.
cex.abc
a numeric value indicating the magnification used to plot the labels of the a, b and c axes.
col
a vector indicating the colors to use to plot each atom.
bg
the color of the background
radii
either a character string indicating the type of radii or a numeric vector specifying the radii of each atom to use to plot atoms as spheres (see details).
add
a logical value indicating whether the plot has be to added to a existing scene (see rgl.cur and open3d).
windowRect
a vector of four integers indicating the left, top, right and bottom of the displayed window in pixels (see par3d).
FOV
the field of view. This controls the degree of parallax in the perspective view (see par3d).
userMatrix
a 4 by 4 matrix describing user actions to display the scene (see par3d).
...
further arguments passed to or from other methods.

Value

  • Return (using invisible) a two-column data.frame containing the IDs and type indicators of the objects added to the scene.

Details

Three different visualization modes are allowed.
  • Whentype="p": Points are drawn at each atomic positions (very light visualization mode).
  • Whentype="l": Lines are drawn between bonded atoms. The connectivity of the system has to be specifyed.
  • Whentype="s": Spheres are drawn at each atomic positions (heavy visualization mode). The radii of the spheres are given byradii.
    • Whenradii="rcov": Covalent radii, taken from theelementsdata set, are used.
    • Whenradii="rvdw": Van der Waals radii, taken from theelementsdata set, are used.
    • Whenradiiis a numeric vector: The numeric values are used to assign to each atom a radius. Iflength(radii) != natom(pdb)radiiis recycled.
When xyz, abc or pbc.box are NULL, the axis or pbc box are are added depending if a cryst1 object can be found.

See Also

addXYZ, addABC, addPBCBox, par3d, select3d

Examples

Run this code
x <- read.pdb(system.file("examples/PCBM_ODCB.pdb",package="Rpdb"))
visualize(x, type = "l")
visualize(x, type = "s", radii = "rcov")
visualize(x, type = "s", radii = "rvdw")
visualize(x, type = "p")
visualize(x, xyz = TRUE, abc = FALSE, pbc.box = FALSE)
visualize(subset(x, resid != 1), type = "l")
visualize(subset(x, resid == 1), type = "s", add = TRUE)

Run the code above in your browser using DataLab