plotExplanatoryVariables {scater} | R Documentation

## Plot explanatory variables ordered by percentage of phenotypic variance explained

### Description

Plot explanatory variables ordered by percentage of phenotypic variance explained

### Usage

    plotExplanatoryVariables(object, method = "density",
      exprs_values = "logcounts", nvars_to_plot = 10, min_marginal_r2 = 0,
      variables = NULL, return_object = FALSE, theme_size = 10, ...)

### Arguments

`object` | an SingleCellExperiment object containing expression values and experimental information. Must have been appropriately prepared.
`method` | character scalar indicating the type of plot to produce. If "density", the function produces a density plot of R-squared values for each variable when fitted as the only explanatory variable in a linear model. If "pairs", then the function produces a pairs plot of the explanatory variables ordered by the percentage of feature expression variance (as measured by R-squared in a marginal linear model) explained.
`exprs_values` | which slot of the `assayData` in the `object` should be used to define expression? Valid options are "logcounts" (default), "tpm", "fpkm", "cpm", and "counts".
`nvars_to_plot` | integer, the number of variables to plot in the pairs plot. Default value is 10.
`min_marginal_r2` | numeric scalar giving the minimal value required for median marginal R-squared for a variable to be plotted. Only variables with a median marginal R-squared strictly larger than this value will be plotted.
`variables` | optional character vector giving the variables to be plotted. Default is `NULL`, in which case all variables in `colData(object)` are considered and the `nvars_to_plot` variables with the highest median marginal R-squared are plotted.
`return_object` | logical, should an `SingleCellExperiment` object with median marginal R-squared values added to `varMetadata(object)` be returned?
`theme_size` | numeric scalar giving font size to use for the plotting theme
`...` | parameters to be passed to `pairs`.

### Details

If the `method` argument is "pairs", then the function produces a pairs plot of the explanatory variables ordered by the percentage of feature expression variance (as measured by R-squared in a marginal linear model) explained by variable. Median percentage R-squared is reported on the plot for each variable. Discrete variables are coerced to a factor and plotted as integers with jittering. Variables with only one unique value are quietly ignored.

### Value

A ggplot object

### Examples

    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, ]
    example_sce <- calculateQCMetrics(example_sce)
    vars <- names(colData(example_sce))[c(2:3, 5:14)]
    plotExplanatoryVariables(example_sce, variables=vars)

[Package scater version 1.6.3 Index]