Description Usage Arguments Details Value Examples
Produce a principal components analysis (PCA) plot of two or more principal
components for an SCESet
dataset.
1 2 3 4 5 6 7 8 9 10 11 12 13 | plotPCASCESet(object, ntop = 500, ncomponents = 2, exprs_values = "exprs",
colour_by = NULL, shape_by = NULL, size_by = NULL, feature_set = NULL,
return_SCESet = FALSE, scale_features = TRUE, draw_plot = TRUE,
pca_data_input = "exprs", selected_variables = NULL,
detect_outliers = FALSE, theme_size = 10, legend = "auto")
## S4 method for signature 'SCESet'
plotPCA(object, ntop = 500, ncomponents = 2,
exprs_values = "exprs", colour_by = NULL, shape_by = NULL,
size_by = NULL, feature_set = NULL, return_SCESet = FALSE,
scale_features = TRUE, draw_plot = TRUE, pca_data_input = "exprs",
selected_variables = NULL, detect_outliers = FALSE, theme_size = 10,
legend = "auto")
|
object |
an |
ntop |
numeric scalar indicating the number of most variable features to
use for the PCA. Default is |
ncomponents |
numeric scalar indicating the number of principal
components to plot, starting from the first principal component. Default is
2. If |
exprs_values |
character string indicating which values should be used
as the expression values for this plot. Valid arguments are |
colour_by |
character string defining the column of |
shape_by |
character string defining the column of |
size_by |
character string defining the column of |
feature_set |
character, numeric or logical vector indicating a set of
features to use for the PCA. If character, entries must all be in
|
return_SCESet |
logical, should the function return an |
scale_features |
logical, should the expression values be standardised
so that each feature has unit variance? Default is |
draw_plot |
logical, should the plot be drawn on the current graphics
device? Only used if |
pca_data_input |
character argument defining which data should be used
as input for the PCA. Possible options are |
selected_variables |
character vector indicating which variables in
|
detect_outliers |
logical, should outliers be detected in the PC plot?
Only an option when |
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
|
... |
further arguments passed to |
The function prcomp
is used internally to do the PCA.
The function checks whether the object
has standardised
expression values (by looking at stand_exprs(object)
). If yes, the
existing standardised expression values are used for the PCA. If not, then
standardised expression values are computed using scale
(with
feature-wise unit variances or not according to the scale_features
argument), added to the object and PCA is done using these new standardised
expression values.
If the arguments detect_outliers
and return_SCESet
are both
TRUE
, then the element $outlier
is added to the pData
(phenotype data) slot of the SCESet
object. This element contains
indicator values about whether or not each cell has been designated as an
outlier based on the PCA. These values can be accessed for filtering
low quality cells with, foe example, example_sceset$outlier
.
either a ggplot plot object or an SCESet object
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 | ## Set up an example SCESet
data("sc_example_counts")
data("sc_example_cell_info")
pd <- new("AnnotatedDataFrame", data = sc_example_cell_info)
example_sceset <- newSCESet(countData = sc_example_counts, phenoData = pd)
drop_genes <- apply(exprs(example_sceset), 1, function(x) {var(x) == 0})
example_sceset <- example_sceset[!drop_genes, ]
## Examples plotting PC1 and PC2
plotPCA(example_sceset)
plotPCA(example_sceset, colour_by = "Cell_Cycle")
plotPCA(example_sceset, colour_by = "Cell_Cycle", shape_by = "Treatment")
plotPCA(example_sceset, colour_by = "Cell_Cycle", shape_by = "Treatment",
size_by = "Mutation_Status")
plotPCA(example_sceset, shape_by = "Treatment", size_by = "Mutation_Status")
plotPCA(example_sceset, feature_set = 1:100, colour_by = "Treatment",
shape_by = "Mutation_Status")
## experiment with legend
example_subset <- example_sceset[, example_sceset$Treatment == "treat1"]
plotPCA(example_subset, colour_by = "Cell_Cycle", shape_by = "Treatment", legend = "all")
plotPCA(example_sceset, shape_by = "Treatment", return_SCESet = TRUE)
## Examples plotting more than 2 PCs
plotPCA(example_sceset, ncomponents = 8)
plotPCA(example_sceset, ncomponents = 4, colour_by = "Treatment",
shape_by = "Mutation_Status")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.