view.dccm error: unequal vector lengths

Issue #260 resolved
Former user created an issue

Hi, there. I am new to R -programming. I was following Bio3D tutorial for protein network analysis. I was using all heavy atoms for network analysis following commands - noh.inds <- atom.select(pdb, "noh") cij <- dccm(trj[, noh.inds$xyz], grpby=pdb$atom[noh.inds$atom, "resno"]) but view.dccm producing error as unequal vector lengths. i have tried running view.dccm by grouping side chain and without grouping also, but both giving the same result. Dimention of matrix is as follows - without using grpby dim(cij) [1] 1599 1599

dim(pdb_A$atom) [1] 1599 16

using grpby

dim(cij) [1] 200 200 dim(pdb_A$atom) [1] 1599 16

pdb_A

Call: read.pdb(file = "ATP_TMP_Mg_chA.pdb")

Total Models#: 1 Total Atoms#: 1599, XYZs#: 4797 Chains#: 1 (values: X)

 Protein Atoms#: 1546  (residues/Calpha atoms#: 197)
 Nucleic acid Atoms#: 0  (residues/phosphate atoms#: 0)

 Non-protein/nucleic Atoms#: 53  (residues: 3)
 Non-protein/nucleic resid values: [ ATP (1), MG2 (1), TMP (1) ]

Protein sequence: PGLFLTLEGLDGSGKTTQARRLAAFLEAQGRPVLLTREPGGGLPEVRSLLLTQELSPEAE YLLFSADRAEHVRKVILPGLAAGKVVISDRYLDSSLAYQGYGRGLPLPWLREVAREATRG LKPRLTFLLDLPPEAALRRVRRPDRLEGLGLEFFRRVREGYLALARAEPGRFVVLDATLP EEEIARAIQAHLRPLLP

  • attr: atom, helix, sheet, seqres, xyz, calpha, remark, call

But it was working fine, while considering c-alpha atoms only.

Please help me in this issue. Thank you.

Comments (7)

  1. Xinqiu Yao

    Hi,

    I guess it was because of the ligand residues in your pdb. Dccm() takes all heavy atoms and returns a matrix of #calpha plus #ligand rows, whereas view.dccm() considers calpha only. If you really want to include ligands in the network, modify your pdb file to convert an atom to 'CA' for each ligand residue and use the new file for view.dccm(). Note that this modification is just for visualization and will not change results at all. Otherwise, you can exclude ligands before all calculations, e.g. noh.inds <- combine.select(atom.select(pdb, 'protein'), atom.select(pdb, 'noh'))

  2. santosh chaudhary

    Hi,

    Thank you very much for providing your valuable time. I tried by changing an atom to 'CA' but it didn't worked, then i changed the name of the ligand in the PDB to some random amino acid and it worked. But for this i processed the data again by taking the modified PDB. Thanks for the idea it worked.

    Apart from this i have two more issues. While running 'view.cna', its giving error as -

    view.cna(nnet, pdb, launch=TRUE) sh: vmd: command not found But its generating, network.vmd and network.pdb files. which i can open in vmd separately.

    and the second is while writing the PDB for normalized betweenness i get following error -

    Error in write.pdb(pdb, b = normalize.vector(node.betweenness), file = "node_cent_B.pdb") : write.pdb: the lengths of all input vectors != 'length(xyz)/3'

    thank you for your suggestions.

  3. Xinqiu Yao

    Hi,

    The first error indicates that your vmd is probably not installed properly. For example, can you open VMD by simply type 'vmd' in a shell? If not, the vmd command is not in the search path and you need to add it in your .bashrc file.

    About the second error, could you check the number of atoms in the 'pdb' and the length of the 'node.betweenness'? For example, nrow(pdb$atom), length(pdb$xyz)/3, length(node.betweenness), all the three commands should give the same results.

  4. santosh chaudhary

    Hi, Thank you for prompt replies. I can open VMD in the shell and can run network.vmd generated by view.cna. The path is present in .bashrc.

    I have checked, number of atoms in pdb and length of network.betweenness both are diffrent.

    nrow(pdb$atom) [1] 1598 length(pdb$xyz)/3 [1] 1598 length(node.betweenness) [1] 199

    Probably because i have used grpby for calculating dccm. I used following commands for calculating node betweenness -

    cij <- dccm(trj[, inds$xyz], grpby=pdb$atom[inds$atom, "resno"]) cm <- cmap(trj[, inds$xyz], grpby=pdb$atom[inds$atom, "resno"], dcut=4.5, scut=0, pcut=0.75, mask.lower=FALSE) net.cut <- cna(cij, cm = cm) node.betweenness <- betweenness(net.cut$network)

    I have created a pdb containing only c-alpha atoms and it worked. Can we assign normalized betweenness values only to the c-alpha atoms by taking the pdb containing all heavy atoms using write.pdb as in my case ?

    Thankyou

  5. Xinqiu Yao

    It is strange that you can open VMD in the shell but not in the R session. I guess the environment somehow changed after starting R... Since you can open it out of R, I recommend to move on (it's definitely not a bug of bio3d since we don't see the same problem).

    So, the problem is for sure the mismatch of vector lengths in writing pdb. You cannot write 'b' to select atoms; however, you can easily create a equivalent vector to match the number of atoms in pdb. For example,

    #write the same b to all atoms of a residue
    b <- vec2resno(normalize.vector(node.betweenness), pdb$atom[inds$atom, 'resno'])
    write.pdb(pdb, b=b,  file = "node_cent_B.pdb")
    
    # write b to CA and 0 to other atoms within a residue
    b <- rep(0, length(inds$atom))
    b[pdb$atom[inds$atom, 'elety']=='CA'] <- normalize.vector(node.betweenness)
    write.pdb(pdb, b=b,  file = "node_cent_B.pdb")
    

    Let me know if you have any problem to run above codes!

  6. santosh chaudhary

    Hi, Yes, you are right, vmd works fine in R on my other PC. The code works fine. Thank you very much for the support and help. I really appreciate it.

  7. Log in to comment