Title: | ggplot2 Bindings for Seurat Objects |
---|---|
Description: | Provides methods to allow Seurat objects to be utilized directly in the ggplot2 ecosystem. |
Authors: | Paul Hoffman [aut, cre] |
Maintainer: | Paul Hoffman <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.0.9002 |
Built: | 2024-11-10 03:14:43 UTC |
Source: | https://github.com/mojaveazure/ggseurat |
Provides methods to allow Seurat objects to be utilized directly in the ggplot2 ecosystem.
Maintainer: Paul Hoffman [email protected] (ORCID)
Useful links:
Report bugs at https://github.com/mojaveazure/ggseurat/issues
ggplot
ObjectsGenerate a geom_violin
layer to add to
existing ggplot
objects. The new plot data and aesthetics are stored
at the geom
level
## S3 method for class 'Assay' autolayer( object, data = missing_arg(), features = NULL, layer = c("data", "scale.data", "counts"), na.rm = TRUE, show.legend = NA, ... )
## S3 method for class 'Assay' autolayer( object, data = missing_arg(), features = NULL, layer = c("data", "scale.data", "counts"), na.rm = TRUE, show.legend = NA, ... )
object |
An |
data |
A |
features |
A vector of features to include in the fortified data; defaults to the variable features |
layer |
Name of layer to pull expression data for |
na.rm |
Remove values with |
show.legend |
logical. Should this layer be included in the legends?
|
... |
Arguments passed to |
The following aesthetics are mapped automatically and overwrite said aesthetics at the plot level if set:
“x
”
“y
”
“fill
”
A geom_violin
layer to add to
ggplot
objects
ggplot2::autolayer()
,
ggplot2::geom_violin()
Visualize Assay Expression Data:
autoplot.Assay()
,
fortify.Assay()
data("pbmc_small") rna <- pbmc_small[["RNA"]] md <- FetchData(pbmc_small, vars = "ident") # Generate a plot using `autolayer()`
data("pbmc_small") rna <- pbmc_small[["RNA"]] md <- FetchData(pbmc_small, vars = "ident") # Generate a plot using `autolayer()`
ggplot
ObjectsGenerate a geom_point
layer to add to
existing ggplot
objects. The new plot data and aesthetics are stored
at the geom
level
## S3 method for class 'DimReduc' autolayer( object, data = missing_arg(), dims = c(1L, 2L), na.rm = TRUE, show.legend = NA, ... )
## S3 method for class 'DimReduc' autolayer( object, data = missing_arg(), dims = c(1L, 2L), na.rm = TRUE, show.legend = NA, ... )
object |
A |
data |
A |
dims |
Dimensions for visualization |
na.rm |
Remove values with |
show.legend |
logical. Should this layer be included in the legends?
|
... |
Arguments passed to |
The following aesthetics are mapped automatically and overwrite said aesthetics at the plot level if set:
“x
”
“y
”
“color
”
A geom_point
layer to add to
ggplot
objects
ggplot2::autolayer()
,
ggplot2::geom_point()
Visualize Dimensional Reductions:
autoplot.DimReduc()
,
fortify.DimReduc()
data("pbmc_small") tsne <- pbmc_small[["tsne"]] md <- FetchData(pbmc_small, vars = c("ident", "MS4A1")) # Generate a plot using `autolayer()` ggplot() + autolayer(tsne) ggplot() + autolayer(tsne, data = md)
data("pbmc_small") tsne <- pbmc_small[["tsne"]] md <- FetchData(pbmc_small, vars = c("ident", "MS4A1")) # Generate a plot using `autolayer()` ggplot() + autolayer(tsne) ggplot() + autolayer(tsne, data = md)
Assay
ObjectsGenerate a ggplot
plot for
Assay
objects
## S3 method for class 'Assay' autoplot( object, data = missing_arg(), features = NULL, layer = c("data", "scale.data", "counts"), na.rm = TRUE, show.legend = NA, ... )
## S3 method for class 'Assay' autoplot( object, data = missing_arg(), features = NULL, layer = c("data", "scale.data", "counts"), na.rm = TRUE, show.legend = NA, ... )
object |
An |
data |
A |
features |
A vector of features to include in the fortified data; defaults to the variable features |
layer |
Name of layer to pull expression data for |
na.rm |
Remove values with |
show.legend |
logical. Should this layer be included in the legends?
|
... |
Arguments passed to |
The following aesthetics are mapped automatically:
“x
”
“y
”
“fill
”
A ggplot
object
Visualize Assay Expression Data:
autolayer.Assay()
,
fortify.Assay()
data("pbmc_small") rna <- pbmc_small[["RNA"]] md <- FetchData(pbmc_small, vars = "ident") # Generate a plot using `autoplot()`
data("pbmc_small") rna <- pbmc_small[["RNA"]] md <- FetchData(pbmc_small, vars = "ident") # Generate a plot using `autoplot()`
DimReduc
ObjectsGenerate a ggplot
plot for
DimReduc
objects
## S3 method for class 'DimReduc' autoplot( object, data = missing_arg(), dims = c(1L, 2L), na.rm = TRUE, show.legend = NA, ... )
## S3 method for class 'DimReduc' autoplot( object, data = missing_arg(), dims = c(1L, 2L), na.rm = TRUE, show.legend = NA, ... )
object |
A |
data |
A |
dims |
Dimensions for visualization |
na.rm |
Remove values with |
show.legend |
logical. Should this layer be included in the legends?
|
... |
Arguments passed to |
The following aesthetics are mapped automatically:
“x
”
“y
”
“color
”
A ggplot
object
Visualize Dimensional Reductions:
autolayer.DimReduc()
,
fortify.DimReduc()
data("pbmc_small") tsne <- pbmc_small[["tsne"]] md <- FetchData(pbmc_small, vars = c("ident", "MS4A1")) # Generate a plot using `autoplot()` autoplot(tsne) autoplot(tsne, data = md)
data("pbmc_small") tsne <- pbmc_small[["tsne"]] md <- FetchData(pbmc_small, vars = c("ident", "MS4A1")) # Generate a plot using `autoplot()` autoplot(tsne) autoplot(tsne, data = md)
ggplot()
Generate a long-format data frame for ease of use with
ggplot()
; as a bonus, this method enables direct
calling of Assay
objects in
ggplot()
(see examples)
## S3 method for class 'Assay' fortify( model, data, features = NULL, layer = c("data", "scale.data", "counts"), na.rm = FALSE, ... )
## S3 method for class 'Assay' fortify( model, data, features = NULL, layer = c("data", "scale.data", "counts"), na.rm = FALSE, ... )
model |
An |
data |
A |
features |
A vector of features to include in the fortified data; defaults to the variable features |
layer |
Name of layer to pull expression data for |
na.rm |
Remove values with |
... |
Ignored |
fortify.Assay()
generates a data frame based on the
expression data stored in layer
; automatically creates a column for
cell names (“cell
”). Also creates creates a column for
identity classes (“ident
”) if not present in data
; the
default identity class is
“SeuratProject
”; final column output
order is:
“cell
”
“ident
”
expression data for features
additional meta data provided by data
A long-format data frame for use with ggplot()
ggplot2::ggplot()
,
ggplot2::fortify()
Visualize Assay Expression Data:
autolayer.Assay()
,
autoplot.Assay()
data("pbmc_small") rna <- pbmc_small[["RNA"]] md <- FetchData(pbmc_small, vars = "ident") # Create a data frame for `ggplot()` df <- fortify(rna, data = md) head(df) ggplot(df, mapping = aes(x = ident, y = PPBP, fill = ident)) + geom_violin() # Use an `Assay` directly in `ggplot()` ggplot(rna, mapping = aes(x = ident, y = GNLY, fill = ident), md) + geom_violin()
data("pbmc_small") rna <- pbmc_small[["RNA"]] md <- FetchData(pbmc_small, vars = "ident") # Create a data frame for `ggplot()` df <- fortify(rna, data = md) head(df) ggplot(df, mapping = aes(x = ident, y = PPBP, fill = ident)) + geom_violin() # Use an `Assay` directly in `ggplot()` ggplot(rna, mapping = aes(x = ident, y = GNLY, fill = ident), md) + geom_violin()
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, ...)
## 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
“SeuratProject
”; 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()
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()
ggplot_build.Seurat
## S3 method for class 'ggseurat' ggplot_build(plot)
## S3 method for class 'ggseurat' ggplot_build(plot)
plot |
ggplot object |
A built ggplot ready for viewing
Visualize Seurat objects
## S3 method for class 'Seurat' ggplot(data = NULL, mapping = aes(), ..., environment = parent.frame())
## S3 method for class 'Seurat' ggplot(data = NULL, mapping = aes(), ..., environment = parent.frame())
data |
A |
mapping |
Default list of aesthetic mappings to use for plot. If not specified, must be supplied in each layer added to the plot. |
... |
Other arguments passed on to methods. Not currently used. |
environment |
DEPRECATED. Used prior to tidy evaluation. |
A ggplot object