Skip to content

Commit

Permalink
remove umap
Browse files Browse the repository at this point in the history
  • Loading branch information
kapoorlab committed Nov 4, 2023
1 parent 61784d7 commit acec5c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 39 deletions.
39 changes: 2 additions & 37 deletions src/napatrackmater/Trackvector.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from joblib import dump
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score
import umap


class TrackVector(TrackMate):
Expand Down Expand Up @@ -839,9 +838,6 @@ def unsupervised_clustering(
shape_dynamic_covariance_matrix = []
shape_covariance_matrix = []
dynamic_covariance_matrix = []
shape_dynamic_umap_matrix = []
shape_umap_matrix = []
dynamic_umap_matrix = []
for track_id, (
shape_dynamic_dataframe_list,
shape_dataframe_list,
Expand Down Expand Up @@ -876,12 +872,7 @@ def unsupervised_clustering(
dynamic_covaraince, dynamic_eigenvectors = compute_covariance_matrix(
dynamic_track_array
)
shape_dynamic_umap = compute_umap_matrix(shape_dynamic_track_array)
shape_umap = compute_umap_matrix(shape_track_array)
dynamic_umap = compute_umap_matrix(dynamic_track_array)
shape_dynamic_umap_matrix.append(shape_dynamic_umap)
shape_umap_matrix.append(shape_umap)
dynamic_umap_matrix.append(dynamic_umap)

shape_dynamic_covariance_matrix.append(shape_dynamic_covariance)
shape_covariance_matrix.append(shape_covariance)
dynamic_covariance_matrix.append(dynamic_covaraince)
Expand All @@ -894,10 +885,6 @@ def unsupervised_clustering(
shape_covariance_matrix = np.mean(shape_covariance_matrix, axis=0)
dynamic_covariance_matrix = np.mean(dynamic_covariance_matrix, axis=0)

shape_dynamic_umap_matrix = np.mean(shape_dynamic_umap_matrix, axis=0)
shape_umap_matrix = np.mean(shape_umap_matrix, axis=0)
dynamic_umap_matrix = np.mean(dynamic_umap_matrix, axis=0)

shape_dynamic_covariance_2d = shape_dynamic_covariance_3d.reshape(
len(analysis_track_ids), -1
)
Expand All @@ -909,11 +896,7 @@ def unsupervised_clustering(
shape_covariance_matrix,
dynamic_covariance_matrix,
]
track_umap_array = [
shape_dynamic_umap_matrix,
shape_umap_matrix,
dynamic_umap_matrix,
]

track_arrays_array_names = ["shape_dynamic", "shape", "dynamic"]
clusterable_track_arrays = [
shape_dynamic_covariance_2d,
Expand Down Expand Up @@ -966,16 +949,6 @@ def unsupervised_clustering(
)
np.save(mean_matrix_file_name, track_arrays)

umap_matrix_file_name = (
csv_file_name_original
+ track_arrays_array_names[track_arrays_array.index(track_arrays)]
+ "_umap.npy"
)
np.save(
umap_matrix_file_name,
track_umap_array[track_arrays_array.index(track_arrays)],
)

linkage_npy_file_name = (
csv_file_name_original
+ track_arrays_array_names[track_arrays_array.index(track_arrays)]
Expand Down Expand Up @@ -1050,14 +1023,6 @@ def compute_covariance_matrix(track_arrays):
return covariance_matrix, eigenvectors


def compute_umap_matrix(track_arrays):

reducer = umap.UMAP()
umap_result = reducer.fit_transform(track_arrays)

return umap_result


def _save_feature_importance(
sorted_feature_names,
normalized_importances,
Expand Down
4 changes: 2 additions & 2 deletions src/napatrackmater/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = version = "4.4.5"
__version_tuple__ = version_tuple = (4, 4, 5)
__version__ = version = "4.4.6"
__version_tuple__ = version_tuple = (4, 4, 6)

0 comments on commit acec5c5

Please sign in to comment.