plot_reduced_dimension() takes a `SummarizedExperiment` that has been processed with `reduce_dimensions()` and returns a ggplot of the selected reduced dimensions, optionally coloured by a sample covariate. For PCA, axis labels include the percentage of variance explained.

plot_reduced_dimension(.data, .color, method = "PCA", dims = 1:2)

# S4 method for class 'SummarizedExperiment'
plot_reduced_dimension(.data, .color, method = "PCA", dims = 1:2)

# S4 method for class 'RangedSummarizedExperiment'
plot_reduced_dimension(.data, .color, method = "PCA", dims = 1:2)

Arguments

.data

A `SummarizedExperiment` object

.color

A symbol. Column in `colData` used for colour coding

method

A character string. Dimensionality reduction method to plot (e.g. `"PCA"`, `"MDS"`, `"tSNE"`, `"UMAP"`)

dims

Integer vector of length 2. Which dimensions to plot (default `1:2`)

Value

A ggplot object

A ggplot object

A ggplot object

Details

`r lifecycle::badge("maturing")`

References

Mangiola, S., Molania, R., Dong, R., Doyle, M. A., & Papenfuss, A. T. (2021). tidybulk: an R tidy framework for modular transcriptomic data analysis. Genome Biology, 22(1), 42. doi:10.1186/s13059-020-02233-7

Examples

## Load airway dataset for examples
data('airway', package = 'airway')
  # Ensure a 'condition' column exists for examples expecting it

    SummarizedExperiment::colData(airway)$condition <- SummarizedExperiment::colData(airway)$dex


counts.PCA =
 airway |>
 identify_abundant() |>
 reduce_dimensions(assay = "counts", method="PCA", .dims = 3)
#> Warning: All samples appear to belong to the same group.
#> Getting the 500 most variable genes
#> Fraction of variance explained by the selected principal components
#> # A tibble: 3 × 2
#>   `Fraction of variance`    PC
#>                    <dbl> <int>
#> 1                  0.409     1
#> 2                  0.285     2
#> 3                  0.147     3
#> tidybulk says: to access the raw results do `metadata(.)$tidybulk$PCA`

 plot_reduced_dimension(counts.PCA, .color = condition, method = "PCA", dims = 1:2)