neurosnap.algos.clusterprot module#
Implementation of the ClusterProt algorithm from https://neurosnap.ai/service/ClusterProt. ClusterProt is an algorithm for clustering proteins by their structure similarity.
- neurosnap.algos.clusterprot.ClusterProt(proteins, model=0, chain=None, umap_n_neighbors=0, proj_1d_algo='umap', dbscan_eps=0, dbscan_min_samples=0, eps_scale_factor=0.05)[source]#
Run the ClusterProt algorithm on some input proteins.
Clusters proteins using their structural similarity.
- Algorithm Description:
Ensure all protein structures are fully loaded
Compute the distance matrices of using the alpha carbons of all the loaded proteins from the selected regions
Get the flattened upper triangle of the of the distance matrices excluding the diagonal.
Align all the proteins to the reference protein (optional but useful for analysis like the animation)
Create the 2D projection using UMAP
Create clusters for the 2D projection using DBSCAN
Create the 1D projection using either UMAP or PCA (optional but useful for organizing proteins 1-dimensionally)
- Parameters:
proteins (
List[Union[Protein,str]]) – List of proteins to cluster, can be either neurosnap Protein objects of filepaths to proteins that will get loaded as Protein objectsmodel (
int) – Model ID to for ClusterProt to use (must be consistent across all structures)chain (
Optional[str]) – Chain ID to for ClusterProt to use (must be consistent across all structures), if not provided calculates for all chainsumap_n_neighbors (
int) – Then_neighborsvalue to provide to UMAP for the main projection. Leave as 0 to automatically calculate optimal value. Prior to the 2024-06-14 update this values was left as7.proj_1d_algo (
str) – Algorithm to use for the 1D projection. Can be either"umap"or"pca"dbscan_eps (
float) – Theepsvalue to provide to DBSCAN. Leave as 0 to automatically calculate optimal value. Prior to the 2024-04-15 update this values was left as0.5.dbscan_min_samples (
int) – Themin_samplesvalue to provide to DBSCAN. Leave as 0 to automatically calculate optimal value. Prior to the 2024-04-15 update this values was left as5.eps_scale_factor (
float) – Fraction of the 2D data’s diagonal range used to set DBSCAN’s eps. Recommended: 0.05-0.10 for larger datasets or finer clusters; 0.15 for smaller datasets or broader clustering.
- Returns:
proteins (list<Protein>): Sorted list of all the neurosnap Proteins aligned by the reference protein.
projection_2d (list<list<float>>): Generated 2D projection of all the proteins.
cluster_labels (list<float>): List of the labels for each of the proteins.
- Return type:
A dictionary containing the results from the algorithm