| Module |
dimred |
| Description |
Usage |
| Create a low-dimensional projection of a trajectory using the classical multidimensional |
  |
| output value |
type |
| the low dimensional projections for the input data points |
matrix |
Details and examples
Create a low-dimensional projection of a trajectory using the classical multidimensional
scaling algorithm.
Multidimensional scaling (MDS) is similar to what is done when you make a map. You start with distances
between London, Belfast, Paris and Dublin and then you try to arrange points on a piece of paper so that the (suitably scaled)
distances between the points in your map representing each of those cities are related to the true distances between the cities.
Stating this more mathematically MDS endeavors to find an isometry
between points distributed in a high-dimensional space and a set of points distributed in a low-dimensional plane.
In other words, if we have
-dimensional points, ,
and we can calculate dissimilarities between pairs them, , we can, with an MDS calculation, try to create projections,
, of the high dimensionality points in a -dimensional linear space by trying to arrange the projections so that the
Euclidean distances between pairs of them, , resemble the dissimilarities between the high dimensional points. In short we minimize:
where is the distance between point and point and is the distance between the projection
of , , and the projection of , . A tutorial on this approach can be used to analyze simulations
can be found in this tutorial and in the following short video.
Examples
The following command instructs plumed to construct a classical multidimensional scaling projection of a trajectory.
The RMSD distance between atoms 1-256 have moved is used to measure the distances in the high-dimensional space.
By contrast the following input instructs PLUMED to calculate the distances between atoms by taking the differences in five torsional angles.
The MDS algorithm is then used to arrange a set of points in a low dimensional space in a way that reproduces these differences.
phi1The TORSION action with label phi1 calculates the following quantities:| Quantity | Type | Description |
| phi1 | scalar | the TORSION involving these atoms |
: TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=1,2,3,4
phi2The TORSION action with label phi2 calculates the following quantities:| Quantity | Type | Description |
| phi2 | scalar | the TORSION involving these atoms |
: TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=5,6,7,8
phi3The TORSION action with label phi3 calculates the following quantities:| Quantity | Type | Description |
| phi3 | scalar | the TORSION involving these atoms |
: TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=9,10,11,12
phi4The TORSION action with label phi4 calculates the following quantities:| Quantity | Type | Description |
| phi4 | scalar | the TORSION involving these atoms |
: TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=13,14,15,16
phi5The TORSION action with label phi5 calculates the following quantities:| Quantity | Type | Description |
| phi5 | scalar | the TORSION involving these atoms |
: TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=17,18,19,20
anglesThe COLLECT_FRAMES action with label angles calculates the following quantities:| Quantity | Type | Description |
| angles_data | matrix | the data that is being collected by this action |
| angles_logweights | vector | the logarithms of the weights of the data points |
: COLLECT_FRAMESCollect atomic positions or argument values from the trajectory for later analysis This action is a shortcut and it has hidden defaults. More details ARGthe labels of the values whose time series you would like to collect for later analysis=phi1,phi2,phi3,phi4,phi5
The COLLECT_FRAMES action with label angles calculates the following quantities:| Quantity | Description |
| angles.data | the data that is being collected by this action |
| angles.logweights | the logarithms of the weights of the data points |
angles: COLLECT_FRAMESCollect atomic positions or argument values from the trajectory for later analysis This action is a shortcut and uses the defaults shown here. More details ARGthe labels of the values whose time series you would like to collect for later analysis=phi1,phi2,phi3,phi4,phi5 STRIDE the frequency with which data should be stored for analysis=1 CLEAR the frequency with which data should all be deleted and restarted=0
# angles: COLLECT_FRAMES ARG=phi1,phi2,phi3,phi4,phi5
angles_phi1The COLLECT action with label angles_phi1 calculates the following quantities:| Quantity | Type | Description |
| angles_phi1 | vector | the time series for the input quantity |
: COLLECTCollect data from the trajectory for later analysis More details ARGthe label of the value whose time series is being stored for later analysis=phi1 STRIDE the frequency with which the data should be collected and added to the quantity being averaged=1 CLEAR the frequency with which to clear all the accumulated data=0
angles_phi2The COLLECT action with label angles_phi2 calculates the following quantities:| Quantity | Type | Description |
| angles_phi2 | vector | the time series for the input quantity |
: COLLECTCollect data from the trajectory for later analysis More details ARGthe label of the value whose time series is being stored for later analysis=phi2 STRIDE the frequency with which the data should be collected and added to the quantity being averaged=1 CLEAR the frequency with which to clear all the accumulated data=0
angles_phi3The COLLECT action with label angles_phi3 calculates the following quantities:| Quantity | Type | Description |
| angles_phi3 | vector | the time series for the input quantity |
: COLLECTCollect data from the trajectory for later analysis More details ARGthe label of the value whose time series is being stored for later analysis=phi3 STRIDE the frequency with which the data should be collected and added to the quantity being averaged=1 CLEAR the frequency with which to clear all the accumulated data=0
angles_phi4The COLLECT action with label angles_phi4 calculates the following quantities:| Quantity | Type | Description |
| angles_phi4 | vector | the time series for the input quantity |
: COLLECTCollect data from the trajectory for later analysis More details ARGthe label of the value whose time series is being stored for later analysis=phi4 STRIDE the frequency with which the data should be collected and added to the quantity being averaged=1 CLEAR the frequency with which to clear all the accumulated data=0
angles_phi5The COLLECT action with label angles_phi5 calculates the following quantities:| Quantity | Type | Description |
| angles_phi5 | vector | the time series for the input quantity |
: COLLECTCollect data from the trajectory for later analysis More details ARGthe label of the value whose time series is being stored for later analysis=phi5 STRIDE the frequency with which the data should be collected and added to the quantity being averaged=1 CLEAR the frequency with which to clear all the accumulated data=0
angles_dataThe VSTACK action with label angles_data calculates the following quantities:| Quantity | Type | Description |
| angles_data | matrix | a matrix that contains the input vectors in its columns |
: VSTACKCreate a matrix by stacking vectors together More details ARGthe values that you would like to stack together to construct the output matrix=angles_phi1,angles_phi2,angles_phi3,angles_phi4,angles_phi5
angles_cweightThe CONSTANT action with label angles_cweight calculates the following quantities:| Quantity | Type | Description |
| angles_cweight | scalar | the constant value that was read from the plumed input |
: CONSTANTCreate a constant value that can be passed to actions More details VALUEthe single number that you would like to store=0
angles_logweightsThe COLLECT action with label angles_logweights calculates the following quantities:| Quantity | Type | Description |
| angles_logweights | vector | the time series for the input quantity |
: COLLECTCollect data from the trajectory for later analysis More details ARGthe label of the value whose time series is being stored for later analysis=angles_cweight STRIDE the frequency with which the data should be collected and added to the quantity being averaged=1 CLEAR the frequency with which to clear all the accumulated data=0
angles_oneThe CONSTANT action with label angles_one calculates the following quantities:| Quantity | Type | Description |
| angles_one | scalar | the constant value that was read from the plumed input |
: CONSTANTCreate a constant value that can be passed to actions More details VALUEthe single number that you would like to store=1
angles_onesThe COLLECT action with label angles_ones calculates the following quantities:| Quantity | Type | Description |
| angles_ones | vector | the time series for the input quantity |
: COLLECTCollect data from the trajectory for later analysis More details ARGthe label of the value whose time series is being stored for later analysis=angles_one STRIDE the frequency with which the data should be collected and added to the quantity being averaged=1 CLEAR the frequency with which to clear all the accumulated data=0
# --- End of included input --- mdsThe CLASSICAL_MDS action with label mds calculates the following quantities:| Quantity | Type | Description |
| mds | matrix | the low dimensional projections for the input data points |
: CLASSICAL_MDSCreate a low-dimensional projection of a trajectory using the classical multidimensional This action is a shortcut. More details ARGthe arguments that you would like to make the histogram for=angles NLOW_DIMnumber of low-dimensional coordinates required=2
# mds: CLASSICAL_MDS ARG=angles NLOW_DIM=2
angles_dataTThe TRANSPOSE action with label angles_dataT calculates the following quantities:| Quantity | Type | Description |
| angles_dataT | matrix | the transpose of the input matrix |
: TRANSPOSECalculate the transpose of a matrix More details ARGthe label of the vector or matrix that should be transposed=angles_data
mds_matThe DISSIMILARITIES action with label mds_mat calculates the following quantities:| Quantity | Type | Description |
| mds_mat | matrix | the dissimilarity matrix |
: DISSIMILARITIESCalculate the matrix of dissimilarities between a trajectory of atomic configurations. More details SQUARED calculate the squares of the dissimilarities (this option cannot be used with MATRIX_PRODUCT) ARGthe label of the two matrices from which the product is calculated=angles_data,angles_dataT
mds_rsumsThe MATRIX_VECTOR_PRODUCT action with label mds_rsums calculates the following quantities:| Quantity | Type | Description |
| mds_rsums | vector | the vector that is obtained by taking the product between the matrix and the vector that were input |
: MATRIX_VECTOR_PRODUCTCalculate the product of the matrix and the vector More details ARGthe label for the matrix and the vector/scalar that are being multiplied=mds_mat,angles_ones
mds_nonesThe SUM action with label mds_nones calculates the following quantities:| Quantity | Type | Description |
| mds_nones | scalar | the SUM of the elements in the input value |
: SUMCalculate the sum of the arguments More details ARGthe vector/matrix/grid whose elements shuld be added together=angles_ones PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO
mds_rsumsnThe CUSTOM action with label mds_rsumsn calculates the following quantities:| Quantity | Type | Description |
| mds_rsumsn | vector | the vector obtained by doing an element-wise application of an arbitrary function to the input vectors |
: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=mds_rsums,mds_nones FUNCthe function you wish to evaluate=x/y PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO
mds_rsummatThe OUTER_PRODUCT action with label mds_rsummat calculates the following quantities:| Quantity | Type | Description |
| mds_rsummat | matrix | a matrix containing the outer product of the two input vectors that was obtained using the function that was input |
: OUTER_PRODUCTCalculate the outer product matrix of two vectors More details ARGthe labels of the two vectors from which the outer product is being computed=mds_rsumsn,angles_ones
mds_intThe CUSTOM action with label mds_int calculates the following quantities:| Quantity | Type | Description |
| mds_int | matrix | the matrix obtained by doing an element-wise application of an arbitrary function to the input matrix |
: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=mds_rsummat,mds_mat FUNCthe function you wish to evaluate=-0.5*y+0.5*x PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO
mds_intTThe TRANSPOSE action with label mds_intT calculates the following quantities:| Quantity | Type | Description |
| mds_intT | matrix | the transpose of the input matrix |
: TRANSPOSECalculate the transpose of a matrix More details ARGthe label of the vector or matrix that should be transposed=mds_int
mds_csumsThe MATRIX_VECTOR_PRODUCT action with label mds_csums calculates the following quantities:| Quantity | Type | Description |
| mds_csums | vector | the vector that is obtained by taking the product between the matrix and the vector that were input |
: MATRIX_VECTOR_PRODUCTCalculate the product of the matrix and the vector More details ARGthe label for the matrix and the vector/scalar that are being multiplied=mds_intT,angles_ones
mds_csumsnThe CUSTOM action with label mds_csumsn calculates the following quantities:| Quantity | Type | Description |
| mds_csumsn | vector | the vector obtained by doing an element-wise application of an arbitrary function to the input vectors |
: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=mds_csums,mds_nones FUNCthe function you wish to evaluate=x/y PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO
mds_csummatThe OUTER_PRODUCT action with label mds_csummat calculates the following quantities:| Quantity | Type | Description |
| mds_csummat | matrix | a matrix containing the outer product of the two input vectors that was obtained using the function that was input |
: OUTER_PRODUCTCalculate the outer product matrix of two vectors More details ARGthe labels of the two vectors from which the outer product is being computed=mds_csumsn,angles_ones
mds_cmatThe CUSTOM action with label mds_cmat calculates the following quantities:| Quantity | Type | Description |
| mds_cmat | matrix | the matrix obtained by doing an element-wise application of an arbitrary function to the input matrix |
: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=mds_csummat,mds_intT FUNCthe function you wish to evaluate=y-x PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO
mds_eigThe DIAGONALIZE action with label mds_eig calculates the following quantities:| Quantity | Type | Description |
| mds_eig.vals-1 | scalar | the eigevalues of the input matrix This is the 1th of these quantities |
| mds_eig.vecs-1 | vector | the eigenvectors of the input matrix This is the 1th of these quantities |
| mds_eig.vals-2 | scalar | the eigevalues of the input matrix This is the 2th of these quantities |
| mds_eig.vecs-2 | vector | the eigenvectors of the input matrix This is the 2th of these quantities |
: DIAGONALIZECalculate the eigenvalues and eigenvectors of a square matrix More details ARGthe input matrix=mds_cmat VECTORS the eigenvalues and vectors that you would like to calculate=1,2
mds-1The CUSTOM action with label mds-1 calculates the following quantities:| Quantity | Type | Description |
| mds-1 | vector | the vector obtained by doing an element-wise application of an arbitrary function to the input vectors |
: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=mds_eig.vecs-1,mds_eig.vals-1 FUNCthe function you wish to evaluate=sqrt(y)*x PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO
mds-2The CUSTOM action with label mds-2 calculates the following quantities:| Quantity | Type | Description |
| mds-2 | vector | the vector obtained by doing an element-wise application of an arbitrary function to the input vectors |
: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=mds_eig.vecs-2,mds_eig.vals-2 FUNCthe function you wish to evaluate=sqrt(y)*x PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO
mdsThe VSTACK action with label mds calculates the following quantities:| Quantity | Type | Description |
| mds | matrix | a matrix that contains the input vectors in its columns |
: VSTACKCreate a matrix by stacking vectors together More details ARGthe values that you would like to stack together to construct the output matrix=mds-1,mds-2
# --- End of included input --- weightsThe CUSTOM action with label weights calculates the following quantities:| Quantity | Type | Description |
| weights | vector | the vector obtained by doing an element-wise application of an arbitrary function to the input vectors |
: CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=angles.logweights FUNCthe function you wish to evaluate=exp(x) PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO
DUMPVECTORPrint a vector to a file More details ARGthe labels of vectors/matrices that should be output in the file=mds,weights FILE the file on which to write the vetors=list_embed
The following section is for people who are interested in how this method works in detail. A solid understanding of this material is
not necessary to use MDS.
Method of optimization
The stress function can be minimized using the conjugate gradients or steepest descent optimization algorithms that are implemented in ARRANGE_POINTS.
However, it is more common to do this minimization using a technique known as classical scaling. Classical scaling works by
recognizing that each of the distances in the above sum can be written as:
We can use this expression and matrix algebra to calculate multiple distances at once. For instance if we have three points,
, we can write distances between them as:
This last equation can be extended to situations when we have more than three points. In it is a matrix that has
one high-dimensional point on each of its rows and is its transpose. is an vector
of ones and is a vector with components given by:
These quantities are the diagonal elements of , which is a dot product or Gram Matrix that contains the
dot product of the vector with the vector in element .
In classical scaling we introduce a centering matrix that is given by:
where is the identity. Multiplying the equations above from the front and back by this matrix and a factor of a gives:
The fist two terms in this expression disappear because , where
is a matrix containing all zeros. In the final step meanwhile we use the fact that the matrix of squared distances will not
change when we translate all the points. We can thus assume that the mean value, , for each of the components, :
is equal to 0 so the columns of add up to 0. This in turn means that each of the columns of
adds up to zero, which is what allows us to write .
The matrix of squared distances is symmetric and positive-definite we can thus use the spectral decomposition to decompose it as:
Furthermore, because the matrix we are diagonalizing, , is the product of a matrix and its transpose
we can use this decomposition to write:
Much as in PCA there are generally a small number of large eigenvalues in and many small eigenvalues.
We can safely use only the large eigenvalues and their corresponding eigenvectors to express the relationship between
the coordinates . This gives us our set of low-dimensional projections.
This derivation makes a number of assumptions about the how the low dimensional points should best be arranged to minimize
the stress. If you use an interactive optimization algorithm such as SMACOF you may thus be able to find a better
(lower-stress) projection of the points. For more details on the assumptions made
see this website.
Full list of keywords
The following table describes the keywords and options that can be used with this action
| Keyword |
Type |
Default |
Description |
| ARG |
compulsory |
none |
the arguments that you would like to make the histogram for |
| NLOW_DIM |
compulsory |
none |
number of low-dimensional coordinates required |