fortify.DimReduc | R Documentation |
ggplot()
Generate a long-format data frame for ease of use with
ggplot()
; as a bonus, this method enables direct
calling of DimReduc
objects in
ggplot()
(see examples)
## S3 method for class 'DimReduc'
fortify(model, data, na.rm = FALSE, ...)
model |
A |
data |
A |
na.rm |
Remove values with |
... |
Ignored |
fortify.DimReduc()
generates a data frame based on the
cell embeddings. Automatically creates a
column for cell names (“cell
”). Also creates a column for
identity classes (“ident
”) if not present in data
; the
default identity class is
\Sexpr[stage=render, results=rd]{ggseurat::.rd_ident()}; final column output
order is:
“cell
”
“ident
”
cell embeddings
additional meta data provided by data
A long-format data frame for use with ggplot()
ggplot2::ggplot()
,
ggplot2::fortify()
Visualize Dimensional Reductions:
autolayer.DimReduc()
,
autoplot.DimReduc()
data("pbmc_small")
tsne <- pbmc_small[["tsne"]]
md <- FetchData(pbmc_small, vars = c("ident", "MS4A1"))
# Create a data frame for `ggplot()`
df <- fortify(tsne, data = md)
head(df)
ggplot(df, mapping = aes(x = tSNE_1, y = tSNE_2, color = ident)) +
geom_point()
# Use a `DimReduc` directly in `ggplot()`
ggplot(tsne, mapping = aes(x = tSNE_1, y = tSNE_2, color = MS4A1), md) +
geom_point()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.