want to use backbone atoms

Issue #309 resolved
Ayesha kanwal created an issue
Hi all,
ca.inds <- atom.select(pdb, elety="CA")
xyz <- fit.xyz(fixed=pdb$xyz, mobile=dcd,
               fixed.inds=ca.inds$xyz,
               mobile.inds=ca.inds$xyz)
i want to visualize all atoms not only c alpha so i post this question how can i make it possible and lars helped me by giving the following example :
# select backbone
sele <- atom.select(pdb, "backbone")

# access backbone coordinates 
# trj[1, sele$xyz]

# fit trajectory coordinates
xyz <- fit.xyz(fixed = trj[1, ], mobile = trj, fixed.inds = sele$xyz, mobile.inds = sele$xyz)
i put "dcd" instead of "trj " but i am also could not understand trajectory fitting coordinates please guide me in this regard and  also help me what changings should i do in the following code because pca calculate only c alpha atoms i change this code by myself but it generate error. kindly help me out what i have to use in place of pca.xyz(xyz[,ca.inds$xyz])
dccm(xyz[,ca.inds$xyz])
i had used pca.xyz(xyz[,sele$xyz])
and also guide me what "," means which is used before ca.ins$xyz

dim(xyz) == dim(dcd)
[1] TRUE TRUE
pc <- pca.xyz(xyz[,ca.inds$xyz])
plot(pc, col=bwr.colors(nrow(xyz)) )
p1 <- mktrj.pca(pc, pc=1, b=pc$au[,1], file="pc1.pdb")
p2 <- mktrj.pca(pc, pc=2,b=pc$au[,2], file="pc2.pdb")
cij<-dccm(xyz[,ca.inds$xyz])

Regards

Comments (8)

  1. Barry Grant

    I believe that you would benefit from going through some introductory R tutorials and then the various introductory bio3d tutorials on our website.

    For example, it is clear that by asking what the "," means in xyz[,sele$xyz] that you do not understand the data structures you are using. xyz is a matrix and the comma separated values within the square brackets allow you to access the rows and cols of that matrix.

    Once you have gone through the tutorials let us know if you still have questions.

  2. Ayesha kanwal reporter

    now i understand what does "," meaning. now the question is how i can fit the coordinates of trajectory ?

  3. Barry Grant

    The fit.xyz() function will do this for you. You can read the help page for the function here: http://thegrantlab.org/bio3d/html/fit.xyz.html

    Let us know if this documentation is not sufficient please.

    Basically you should supply:

    1. Some fixed atom coordinates as a vector (e.g. your first trajectory frame or a starting PDB structure). These coordinates will not be returned from the function but will be used to 'fit on'.

    2. Some mobile atom coordinates as a vector or matrix (i.e. your trajectory). These coordinates will be superposed (i.e. moved) to match those given by fixed above and returned from the function. Note that all coordinates you provide as input to mobile here will be returned from the function and not just the optional subset you use for fitting (this subset can be specified by fixed.inds and mobile.inds, see below).

    3. Some optional fixed.inds and mobile.inds. These should be of the same length and correspond to the coordinate position indices that you actually want to use for fitting.

    Here is an example where we fit all trajectory atoms to a corresponding PDB structure based on a small subset of positions:

    ##-- Read coordinates from example trajectory file
    trtfile <- system.file("examples/hivp.dcd", package="bio3d")
    trj <- read.dcd(trtfile)
    
     ## Read the starting PDB file to determine atom correspondence
     pdbfile <- system.file("examples/hivp.pdb", package="bio3d")
     pdb <- read.pdb(pdbfile)
    
     ## select residues 24 to 27 and 85 to 90 in both chains
     inds <- atom.select(pdb, resno=c(24:27,85:90), elety='CA')
    
     ## lsq fit of trj on pdb based on selected residues BUT OUTPUT ALL coords
     xyz <- fit.xyz(pdb$xyz, trj, fixed.inds=inds$xyz, mobile.inds=inds$xyz)
    
    ##-- Plot RMSD of trj frames from PDB
    r1 <- rmsd(a=pdb, b=xyz)
    plot(r1, typ="l", ylab="RMSD", xlab="Frame No.")
    
  4. Ayesha kanwal reporter
    by using the following command rmsd generate graph
    bb.inds<-atom.select(pdb, "backbone")
    xyz<-fit.xyz(fixed=pdb$xyz, mobile=dcd, fixed.inds=bb.inds$xyz, mobile.inds=bb.inds$xyz)
    rd<-rmsd(xyz[1,bb.inds$xyz], xyz[,bb.inds$xyz])
    plot(rd, typ="l", ylab="RMSD", xlab="Frame No.")
    but when i put bb.inds in PCA command terminal shows the following error
    pc <- pca.xyz(xyz[,bb.inds$xyz])
    NOTE: In input xyz (MxN),  N > 3000 and M < N
          Singular Value Decomposition (SVD) approach is faster
          and is recommended (set 'use.svd = TRUE')
    
    Error: cannot allocate vector of size 478.6 Mb
    > pc <- pca.xyz(xyz[,bb.inds$xyz])
    NOTE: In input xyz (MxN),  N > 3000 and M < N
          Singular Value Decomposition (SVD) approach is faster
          and is recommended (set 'use.svd = TRUE')
    
    Error: cannot allocate vector of size 478.6 Mb
    how can i solve this problem?
    
  5. Barry Grant

    The message "Error: cannot allocate vector of size..." indicates that you do not have enough free memory to store the result here - you could find that out by using google!

    Keep all other processes and objects in R to a minimum when you need to make objects of this size. Use gc() to clear unused memory, or, better only create the object you need in one session.

    If the above cannot help, use a 64-bit machine with more RAM and 64-bit R installed. Google for more assistance on this.

  6. Xinqiu Yao

    Also probably try what it suggested: Set 'use.svd=TRUE', which uses a bit smaller memory for matrix with much longer column than row.

  7. Log in to comment