markovmodel / PyEMMA

🚂 Python API for Emma's Markov Model Algorithms 🚂
http://pyemma.org
GNU Lesser General Public License v3.0
306 stars 119 forks source link

Eigenvalues associated with the eigenvectors of TICA #1581

Open qasimpars opened 1 year ago

qasimpars commented 1 year ago

Hi,

I would calculate the (positional) variance associated with the first eigenvector of TICA but I don't know how to do that. Could you please tell me how I can get/write the eigenvalues associated the eigenvectors of TICA? Is there a command line for that?

Best,

clonker commented 1 year ago

Hi you can access them like this:

import pyemma
import deeptime
sys = deeptime.data.double_well_2d()
traj = sys.trajectory([[0, 0]], 10000)
print(traj.shape)
>> (10000, 2)

tica = pyemma.coordinates.tica(traj)
print(tica.eigenvalues)
>> array([ 0.0257529 , -0.00124387])

print(tica.eigenvectors)
>> array([[ 0.02641758,  0.00022611],
       [ 0.01163282, -0.0034579 ]])

Or using deeptime:

import deeptime
sys = deeptime.data.double_well_2d()
traj = sys.trajectory([[0, 0]], 10000)
print(traj.shape)

tica = deeptime.decomposition.TICA(lagtime=1).fit_fetch(traj)
print(tica.singular_values)
print(tica.singular_vectors_left)
qasimpars commented 1 year ago

Hi,

Thank you very much @clonker. It works. Sorry but I have two more questions about the variance:

  1. How can I get the percentages of the variance associated with the first and the second eigenvectors of TICA (e.g. X% for eigenvector 1 and y% for eigenvector 2?
  2. How can I get the total variance associated with all eigenvector of a trajectory?

Regards,

clonker commented 1 year ago

Hi,

this is not really how TICA works and I am not sure you even can associate a positional variance to TICs. You are probably thinking in terms of PCA, where you can identify a projection axis with variance captured in the data. Here however we look at covariances and autocovariances, so in particular at timelagged pairs of data and slow processes in the data. What you can do is look at feature correlations though.

qasimpars commented 1 year ago

Hi,

Thanks. How can I look at feature correlations of a trajectory using TICA? Can you recommend me a tutorial or something like that?

Best,

clonker commented 1 year ago

You can just access the feature_TIC_correlation attribute on an estimated TICA object. That will give you the correlation matrix between (mean free) input features and tics.