plotReducedDim {scater} | R Documentation |
Plot reduced dimension representation of cells
plotReducedDimDefault(df_to_plot, ncomponents = 2, percentVar = NULL, colour_by = NULL, shape_by = NULL, size_by = NULL, theme_size = 10, legend = "auto") plotReducedDim(object, use_dimred, ncomponents = 2, colour_by = NULL, shape_by = NULL, size_by = NULL, exprs_values = "logcounts", percentVar = NULL, ...)
df_to_plot |
data.frame containing a reduced dimension represenation of cells and optional metadata for the plot. |
ncomponents |
numeric scalar indicating the number of principal
components to plot, starting from the first principal component. Default is
2. If |
percentVar |
numeric vector giving the proportion of variance in
expression explained by each reduced dimension. Only expected to be used
internally in the |
colour_by |
character string defining the column of |
shape_by |
character string defining the column of |
size_by |
character string defining the column of |
theme_size |
numeric scalar giving default font size for plotting theme (default is 10). |
legend |
character, specifying how the legend(s) be shown? Default is
|
object |
an |
use_dimred |
character, name of reduced dimension representation of cells
stored in |
exprs_values |
a string specifying the expression values to use for
colouring the points, if |
... |
optional arguments (from those listed above) passed to
|
The function plotReducedDim.default
assumes that the first
ncomponents
columns of df_to_plot
contain the reduced dimension
components to plot, and that any subsequent columns define factors for
colour_by
, shape_by
and size_by
in the plot.
a ggplot plot object
data("sc_example_counts") data("sc_example_cell_info") example_sce <- SingleCellExperiment( assays = list(counts = sc_example_counts), colData = sc_example_cell_info) example_sce <- normalize(example_sce) drop_genes <- apply(exprs(example_sce), 1, function(x) {var(x) == 0}) example_sce <- example_sce[!drop_genes, ] reducedDim(example_sce, "PCA") <- prcomp(t(exprs(example_sce)), scale. = TRUE)$x plotReducedDim(example_sce, "PCA") plotReducedDim(example_sce, "PCA", colour_by="Cell_Cycle") plotReducedDim(example_sce, "PCA", colour_by="Cell_Cycle", shape_by="Treatment") plotReducedDim(example_sce, "PCA", colour_by="Cell_Cycle", size_by="Treatment") plotReducedDim(example_sce, "PCA", ncomponents=5) plotReducedDim(example_sce, "PCA", ncomponents=5, colour_by="Cell_Cycle", shape_by="Treatment") plotReducedDim(example_sce, "PCA", colour_by="Gene_0001")