forked from satijalab/seurat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindNeighbors.Rd
182 lines (153 loc) · 5.1 KB
/
FindNeighbors.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/generics.R, R/clustering.R
\name{FindNeighbors}
\alias{FindNeighbors}
\alias{FindNeighbors.default}
\alias{FindNeighbors.Assay}
\alias{FindNeighbors.dist}
\alias{FindNeighbors.Seurat}
\title{(Shared) Nearest-neighbor graph construction}
\usage{
FindNeighbors(object, ...)
\method{FindNeighbors}{default}(
object,
query = NULL,
distance.matrix = FALSE,
k.param = 20,
return.neighbor = FALSE,
compute.SNN = !return.neighbor,
prune.SNN = 1/15,
nn.method = "annoy",
n.trees = 50,
annoy.metric = "euclidean",
nn.eps = 0,
verbose = TRUE,
force.recalc = FALSE,
l2.norm = FALSE,
cache.index = FALSE,
index = NULL,
...
)
\method{FindNeighbors}{Assay}(
object,
features = NULL,
k.param = 20,
return.neighbor = FALSE,
compute.SNN = !return.neighbor,
prune.SNN = 1/15,
nn.method = "annoy",
n.trees = 50,
annoy.metric = "euclidean",
nn.eps = 0,
verbose = TRUE,
force.recalc = FALSE,
l2.norm = FALSE,
cache.index = FALSE,
...
)
\method{FindNeighbors}{dist}(
object,
k.param = 20,
return.neighbor = FALSE,
compute.SNN = !return.neighbor,
prune.SNN = 1/15,
nn.method = "annoy",
n.trees = 50,
annoy.metric = "euclidean",
nn.eps = 0,
verbose = TRUE,
force.recalc = FALSE,
l2.norm = FALSE,
cache.index = FALSE,
...
)
\method{FindNeighbors}{Seurat}(
object,
reduction = "pca",
dims = 1:10,
assay = NULL,
features = NULL,
k.param = 20,
return.neighbor = FALSE,
compute.SNN = !return.neighbor,
prune.SNN = 1/15,
nn.method = "annoy",
n.trees = 50,
annoy.metric = "euclidean",
nn.eps = 0,
verbose = TRUE,
force.recalc = FALSE,
do.plot = FALSE,
graph.name = NULL,
l2.norm = FALSE,
cache.index = FALSE,
...
)
}
\arguments{
\item{object}{An object}
\item{...}{Arguments passed to other methods}
\item{query}{Matrix of data to query against object. If missing, defaults to
object.}
\item{distance.matrix}{Boolean value of whether the provided matrix is a
distance matrix; note, for objects of class \code{dist}, this parameter will
be set automatically}
\item{k.param}{Defines k for the k-nearest neighbor algorithm}
\item{return.neighbor}{Return result as \code{\link{Neighbor}} object. Not
used with distance matrix input.}
\item{compute.SNN}{also compute the shared nearest neighbor graph}
\item{prune.SNN}{Sets the cutoff for acceptable Jaccard index when
computing the neighborhood overlap for the SNN construction. Any edges with
values less than or equal to this will be set to 0 and removed from the SNN
graph. Essentially sets the stringency of pruning (0 --- no pruning, 1 ---
prune everything).}
\item{nn.method}{Method for nearest neighbor finding. Options include: rann,
annoy}
\item{n.trees}{More trees gives higher precision when using annoy approximate
nearest neighbor search}
\item{annoy.metric}{Distance metric for annoy. Options include: euclidean,
cosine, manhattan, and hamming}
\item{nn.eps}{Error bound when performing nearest neighbor seach using RANN;
default of 0.0 implies exact nearest neighbor search}
\item{verbose}{Whether or not to print output to the console}
\item{force.recalc}{Force recalculation of (S)NN.}
\item{l2.norm}{Take L2Norm of the data}
\item{cache.index}{Include cached index in returned Neighbor object
(only relevant if return.neighbor = TRUE)}
\item{index}{Precomputed index. Useful if querying new data against existing
index to avoid recomputing.}
\item{features}{Features to use as input for building the (S)NN; used only when
\code{dims} is \code{NULL}}
\item{reduction}{Reduction to use as input for building the (S)NN}
\item{dims}{Dimensions of reduction to use as input}
\item{assay}{Assay to use in construction of (S)NN; used only when \code{dims}
is \code{NULL}}
\item{do.plot}{Plot SNN graph on tSNE coordinates}
\item{graph.name}{Optional naming parameter for stored (S)NN graph
(or Neighbor object, if return.neighbor = TRUE). Default is assay.name_(s)nn.}
}
\value{
This function can either return a \code{\link{Neighbor}} object
with the KNN information or a list of \code{\link{Graph}} objects with
the KNN and SNN depending on the settings of \code{return.neighbor} and
\code{compute.SNN}. When running on a \code{\link{Seurat}} object, this
returns the \code{\link{Seurat}} object with the Graphs or Neighbor objects
stored in their respective slots. Names of the Graph or Neighbor object can
be found with \code{\link{Graphs}} or \code{\link{Neighbors}}.
}
\description{
Computes the \code{k.param} nearest neighbors for a given dataset. Can also
optionally (via \code{compute.SNN}), construct a shared nearest neighbor
graph by calculating the neighborhood overlap (Jaccard index) between every
cell and its \code{k.param} nearest neighbors.
}
\examples{
data("pbmc_small")
pbmc_small
# Compute an SNN on the gene expression level
pbmc_small <- FindNeighbors(pbmc_small, features = VariableFeatures(object = pbmc_small))
# More commonly, we build the SNN on a dimensionally reduced form of the data
# such as the first 10 principle components.
pbmc_small <- FindNeighbors(pbmc_small, reduction = "pca", dims = 1:10)
}
\concept{clustering}