dimensionReductionPlot: Plot the coordinates from 'dimensionReduction' values

View source: R/tab_dimensionreduction.R

dimensionReductionPlotR Documentation

Plot the coordinates from dimensionReduction values

Description

The function dimensionReductionPlot creates a dimension reduction plot. The function takes as input the tbl object obtained from the dimensionReduction function. The tbl contains transformed values by one of the dimension reduction methods.

Usage

dimensionReductionPlot(
  tbl,
  se,
  color = c("none", colnames(se@colData)),
  size = c("none", colnames(se@colData)),
  explainedVar = NULL,
  x_coord,
  y_coord,
  height = 600,
  interactive = TRUE
)

Arguments

tbl

tbl as obtained by the function dimensionReduction

se

SummarizedExperiment

color

character, one of "none" or colnames(se@colData)

size

character, one of "none" or colnames(se@colData)

explainedVar

NULL or named numeric, if numeric explainedVar contains the explained variance per principal component (names of explainedVar corresponds to the principal components)

x_coord

character, column name of tbl that stores x coordinates

y_coord

character, column name of tbl that stores y coordinates

height

numeric, specifying the height of the plot (in pixels)

interactive

logical(1), if TRUE dimensionReductionPlot will return a plotly object, if FALSE dimensionReductionPlot will return a gg object

Details

The function dimensionReductionPlot is a wrapper for a ggplot/ggplotly expression.

Value

plotly or gg

Author(s)

Thomas Naake

Examples

library(SummarizedExperiment)

## create se
a <- matrix(seq_len(100), nrow = 10, ncol = 10, byrow = TRUE,
            dimnames = list(seq_len(10), paste("sample", seq_len(10))))
set.seed(1)
a <- a + rnorm(100)
cD <- data.frame(name = colnames(a), type = c(rep("1", 5), rep("2", 5)),
  median_vals = apply(a, 2, median))
rD <- data.frame(spectra = rownames(a))
se <- SummarizedExperiment(assay = a, rowData = rD, colData = cD)

pca <- dimensionReduction(x = assay(se), type = "PCA", params = list())[[1]]

dimensionReductionPlot(tbl = pca, se = se, color = "type", size = "median_vals",
    x_coord = "PC1", y_coord = "PC2")


tnaake/MatrixQCvis documentation built on June 20, 2024, 7:22 a.m.