cellrank icon indicating copy to clipboard operation
cellrank copied to clipboard

Throw error in `RealtimeKernel` if `self_transitions="all"` but `conn_weight` not provided

Open WeilerP opened this issue 2 years ago • 0 comments

Description

Computing the transition matrix with the RealtimeKernel with self_transitions="all" but not providing a weight for the connectivities, i.e., not passing conn_weight, results in the error

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/var/folders/7p/j67nx0vs6j968c2w2d9pqmzryt4ryq/T/ipykernel_81111/2610910967.py in <module>
----> 1 wk.compute_transition_matrix(
      2     growth_iters=3, growth_rate_key="growth_rate_init", self_transitions="all"  #, conn_weight=0.1
      3 )

~/code/cellrank/cellrank/external/kernels/_wot_kernel.py in compute_transition_matrix(self, cost_matrices, lambda1, lambda2, epsilon, growth_iters, solver, growth_rate_key, use_highly_variable, threshold, self_transitions, conn_weight, conn_kwargs, **kwargs)
    370             self._threshold_transport_maps(self._tmaps, threshold=threshold, copy=False)
    371 
--> 372         tmap = self._restich_tmaps(
    373             self._tmaps,
    374             self_transitions=self_transitions,

~/code/cellrank/cellrank/tl/kernels/_transport_map_kernel.py in _restich_tmaps(self, tmaps, self_transitions, conn_weight, conn_kwargs)
    272                 settings.verbosity = 0
    273                 if conn_weight is None or not (0 < conn_weight < 1):
--> 274                     raise ValueError(
    275                         "Please specify `conn_weight` in interval `(0, 1)`."
    276                     )

ValueError: Please specify `conn_weight` in interval `(0, 1)`.

The error is thrown after the transport maps have been calculated. I think it'd be good to check if both are provided (if needed) before calculating the transport maps. Otherwise, everything will have to be recomputed.

WeilerP avatar May 26 '22 18:05 WeilerP