htmd.metricdata.
MetricData
(dat=None, ref=None, description=None, simlist=None, fstep=0, parent=None, file=None, trajectories=None, cluster=None)¶Bases: object
Class used for storing projected trajectories, their clustering and state assignments. Objects of this class are constructed by the project methods of the other projection classes. Only construct this class if you want to load saved data.
dat
¶numpy.ndarray – The projected metrics
ref
¶numpy.ndarray – Reference indices to the simulations and frames that generated the metrics
fstep
¶float – Size of simulation step in ns
map
¶numpy.ndarray – Contains the mapping from columns in dat to atom indices
parent
¶MetricData
object – The MetricData object that was used to generate this object
St
¶numpy.ndarray – Assignment of simulation frames to clusters
K
¶int – Number of clusters
N
¶numpy.ndarray – Populations of clusters
Centers
¶numpy.ndarray – Centers of clusters
St
abs2rel
(absFrames)¶Convert absolute frame indexes into trajectory index-frame pairs
Useful when doing calculations on a concatenated data array of all trajectories. When you find a frame of interest you can deconcatenate the frame index to the corresponding trajectory index-frame pair.
Parameters: | absFrames (list of int) – A list of absolute index frames |
---|---|
Returns: | pairs – A array where each row is a trajectory index-frame pair |
Return type: | np.ndarray |
Examples
>>> relidx = data.abs2rel(536)
abs2sim
(absFrames)¶Converts absolute frame indexes into Sim-frame pairs
Parameters: | absFrames (list of int) – A list of absolute index frames |
---|---|
Returns: | frames – An array of Frame objects containing the simulation object, the trajectory
piece ID and the frame index. |
Return type: | np.ndarray |
Examples
>>> simframes = data.abs2sim(563) # 563rd frame to simulation/frame pairs
aggregateTime
¶The total aggregate simulation time
Examples
>>> data.aggTime
append
(other)¶bootstrap
(ratio, replacement=False)¶Randomly sample a set of trajectories
Parameters: | |
---|---|
Returns: | bootdata – A new |
Return type: |
|
Examples
>>> data = MetricSelfDistance.project(sims, 'protein and name CA')
>>> databoot = data.bootstrap(0.8)
cluster
(clusterobj, mergesmall=None, batchsize=False)¶Cluster the metrics
Parameters: |
|
---|
Examples
>>> from sklearn.cluster import MiniBatchKMeans
>>> data = MetricDistance.project(sims, 'protein and name CA', 'resname MOL')
>>> data.cluster(MiniBatchKMeans(n_clusters=1000), mergesmall=5)
combine
(otherdata)¶Combines two different metrics into one by concatenating them.
Parameters: | otherdata (MetricData object) – Concatenates the metrics of otherdata to the current objects metrics |
---|
Examples
>>> dataRMSD = MetricRmsd.project(sims)
>>> dataDist = MetricSelfDistance.project(sims, 'protein and name CA')
>>> dataRMSD.combine(dataDist)
copy
()¶Produces a deep copy of the object
Returns: | data – A copy of the current object |
---|---|
Return type: | MetricData object |
Examples
>>> data = MetricSelfDistance.project(sims, 'protein and name CA')
>>> data2 = data.copy()
dat
deconcatenate
(array)¶dropDimensions
(drop=None, keep=None)¶Drop some dimensions of the data given their indexes
Parameters: |
---|
Examples
>>> data.dropDimensions([1, 24, 3])
>>> data.dropDimensions(keep=[2, 10])
dropFrames
(idx, frames)¶dropTraj
(limits=None, multiple=None, partial=None, idx=None, keepsims=None)¶Drops trajectories based on their lengths
By default, drops all trajectories which are not of statistical mode (most common) length.
Parameters: |
|
---|
Examples
>>> data = MetricSelfDistance.project(sims, 'protein and name CA')
>>> data.dropTraj()
>>> data.dropTraj(multiple=[100])
load
(filename)¶Load a MetricData
object from disk
Parameters: | filename (str) – Path to the saved MetricData object |
---|
Examples
>>> data = MetricData()
>>> data.load('./data.dat')
map
numDimensions
¶The number of dimensions
Examples
>>> data.numDimensions
numFrames
¶Get the total number of frames in all trajectories
Returns: | nframes – Total number of frames in all trajectories |
---|---|
Return type: | int |
Examples
>>> data.numFrames
numTrajectories
¶The number of trajectories
Examples
>>> data.numTrajectories
plotClusters
(dimX, dimY, resolution=100, s=4, c=None, cmap=None, logplot=False, plot=True, save=None, data=None)¶Plot a scatter-plot of the locations of the clusters on top of the count histogram.
Parameters: |
|
---|
plotCounts
(dimX, dimY, resolution=100, logplot=False, plot=True, save=None)¶Plots a histogram of counts on any two given dimensions.
Parameters: |
|
---|
plotTrajSizes
()¶Plot the lengths of all trajectories in a sorted bar plot
Examples
>>> data = MetricSelfDistance.project(sims, 'protein and name CA')
>>> data.plotTrajSizes()
ref
rel2sim
(relFrames, simlist=None)¶Converts trajectory index-frame pairs into Sim-frame pairs
Parameters: |
|
---|---|
Returns: | frames – An array of |
Return type: | np.ndarray |
Examples
>>> simframes = data.rel2sim([100, 56]) # 100th simulation frame 56
sampleClusters
(clusters=None, frames=20, replacement=False, allframes=False)¶Samples frames from a set of clusters
Parameters: |
|
---|---|
Returns: |
|
Examples
>>> data.sampleClusters(range(5), [10, 3, 2, 50, 1]) # Sample from first 5 clusters, 10, 3, etc frames respectively
sampleRegion
(point=None, radius=None, limits=None, nsamples=20, singlemol=False)¶Samples conformations from a region in the projected space.
Parameters: |
|
---|---|
Returns: |
|
Examples
>>> # Working with 4 dimensional data for example
>>> abs, rel, mols = data.sampleRegion(point=(0.5, 3, None, None), radius=0.1) # Point undefined in dim 3, 4
>>> minlims = [-1, None, None, 4] # No min limit for 2, 3 dim
>>> maxlims = [2, 3, None, 7] # No max limit for 3 dim
>>> abs, rel, mols = data.sampleRegion(limits=np.array([minlims, maxlims]))
save
(filename)¶Save a MetricData
object to disk
Parameters: | filename (str) – Path of the file in which to save the object |
---|
Examples
>>> data = MetricSelfDistance.project(sims, 'protein and name CA')
>>> data.save('./data.dat')
simlist
splitCols
()¶