@@ -26,11 +26,11 @@ class Distance:
2626
2727 Parameters
2828 ----------
29- metric : str
29+ metric
3030 Distance metric. Currently supported: 'edistance' (energy distance).
31- layer_key : str | None
31+ layer_key
3232 Key in adata.layers for cell data. Mutually exclusive with 'obsm_key'.
33- obsm_key : str | None
33+ obsm_key
3434 Key in adata.obsm for embeddings. Mutually exclusive with 'layer_key'.
3535 Defaults to 'X_pca' if neither is specified.
3636
@@ -51,12 +51,12 @@ def __init__(
5151 obsm_key : str | None = None ,
5252 ):
5353 """Initialize Distance calculator with specified metric."""
54- if layer_key and obsm_key :
54+ if layer_key is not None and obsm_key is not None :
5555 raise ValueError (
5656 "Cannot use 'layer_key' and 'obsm_key' at the same time.\n "
5757 "Please provide only one of the two keys."
5858 )
59- if not layer_key and not obsm_key :
59+ if layer_key is None and obsm_key is None :
6060 obsm_key = "X_pca"
6161
6262 self .metric = metric
@@ -93,14 +93,14 @@ def __call__(
9393
9494 Parameters
9595 ----------
96- X : np.ndarray | cp.ndarray
96+ X
9797 First array of shape (n_samples_x, n_features)
98- Y : np.ndarray | cp.ndarray
98+ Y
9999 Second array of shape (n_samples_y, n_features)
100100
101101 Returns
102102 -------
103- distance : float
103+ float
104104 Distance between X and Y
105105
106106 Examples
@@ -131,17 +131,17 @@ def pairwise(
131131
132132 Parameters
133133 ----------
134- adata : AnnData
134+ adata
135135 Annotated data matrix
136- groupby : str
136+ groupby
137137 Key in adata.obs for grouping cells
138- groups : Sequence[str] | None
138+ groups
139139 Specific groups to compute (if None, use all)
140- bootstrap : bool
140+ bootstrap
141141 Whether to compute bootstrap variance estimates
142- n_bootstrap : int
142+ n_bootstrap
143143 Number of bootstrap iterations (if bootstrap=True)
144- random_state : int
144+ random_state
145145 Random seed for reproducibility
146146
147147 Returns
@@ -180,24 +180,24 @@ def onesided_distances(
180180
181181 Parameters
182182 ----------
183- adata : AnnData
183+ adata
184184 Annotated data matrix
185- groupby : str
185+ groupby
186186 Key in adata.obs for grouping cells
187- selected_group : str
187+ selected_group
188188 Reference group to compute distances from
189- groups : Sequence[str] | None
189+ groups
190190 Specific groups to compute distances to (if None, use all)
191- bootstrap : bool
191+ bootstrap
192192 Whether to compute bootstrap variance estimates
193- n_bootstrap : int
193+ n_bootstrap
194194 Number of bootstrap iterations (if bootstrap=True)
195- random_state : int
195+ random_state
196196 Random seed for reproducibility
197197
198198 Returns
199199 -------
200- distances : pd.Series | tuple[pd.Series, pd.Series]
200+ distances
201201 Series containing distances from selected_group to all other groups.
202202 If bootstrap=True, returns tuple of (distances, distances_var).
203203
@@ -238,18 +238,18 @@ def bootstrap(
238238
239239 Parameters
240240 ----------
241- X : np.ndarray | cp.ndarray
241+ X
242242 First array of shape (n_samples_x, n_features)
243- Y : np.ndarray | cp.ndarray
243+ Y
244244 Second array of shape (n_samples_y, n_features)
245- n_bootstrap : int
245+ n_bootstrap
246246 Number of bootstrap iterations
247- random_state : int
247+ random_state
248248 Random seed for reproducibility
249249
250250 Returns
251251 -------
252- result : MeanVar
252+ result
253253 Named tuple containing mean and variance of bootstrapped distances
254254
255255 Examples
@@ -287,22 +287,22 @@ def bootstrap_adata(
287287
288288 Parameters
289289 ----------
290- adata : AnnData
290+ adata
291291 Annotated data matrix
292- groupby : str
292+ groupby
293293 Key in adata.obs for grouping cells
294- group_a : str
294+ group_a
295295 First group name
296- group_b : str
296+ group_b
297297 Second group name
298- n_bootstrap : int
298+ n_bootstrap
299299 Number of bootstrap iterations
300- random_state : int
300+ random_state
301301 Random seed for reproducibility
302302
303303 Returns
304304 -------
305- result : MeanVar
305+ result
306306 Named tuple containing mean and variance of bootstrapped distances
307307
308308 Examples
0 commit comments