plotExplanatoryVariables: Plot explanatory variables ordered by percentage of...

Description Usage Arguments Details Value Examples

View source: R/qc.R

Description

Plot explanatory variables ordered by percentage of phenotypic variance explained

Usage

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

Arguments

object

an SCESet 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 "exprs" (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 pData(object) are considered and the nvars_to_plot variables with the highest median marginal R-squared are plotted.

return_object

logical, should an SCESet 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data("sc_example_counts")
data("sc_example_cell_info")
pd <- new("AnnotatedDataFrame", data = sc_example_cell_info)
rownames(pd) <- pd$Cell
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, ]
example_sceset <- calculateQCMetrics(example_sceset)
vars <- names(pData(example_sceset))[c(2:3, 5:14)]
plotExplanatoryVariables(example_sceset, variables=vars)

dynverse/scaterlegacy documentation built on Feb. 17, 2020, 5:07 a.m.