Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explanations to docstrings of sorting and projecting functions. #65

Merged
merged 1 commit into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pensa/dimensionality/pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ def pca_features(tica, features, num, threshold, plot_file=None, add_labels=Fals

def project_on_pc(data, ev_idx, pca=None, dim=-1):
"""
Projects a trajectory onto an eigenvector of its PCA.

Projects a trajectory onto an eigenvector of its PCA, i.e., calculates the value along this component at each step of the trajectory (retains the order of the trajectory).
Note that the eigenvector is indexed starting from zero.

Parameters
----------
data : float array
Expand Down Expand Up @@ -136,7 +137,8 @@ def get_components_pca(data, num, pca=None, prefix=''):

def sort_traj_along_pc(data, top, trj, out_name, pca=None, num_pc=3, start_frame=0):
"""
Sort a trajectory along principal components.
Sort a trajectory along principal components.
For each of the num_pc specified components, return a trajectory in which the frames are ordered by their value along the respective components.

Parameters
----------
Expand Down Expand Up @@ -181,6 +183,7 @@ def sort_traj_along_pc(data, top, trj, out_name, pca=None, num_pc=3, start_frame
def sort_trajs_along_common_pc(data_a, data_b, top_a, top_b, trj_a, trj_b, out_name, num_pc=3, start_frame=0):
"""
Sort two trajectories along their most important common principal components.
For each of the num_pc specified components, return a trajectory in which the frames from both original trajectories are ordered by their value along the respective components.

Parameters
----------
Expand Down Expand Up @@ -225,7 +228,8 @@ def sort_trajs_along_common_pc(data_a, data_b, top_a, top_b, trj_a, trj_b, out_n
def sort_mult_trajs_along_common_pc(data, top, trj, out_name, num_pc=3, start_frame=0):
"""
Sort multiple trajectories along their most important common principal components.

For each of the num_pc specified components, return a trajectory in which the frames from all original trajectories are ordered by their value along the respective components.

Parameters
----------
data : list of float arrays
Expand Down
8 changes: 6 additions & 2 deletions pensa/dimensionality/tica.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ def tica_features(tica, features, num, threshold, plot_file=None, add_labels=Fal

def project_on_tic(data, ev_idx, tica=None, dim=-1, lag=10):
"""
Projects a trajectory onto an eigenvector of its TICA.

Projects a trajectory onto an eigenvector of its TICA, i.e., calculates the value along this component at each step of the trajectory (retains the order of the trajectory)
Note that the eigenvector is indexed starting from zero.

Parameters
----------
data : float array
Expand Down Expand Up @@ -148,6 +149,7 @@ def get_components_tica(data, num, tica=None, lag=10, prefix=''):
def sort_traj_along_tic(data, top, trj, out_name, tica=None, num_ic=3, lag=10, start_frame=0):
"""
Sort a trajectory along independent components.
For each of the num_pc specified components, return a trajectory in which the frames are ordered by their value along the respective components.

Parameters
----------
Expand Down Expand Up @@ -195,6 +197,7 @@ def sort_traj_along_tic(data, top, trj, out_name, tica=None, num_ic=3, lag=10, s
def sort_trajs_along_common_tic(data_a, data_b, top_a, top_b, trj_a, trj_b, out_name, num_ic=3, lag=10, start_frame=0):
"""
Sort two trajectories along their most important common time-lagged independent components.
For each of the num_pc specified components, return a trajectory in which the frames from both original trajectories are ordered by their value along the respective components.

Parameters
----------
Expand Down Expand Up @@ -242,6 +245,7 @@ def sort_trajs_along_common_tic(data_a, data_b, top_a, top_b, trj_a, trj_b, out_
def sort_mult_trajs_along_common_tic(data, top, trj, out_name, num_ic=3, lag=10, start_frame=0):
"""
Sort multiple trajectories along their most important independent components.
For each of the num_pc specified components, return a trajectory in which the frames from all original trajectories are ordered by their value along the respective components.

Parameters
----------
Expand Down