-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathfrom_Seurat.Rd
226 lines (162 loc) · 8.33 KB
/
from_Seurat.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Seurat.R
\name{from_Seurat}
\alias{from_Seurat}
\title{Convert a Seurat object to an AnnData object}
\usage{
from_Seurat(
seurat_obj,
output_class = c("InMemoryAnnData", "HDF5AnnData"),
assay_name = NULL,
x_mapping = NULL,
layers_mapping = NULL,
obs_mapping = NULL,
var_mapping = NULL,
obsm_mapping = NULL,
varm_mapping = NULL,
obsp_mapping = NULL,
varp_mapping = NULL,
uns_mapping = NULL,
...
)
}
\arguments{
\item{seurat_obj}{A Seurat object to be converted.}
\item{output_class}{Name of the AnnData class. Must be one of \code{"HDF5AnnData"} or \code{"InMemoryAnnData"}.}
\item{assay_name}{The name of the assay to be converted. If \code{NULL}, the default assay will be used
(\code{\link[SeuratObject:DefaultAssay]{SeuratObject::DefaultAssay()}}).}
\item{x_mapping}{A mapping of a Seurat layer to the AnnData \code{X} slot. If \code{NULL}, no data will be copied to the
\code{X} slot.}
\item{layers_mapping}{A named vector mapping layer names in AnnData to the names of the layers in the Seurat object.
Each name corresponds to the layer name in AnnData, and each value to the layer name in Seurat.
See section "\verb{$layers} mapping" for more details.}
\item{obs_mapping}{A named vector or list mapping obs names in AnnData to the names of the object-level (cell level)
metadata in the Seurat object. Each name corresponds to a column name in AnnData's obs, and each value to a column
name in Seurat's cell metadata. See section "\verb{$obs} mapping" for more details.}
\item{var_mapping}{A named vector or list mapping var names in AnnData to the names of the feature-level metadata in
the Seurat object. Each name corresponds to a column name in AnnData's var, and each value to a column name in
Seurat's feature metadata. See section "\verb{$var} mapping" for more details.}
\item{obsm_mapping}{A named vector mapping obsm keys in AnnData to reduction names in the Seurat object.
Each name corresponds to a key in AnnData's obsm, and each value to the name of a reduction in Seurat.
Example: \code{obsm_mapping = c(X_pca = "pca", X_umap = "umap")}.}
\item{varm_mapping}{A named vector mapping varm keys in AnnData to reduction names in the Seurat object.
Each name corresponds to a key in AnnData's varm, and each value to the name of a reduction in Seurat.
Example: \code{varm_mapping = c(PCs = "pca")}.}
\item{obsp_mapping}{A named vector mapping obsp keys in AnnData to graph names in the Seurat object.
Each name corresponds to a key in AnnData's obsp, and each value to the name of a graph in Seurat.
Example: \code{obsp_mapping = c(connectivities = "RNA_nn")}.}
\item{varp_mapping}{A named vector mapping varp keys in AnnData to misc data names in the Seurat object.
Each name corresponds to a key in AnnData's varp, and each value to the name of misc data in Seurat.
Example: \code{varp_mapping = c(foo = "foo_data")}.}
\item{uns_mapping}{A named vector mapping uns keys in AnnData to misc data names in the Seurat object.
Each name corresponds to a key in AnnData's uns, and each value to the name of misc data in Seurat.
Example: \code{uns_mapping = c(metadata = "project_meta")}.}
\item{...}{Additional arguments passed to the generator function.}
}
\value{
An AnnData object
}
\description{
\code{from_Seurat()} converts a Seurat object to an AnnData object.
Only one assay can be converted at a time. Arguments are used to configure the conversion.
If \code{NULL}, the functions \verb{.from_Seurat_guess_*} will be used to guess the mapping.
}
\details{
For more information on the functionality of an AnnData object, see \link{anndataR-package}.
}
\section{\verb{$X} mapping}{
A mapping of a Seurat layer to the AnnData \code{X} slot. Its value must be \code{NULL} or a character vector of the Seurat
layer name to copy. If \code{NULL}, no data will be copied to the \code{X} slot.
}
\section{\verb{$layers} mapping}{
A named list to map AnnData layers to Seurat layers. Each item in the list must be a character vector of length 1.
The \verb{$X} key maps to the \code{X} slot.
Example: \code{layers_mapping = c(counts = "counts", foo = "bar")}.
If \code{NULL}, the internal function \code{.from_Seurat_guess_layers} will be used to guess the layer mapping as follows:
\itemize{
\item All Seurat layers are copied to AnnData \code{layers} by name.
\item This means that the AnnData \code{X} slot will be \code{NULL} (empty). If you want to copy data to the \code{X} slot,
you must define the layer mapping explicitly.
}
}
\section{\verb{$obs} mapping}{
A named list or vector to map Seurat object-level metadata to AnnData \verb{$obs}. The values of this list or vector
correspond to the names of the metadata in the Seurat object, and the names correspond to the names of the
metadata in the resulting \verb{$obs} slot.
Example: \code{obs_mapping = c(cellType = "cell_type")}.
If \code{NULL}, the internal function \code{.from_Seurat_guess_obs} will be used to guess the obs mapping as follows:
\itemize{
\item All Seurat object-level metadata is copied to AnnData \verb{$obs} by name.
}
}
\section{\verb{$var} mapping}{
A named list or vector to map Seurat feature-level metadata to AnnData \verb{$var}. The values of this list or
vector correspond to the names of the metadata of the assay in the Seurat object, and the
names correspond to the names of the metadata in the resulting \verb{$var} slot.
Example: \code{var_mapping = c(geneInfo = "gene_info")}.
If \code{NULL}, the internal function \code{.from_Seurat_guess_vars} will be used to guess the var mapping as follows:
\itemize{
\item All Seurat feature-level metadata is copied to AnnData \verb{$var} by name.
}
}
\section{\verb{$obsm} mapping}{
A named vector mapping obsm keys in AnnData to reduction names in the Seurat object.
Each name corresponds to a key in AnnData's obsm, and each value to the name of a reduction in Seurat.
Example: \code{obsm_mapping = c(pca = "pca", umap = "umap")}.
If \code{NULL}, the internal function \code{.from_Seurat_guess_obsms} will be used to guess the obsm mapping as follows:
\itemize{
\item All Seurat reductions are copied to AnnData \verb{$obsm}.
}
}
\section{\verb{$varm} mapping}{
A named vector mapping varm keys in AnnData to reduction names in the Seurat object.
Each name corresponds to a key in AnnData's varm, and each value to the name of a reduction in Seurat.
Example: \code{varm_mapping = c(PCs = "pca")}.
If \code{NULL}, the internal function \code{.from_Seurat_guess_varms} will be used to guess the varm mapping as follows:
\itemize{
\item The name of the PCA loadings is copied by name.
}
}
\section{\verb{$obsp} mapping}{
A named vector mapping obsp keys in AnnData to graph names in the Seurat object.
Each name corresponds to a key in AnnData's obsp, and each value to the name of a graph in Seurat.
Example: \code{obsp_mapping = c(connectivities = "RNA_nn")}.
If \code{NULL}, the internal function \code{.from_Seurat_guess_obsps} will be used to guess the obsp mapping as follows:
\itemize{
\item All Seurat graphs are copied to \verb{$obsp} by name.
}
}
\section{\verb{$varp} mapping}{
A named vector mapping varp keys in AnnData to misc data names in the Seurat object.
Each name corresponds to a key in AnnData's varp, and each value to the name of misc data in Seurat.
Example: \code{varp_mapping = c(foo = "foo_data")}.
If \code{NULL}, the internal function \code{.from_Seurat_guess_varps} will be used to guess the varp mapping as follows:
\itemize{
\item No data is mapped to \verb{$varp}.
}
}
\section{\verb{$uns} mapping}{
A named vector mapping uns keys in AnnData to misc data names in the Seurat object.
Each name corresponds to a key in AnnData's uns, and each value to the name of misc data in Seurat.
Example: \code{uns_mapping = c(metadata = "project_meta")}.
If \code{NULL}, the internal function \code{.from_Seurat_guess_uns} will be used to guess the uns mapping as follows:
\itemize{
\item All Seurat miscellaneous data is copied to \code{uns} by name.
}
}
\section{Mapping details}{
If an unnamed vector is provided to a mapping argument the values will be
used as names
}
\examples{
library(Seurat)
counts <- matrix(rbinom(20000, 1000, .001), nrow = 100)
obj <- CreateSeuratObject(counts = counts)
obj <- NormalizeData(obj)
obj <- FindVariableFeatures(obj)
obj <- ScaleData(obj)
obj <- RunPCA(obj, npcs = 10L)
obj <- FindNeighbors(obj)
obj <- RunUMAP(obj, dims = 1:10)
from_Seurat(obj)
}