You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title={Comprehensive integration of single-cell data},
238
+
author={Stuart, Tim and Butler, Andrew and Hoffman, Paul and Hafemeister, Christoph and Papalexi, Efthymia and Mauck III, William M and Hao, Yuhan and Stoeckius, Marlon and Smibert, Peter and Satija, Rahul},
Compute nearest neighbors between reference and query datasets.
193
152
153
+
The method computes k-nearest neighbor graphs to enable mapping between
154
+
datasets. If no representation is provided (`use_rep=None`), a fallback
155
+
representation will be computed automatically using either fast CCA
156
+
,inspired by Seurat v3 :cite:`stuart2019comprehensive`), or joint PCA. In self-mapping mode,
157
+
a simple PCA will be computed on the query dataset.
158
+
194
159
Parameters
195
160
----------
196
161
n_neighbors
197
162
Number of nearest neighbors.
198
163
use_rep
199
-
Data representation based on which to find nearest neighbors. If None, a joint PCA will be computed.
164
+
Data representation based on which to find nearest neighbors. If None,
165
+
a fallback representation will be computed automatically.
166
+
n_comps
167
+
Number of components to use. If a pre-computed representation is provided via `use_rep`,
168
+
we will use the number of components from that representation. Otherwiese, if `use_rep=None`,
169
+
we will compute the given number of components using the fallback representation method.
200
170
method
201
-
Method to use for computing neighbors. "sklearn" and "pynndescent" run on CPU, "rapids" and "faiss" run on GPU. Note that all but "pynndescent" perform exact neighbor search. With GPU acceleration, "faiss" is usually fastest and more memory efficient than "rapids".
202
-
All methods return exactly `n_neighbors` neighbors, including the reference cell itself (in self-mapping mode). For faiss and sklearn, distances to self are very small positive numbers, for rapids and sklearn, they are exactly 0.
171
+
Method to use for computing neighbors. "sklearn" and "pynndescent" run on CPU,
172
+
"rapids" and "faiss" run on GPU. Note that all but "pynndescent" perform exact
173
+
neighbor search. With GPU acceleration, "faiss" is usually fastest and more
174
+
memory efficient than "rapids". All methods return exactly `n_neighbors` neighbors,
175
+
including the reference cell itself (in self-mapping mode). For faiss and sklearn,
176
+
distances to self are very small positive numbers, for rapids and sklearn, they are exactly 0.
203
177
metric
204
178
Distance metric to use for nearest neighbors.
205
179
only_yx
206
-
If True, only compute the xy neighbors. This is faster, but not suitable for Jaccard or HNOCA methods.
207
-
joint_pca_key
208
-
Key under which to store the joint PCA embeddings if use_rep is None.
209
-
n_pca_components
210
-
Number of principal components to compute for joint PCA if use_rep is None.
211
-
pca_kwargs
212
-
Additional keyword arguments to pass to scanpy's `pp.pca` function if use_rep is None.
180
+
If True, only compute the xy neighbors. This is faster, but not suitable for
181
+
Jaccard or HNOCA methods.
182
+
fallback_representation
183
+
Method to use for computing a cross-dataset representation when `use_rep=None`. Options:
184
+
185
+
- "fast_cca": Fast canonical correlation analysis, inspired by Seurat v3 :cite:`stuart2019comprehensive` and
186
+
SLAT :cite:`xia2023spatial`).
187
+
- "joint_pca": Principal component analysis on concatenated datasets.
188
+
fallback_kwargs
189
+
Additional keyword arguments to pass to the fallback representation method.
190
+
For "fast_cca": see :meth:`~cellmapper.EmbeddingMixin.compute_fast_cca`.
191
+
For "joint_pca": see :meth:`~cellmapper.EmbeddingMixin.compute_joint_pca`.
213
192
214
193
Returns
215
194
-------
@@ -223,22 +202,50 @@ def compute_neighbors(
223
202
- ``n_neighbors``: Number of nearest neighbors.
224
203
- ``only_yx``: Whether only yx neighbors were computed.
225
204
"""
205
+
# Handle backward compatibility parameters
206
+
iffallback_kwargsisNone:
207
+
fallback_kwargs= {}
208
+
226
209
self.only_yx=only_yx
210
+
227
211
ifuse_repisNone:
228
-
ifpca_kwargsisNone:
229
-
pca_kwargs= {}
212
+
logger.warning(
213
+
"No representation provided (`use_rep=None`). Computing a joint representation automatically "
214
+
"using '%s'. For optimal results, consider pre-computing a representation and passing it to `use_rep`.",
0 commit comments