Learn R Programming

Rpdb (version 2.3.4)

visualize: Visualize a Molecular Structure

Description

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

Usage

visualize(...)

# S3 method for coords visualize( x, elename = NULL, cryst1 = NULL, conect = NULL, mode = 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 data.frame visualize( x, elename = NULL, cryst1 = NULL, conect = NULL, mode = 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 matrix visualize( x, elename = NULL, cryst1 = NULL, conect = NULL, mode = 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 atoms visualize( x, cryst1 = NULL, conect = NULL, mode = 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 pdb visualize( x, mode = 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 character visualize( x, mode = 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), ... )

Value

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

Arguments

...

further arguments passed to or from other methods.

x

an object or the name of a PDB file 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

mode

a single element character vector indicating the visualization mode (See details).

type

a character string indicating the visualization style (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).

Details

Three different visualization styles are allowed.

  • When type="p": Points are drawn at each atomic positions (very light visualization mode).

  • When type="l": Lines are drawn between bonded atoms. The connectivity of the system has to be specifyed.

  • When type="s": Spheres are drawn at each atomic positions (heavy visualization mode).

    The radii of the spheres are given by radii.

    • When radii="rcov": Covalent radii, taken from the elements data set, are used.

    • When radii="rvdw": Van der Waals radii, taken from the elements data set, are used.

    • When radii is a numeric vector: The numeric values are used to assign to each atom a radius. If length(radii) != natom(pdb) radii is 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.
Two different interactive visualization modes are avalable:

  • When mode="measure": bond lengths, angles and dihedrals can be measured by right-clicing on the atoms.

  • When mode="info": atomic labels can be added to the scene by right-clicing on the atoms. The labels are as follow: "ResidResname:EleidElename"

When mode=NULL the interactive mode is disabled. To escape the interactive mode press the ESC key.

See Also

addXYZ, addABC, addPBCBox, par3d, select3d, measure, info3d

Examples

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

Run the code above in your browser using DataLab