-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcs_veloTools.py
More file actions
67 lines (60 loc) · 2.14 KB
/
cs_veloTools.py
File metadata and controls
67 lines (60 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# custom function to also reduce umap data
def filter_cells(self, bool_array: np.ndarray) -> None:
"""Filter cells using a boolean array.
Arguments
---------
bool_array: np.ndarray (size )
array describing the cells to keep (True).
Return
------
Nothing but it removes some cells from S and U.
"""
self.S, self.U, self.A = (X[:, bool_array] for X in (self.S, self.U, self.A))
self.initial_cell_size = self.initial_cell_size[bool_array]
self.initial_Ucell_size = self.initial_Ucell_size[bool_array]
self.ca = {k: v[bool_array] for k, v in self.ca.items()}
# for object that have been normalized already
try:
self.S_sz, self.S_norm, self.U_sz, self.U_norm = (X[:, bool_array] for X in (self.S_sz, self.S_norm, self.U_sz, self.U_norm))
self.cell_size = self.cell_size[bool_array]
self.Ucell_size = self.Ucell_size[bool_array]
self.norm_factor = self.norm_factor[bool_array]
self.Unorm_factor = self.Unorm_factor[bool_array]
except:
pass
# for objects that have been dimension reduced
try:
self.pcs = self.pcs[bool_array] # type: np.ndarray
except:
pass
try:
self.ts = self.ts[bool_array] # type: np.ndarray
except:
pass
try:
self.um = self.um[bool_array] # type: np.ndarray
except:
pass
try:
self.embedding = self.embedding[bool_array] # type: np.ndarray
except:
pass
try:
self.delta_embedding_random = self.delta_embedding_random[bool_array] # type: np.ndarray
except:
pass
try:
self.delta_embedding = self.delta_embedding[bool_array] # type: np.ndarray
except:
pass
# for objects which have been score_cv_vs_mean'd
try:
self.size_factor = self.size_factor[bool_array] # type: np.ndarray
except:
pass
# for objects that have cluster assignments
try:
self.cluster_labels = self.cluster_labels[bool_array] # type: np.ndarray
self.colorandum = self.colorandum[bool_array, :] # type: np.ndarray
except AttributeError:
pass