View source: R/plotExplanatoryVariables.R

plotExplanatoryVariables | R Documentation |

Plot explanatory variables ordered by percentage of variance explained

```
plotExplanatoryVariables(
object,
nvars_to_plot = 10,
min_marginal_r2 = 0,
theme_size = 10,
...
)
```

`object` |
A SingleCellExperiment object containing expression values and experimental information.
Alternatively, a matrix containing the output of |

`nvars_to_plot` |
Integer scalar specifying the number of variables with the greatest explanatory power to plot.
This can be set to |

`min_marginal_r2` |
Numeric scalar specifying 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. |

`theme_size` |
Numeric scalar specifying the font size to use for the plotting theme |

`...` |
Parameters to be passed to |

A density plot is created for each variable, showing the distribution of R-squared across all genes.
Only the `nvars_to_plot`

variables with the largest median R-squared across genes are shown.
Variables are also only shown if they have median R-squared values above `min_marginal_r2`

.

If `object`

is a SingleCellExperiment object, `getVarianceExplained`

will be called to compute the variance in expression explained by each variable in each gene.
Users may prefer to run `getVarianceExplained`

manually and pass the resulting matrix as `object`

, in which case the R-squared values are used directly.

A ggplot object.

```
example_sce <- mockSCE()
example_sce <- logNormCounts(example_sce)
plotExplanatoryVariables(example_sce)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.