@@ -174,12 +174,19 @@ def __init__(self,
174174 recompute_graph = None ,
175175 flavor = 'haghverdi16' ):
176176 self .sym = True # we do not allow asymetric cases
177+ self .flavor = flavor # this is to experiment around
178+ self .n_pcs = n_pcs
179+ self .n_dcs = n_dcs
177180 # use the graph in adata
178181 if (not recompute_graph
182+ # make sure X_diffmap is there
179183 and 'X_diffmap' in adata .smp
180- and adata .smp ['X_diffmap' ].shape [1 ] >= n_dcs - 1 ):
181- self .n_pcs = n_pcs
182- self .n_dcs = n_dcs
184+ # make sure enough DCs are there
185+ and adata .smp ['X_diffmap' ].shape [1 ] >= n_dcs - 1
186+ # make sure that it's sparse
187+ and issparse (adata .add ['Ktilde' ]) == knn
188+ # make sure n_neighbors matches
189+ and k == adata .add ['distance' ][0 ].nonzero ()[0 ].size + 1 ):
183190 self .init_iroot_directly (adata )
184191 self .X = adata .X # this is a hack, PCA?
185192 self .knn = issparse (adata .add ['Ktilde' ])
@@ -188,7 +195,7 @@ def __init__(self,
188195 if self .knn :
189196 self .k = adata .add ['distance' ][0 ].nonzero ()[0 ].size + 1
190197 else :
191- self .k = adata . X . shape [ 0 ]
198+ self .k = None # currently do not store this, is unknown
192199 # for output of spectrum
193200 self .X_diffmap = adata .smp ['X_diffmap' ][:, :n_dcs - 1 ]
194201 self .evals = np .r_ [1 , adata .add ['diffmap_evals' ][:n_dcs - 1 ]]
@@ -205,7 +212,7 @@ def __init__(self,
205212 # recompute the graph
206213 else :
207214 self .k = k if k is not None else 30
208- logg .info ('compute data graph with ` n_neighbors={}` '
215+ logg .info (' computing data graph with n_neighbors = {} '
209216 .format (self .k ))
210217 self .evals = None
211218 self .rbasis = None
@@ -214,13 +221,8 @@ def __init__(self,
214221 self .Dsq = None
215222 self .knn = knn
216223 self .n_jobs = sett .n_jobs if n_jobs is None else n_jobs
217- self .n_pcs = n_pcs
218- self .n_dcs = n_dcs
219- self .flavor = flavor # this is to experiment around
220- self .iroot = None
221224 self .X = adata .X # might be overwritten with X_pca below
222225 self .Dchosen = None
223- self .M = None
224226 self .init_iroot_and_X_from_PCA (adata , recompute_pca , n_pcs )
225227 if False : # TODO
226228 # in case we already computed distance relations
@@ -233,16 +235,15 @@ def __init__(self,
233235 self .Dsq = adata .add ['distance' ]
234236
235237 def init_iroot_directly (self , adata ):
238+ self .iroot = None
236239 if 'iroot' in adata .add :
237240 if adata .add ['iroot' ] >= adata .n_smps :
238241 logg .warn ('Root cell index {} does not exist for {} samples. '
239242 'Is ignored.'
240243 .format (adata .add ['iroot' ], adata .n_smps ))
241- self .iroot = None
242244 else :
243245 self .iroot = adata .add ['iroot' ]
244-
245-
246+
246247 def init_iroot_and_X_from_PCA (self , adata , recompute_pca , n_pcs ):
247248 # retrieve xroot
248249 xroot = None
@@ -281,7 +282,7 @@ def update_diffmap(self, n_comps=None):
281282 self .n_dcs = n_comps
282283 logg .info (' updating number of DCs to' , self .n_dcs )
283284 if self .evals is None or self .evals .size < self .n_dcs :
284- logg .info ('computing spectral decomposition ("diffmap") with' ,
285+ logg .info (' computing spectral decomposition ("diffmap") with' ,
285286 self .n_dcs , 'components' , r = True )
286287 self .compute_transition_matrix ()
287288 self .embed (n_evals = self .n_dcs )
0 commit comments