From 812f17fd2548198306fc1325046b22ac88b5a7a3 Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Wed, 9 Dec 2020 14:56:39 -0500 Subject: [PATCH] Ensure all empty motifs present in motif_usage.npy --- vame/analysis/behavior_structure.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/vame/analysis/behavior_structure.py b/vame/analysis/behavior_structure.py index fa092b19..8cc9736f 100644 --- a/vame/analysis/behavior_structure.py +++ b/vame/analysis/behavior_structure.py @@ -75,9 +75,19 @@ def get_network(path_to_file, file, cluster_method, n_cluster): motif_usage = np.unique(labels, return_counts=True) cons = consecutive(motif_usage[0]) if len(cons) != 1: + used_motifs = list(motif_usage[0]) usage_list = list(motif_usage[1]) - index = cons[0][-1]+1 - usage_list.insert(index,0) + + for i in range(n_cluster): + if i not in used_motifs: + used_motifs.insert(i, i) + usage_list.insert(i,0) + + # for i in range(len(cons)): + # index = cons[i][-1]+1 + # usage_list.insert(index,0) + # if index != cons[i+1][-1]+1: + # usage_list.insert(index+1,0) usage = np.array(usage_list)