我有一个从MDAnalysis.pca.transform()生成的形状(150017,5)的数组tpcs。我试图将其加载为可视化的轨迹。我试过了:
u = mda.Universe(trjpath+'md.gro', tpcs)
返回错误:
ValueError Traceback (most recent call last)
<ipython-input-80-ea97f213be3c> in <module>()
----> 1 u = mda.Universe(trjpath+'md.gro', tpcs)
/nfs/homes/kreidy/Library/mdanalysis/package/MDAnalysis/core/universe.pyc in __init__(self, *args, **kwargs)
276 else:
277 coordinatefile = args[1:]
--> 278 self.load_new(coordinatefile, **kwargs)
279
280 # Check for guess_bonds
/nfs/homes/kreidy/Library/mdanalysis/package/MDAnalysis/core/universe.pyc in load_new(self, filename, format, in_memory, **kwargs)
424 kwargs['n_atoms'] = self.atoms.n_atoms
425
--> 426 self.trajectory = reader(filename, **kwargs)
427 if self.trajectory.n_atoms != len(self.atoms):
428 raise ValueError("The topology and {form} trajectory files don't"
/nfs/homes/kreidy/Library/mdanalysis/package/MDAnalysis/coordinates/memory.pyc in __init__(self, coordinate_array, order, dimensions, dt, filename, **kwargs)
275 "does not match the shape of the coordinate "
276 "array ({})"
--> 277 .format(provided_n_atoms, self.n_atoms))
278
279 self.ts = self._Timestep(self.n_atoms, **kwargs)
ValueError: The provided value for n_atoms (132506) does not match the shape of the coordinate array (5)
如何将此数组加载到轨迹中?
答案 0 :(得分:0)
您只能将加载3维数据存储在gro文件中。您使用的PCA空间是5维。除了通过MDAnalysis可视化PCA空间之外也行不通。您可以使用gromacs在PCA识别的状态之间显示非物理变形。
单个PCA组件是可以使用matplotlib绘制的集体变量。单独或成对。有关PCA空间的可视化以及如何使用MDAnalysis和Gromacs可视化PCA找到的状态,请参见此gist。