RunBBKNN | R Documentation |
Batch balanced KNN, altering the KNN procedure to identify each cell’s top neighbours in each batch separately instead of the entire cell pool with no accounting for batch. The nearest neighbours for each batch are then merged to create a final list of neighbours for the cell. Aligns batches in a quick and lightweight manner.
RunBBKNN(object, ...)
## S3 method for class 'matrix'
RunBBKNN(
object,
batch_list,
neighbors_within_batch = 3,
n_pcs = 50,
method = c("annoy", "nndescent"),
metric = "euclidean",
n_trees = 10L,
k_build_nndescent = 30,
trim = NULL,
set_op_mix_ratio = 1,
local_connectivity = 1,
seed = 42,
verbose = TRUE,
...
)
## S3 method for class 'Seurat'
RunBBKNN(
object,
batch_key,
assay = NULL,
reduction = "pca",
n_pcs = 50L,
graph_name = "bbknn",
set_op_mix_ratio = 1,
local_connectivity = 1,
run_TSNE = TRUE,
TSNE_name = "tsne",
TSNE_key = "tSNE_",
run_UMAP = TRUE,
UMAP_name = "umap",
UMAP_key = "UMAP_",
return.umap.model = FALSE,
min_dist = 0.3,
spread = 1,
seed = 42,
verbose = TRUE,
...
)
object |
An object |
... |
Arguments passed to other methods |
batch_list |
A character vector with the same length as nrow(pca) |
neighbors_within_batch |
How many top neighbours to report for each batch; total number of neighbours in the initial k-nearest-neighbours computation will be this number times the number of batches. This then serves as the basis for the construction of a symmetrical matrix of connectivities. |
n_pcs |
Number of dimensions to use. Default is 50. |
method |
Method to find k nearest neighbors (kNNs). One of "annoy" and "nndescent". |
metric |
Metric to calculate the distances. The options depend on the
choice of kNN
The following metrics are only supported in
|
n_trees |
The number of trees to use in the random projection forest. More trees give higher precision when querying, at the cost of increased run time and resource intensity. |
k_build_nndescent |
Used with nndescent neighbour identification. The number of neighbours to include when building the approximate nearest neighbors index and neighbor graph. More neighbours give higher precision when querying, at the cost of increased run time and resource intensity. |
trim |
Trim the neighbours of each cell to these many top connectivities. May help with population independence and improve the tidiness of clustering. The lower the value the more independent the individual populations, at the cost of more conserved batch effect. Default is 10 times neighbors_within_batch times the number of batches. Set to 0 to skip. |
set_op_mix_ratio |
Pass to 'set_op_mix_ratio' parameter for
|
local_connectivity |
Pass to 'local_connectivity' parameter for
|
seed |
Set a random seed. By default, sets the seed to 42. Setting
|
verbose |
Whether or not to print output to the console |
batch_key |
Column name in meta.data discriminating between your batches. |
assay |
Used to construct Graph. |
reduction |
Which dimensional reduction to use for the BBKNN input. Default is PCA |
graph_name |
Name of the generated BBKNN graph. Default is "bbknn". |
run_TSNE |
Whether or not to run t-SNE based on BBKNN results. |
TSNE_name |
Name to store t-SNE dimensional reduction. |
TSNE_key |
Specifies the string before the number of the t-SNE dimension names. tSNE by default. |
run_UMAP |
Whether or not to run UMAP based on BBKNN results. |
UMAP_name |
Name to store UMAP dimensional reduction. |
UMAP_key |
Specifies the string before the number of the UMAP dimension names. tSNE by default. |
return.umap.model |
Whether UMAP will return the uwot model. |
min_dist |
Pass to 'min_dist' parameter for |
spread |
Pass to 'spread' parameter for |
Returns a Seurat object containing a new BBKNN Graph and Neighbor data. If run t-SNE or UMAP, will also return corresponded reduction objects.
Polański, Krzysztof, et al. "BBKNN: fast batch alignment of single cell transcriptomes." Bioinformatics 36.3 (2020): 964-965.
data("panc8_small")
panc8_small <- RunBBKNN(panc8_small, "tech")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.