ggcells {scater} | R Documentation |
Create a base ggplot object from a SingleCellExperiment, the contents of which can be directly referenced in subsequent layers without prior specification.
ggcells( x, mapping = aes(), features = NULL, exprs_values = "logcounts", use_dimred = TRUE, use_altexps = FALSE, prefix_altexps = FALSE, check_names = TRUE, extract_mapping = TRUE, ... ) ggfeatures( x, mapping = aes(), cells = NULL, exprs_values = "logcounts", check_names = TRUE, extract_mapping = TRUE, ... )
x |
A SingleCellExperiment object.
This is expected to have row names for |
mapping |
A list containing aesthetic mappings, usually the output of |
features |
Character vector specifying the features for which to extract expression profiles across cells.
May also include features in alternative Experiments if permitted by |
exprs_values |
String or integer scalar indicating the assay to use to obtain expression values. Must refer to a matrix-like object with integer or numeric values. |
use_dimred |
Logical scalar indicating whether data should be extracted for dimensionality reduction results in |
use_altexps |
Logical scalar indicating whether (meta)data should be extracted for alternative experiments in |
prefix_altexps |
Logical scalar indicating whether |
check_names |
Logical scalar indicating whether the column names of the output data.frame should be made syntactically valid and unique. |
extract_mapping |
Logical scalar indicating whether |
... |
Further arguments to pass to ggplot. |
cells |
Character vector specifying the features for which to extract expression profiles across cells. |
These functions generate a data.frame from the contents of a SingleCellExperiment and pass it to ggplot
.
Rows, columns or metadata fields in the x
can then be referenced in subsequent ggplot2 commands.
ggcells
treats cells as the data values so users can reference row names of x
(if provided in features
), column metadata variables and dimensionality reduction results.
They can also reference row names and metadata variables for alternative Experiments.
ggfeatures
treats features as the data values so users can reference column names of x
(if provided in cells
) and row metadata variables.
If mapping
is supplied, the function will automatically expand features
or cells
for any features or cells requested in the mapping.
This is convenient as features/cells do not have to specified twice (once in data.frame construction and again in later geom
or stat
layers).
Developers may wish to turn this off with extract_mapping=FALSE
for greater control.
A ggplot object containing the specified contents of x
.
Aaron Lun
makePerCellDF
and makePerFeatureDF
, for the construction of the data.frame.
example_sce <- mockSCE() example_sce <- logNormCounts(example_sce) example_sce <- runPCA(example_sce) ggcells(example_sce, aes(x=PCA.1, y=PCA.2, color=Gene_0001)) + geom_point() ggcells(example_sce, aes(x=Mutation_Status, y=Gene_0001)) + geom_violin() + facet_wrap(~Cell_Cycle) rowData(example_sce)$GC <- runif(nrow(example_sce)) ggfeatures(example_sce, aes(x=GC, y=Cell_001)) + geom_point() + stat_smooth()