Error in cmdscale(dist(cent), k = k) : NA values not allowed in 'd'

Issue #810 new
Mohammad Avestan created an issue

I am trying to run the following code in which, The first part, line 1 to line 23, is working but when I want to plot net, last 3 lines, it gives me the following error.

I tried two different PDB one obtained from VMD for CA and the other one just simply greps the CA from the PDB file, but with both, I am getting the same error.

I know that someone already reported a similar error and that problem fixed by choosing only CA; however, here I have CA and still getting the same error.

I attached all the required files. my dcd has only CA.

I will appreciate your help

library(bio3d)
library(grid)
require(grid)
library(igraph)
dcd1 <- read.dcd("wt-ca-traj1.dcd")
pdb1 <- read.pdb("wt-grep-ca.pdb")


inds1 <- atom.select(pdb1, elety="CA")
trj1 <- fit.xyz(fixed = pdb1$xyz, mobile = dcd1,
               fixed.inds = inds1$xyz, mobile.inds = inds1$xyz)
cij1 <- dccm(trj1)

net <- cna(cij1, cutoff.cij=0.6)

jpeg("cross_corl.jpg", res=300, height=10, width=10, units="in")
plot(cij1, margin.segments = net$communities$membership, col.regions=bwr.colors(200), contour=FALSE, at=seq(-1,1,by=0.4), main=expression(paste("Residue Cross Correlation [50 ns]")))
dev.off()

print(net)
x <- summary(net)
attributes(x)
x$members[5]


jpeg("Network-md.jpg", res=300, height=10, width=10, units="in")
plot(net, pdb1, full = TRUE, vertex.label.cex=0.7, main=expression(paste("MD: Full all-residue network: [50 ns]")))
dev.off()

OUTPUT for line 26
> jpeg("Network-md.jpg", res=300, height=10, width=10, units="in")

> plot(net, pdb1, full = TRUE, vertex.label.cex=0.7, main=expression(paste("MD: [50 ns]")))
Obtaining layout from PDB structure
Error in cmdscale(dist(cent), k = k) : NA values not allowed in 'd'
In addition: Warning messages:
1: In (function (graph, weights = E(graph)$weight, directed = TRUE,  :
  At community.c:459 :Membership vector will be selected based on the lowest modularity score.
2: In (function (graph, weights = E(graph)$weight, directed = TRUE,  :
  At community.c:464 :Modularity calculation with weighted edge betweenness community detection might not make sense -- modularity treats edge weights as similarities while edge betwenness treats them as distances
3: In cna.dccm(cij12345, cutoff.cij = 0.6) :
  The number of communities is larger than the number of unique 
              'colors' provided as input. Colors will be recycled

> sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Comments (7)

  1. Xinqiu Yao

    I think the problem is because of the duplicate residue numbers in the PDB file. Although duplicate numbers are allowed in multi-chain systems, you need to add chain IDs to distinguish different residues.

    Please fix the PDB file (by either using different residue numbers or adding unique chain IDs) and try again.

  2. Mohammad Avestan reporter

    the PDB is generated by CHARMM and the chain IDs are in the last column. I tried to bring them to the 5th column but it deformed the protein structure. And as you said it is a multiple chain protein and I generated the pdb, psf and cor file for each chain separately so that the chain are not attached to each other and then append the psf and cor files of all the chains to produce the final pdb, psf and cor file.

  3. Mohammad Avestan reporter

    I updated my pdb the way that you recommended. could you please check why it is not working now? thank you I am again getting this error

    #!> jpeg("Network-md-1gfp.jpg") ##, res=300, height=10, width=10, units="in")
    
    > plot(net, pdb1, full = TRUE, vertex.label.cex=0.7, main=expression(paste("MD: Full all-residue network-1gfp: [50 ns]")))
    Obtaining layout from PDB structure
    Error in cmdscale(dist(cent), k = k) : NA values not allowed in 'd'
    In addition: Warning messages:
    1: In (function (graph, weights = E(graph)$weight, directed = TRUE,  :
      At community.c:459 :Membership vector will be selected based on the lowest modularity score.
    2: In (function (graph, weights = E(graph)$weight, directed = TRUE,  :
      At community.c:464 :Modularity calculation with weighted edge betweenness community detection might not make sense -- modularity treats edge weights as similarities while edge betwenness treats them as distances
    3: In cna.dccm(cij1, cutoff.cij = 0.8) :
      The number of communities is larger than the number of unique 
                  'colors' provided as input. Colors will be recycled
    
  4. Mohammad Avestan reporter

    I generate a new pdb usig gromacs and it solved the problem.

    it seems bio3d has problem with the pdb saved using CHARMM.

    Thank you

  5. Log in to comment