Skip to contents

Violin plot of variance fraction for each gene and each variable

Usage

# S4 method for class 'DataFrame'
plotVarPart(
  obj,
  col = c(ggColorHue(base::ncol(obj) - 3), "grey85"),
  label.angle = 20,
  main = "",
  ylab = "",
  convertToPercent = TRUE,
  ncol = 3,
  ...
)

Arguments

obj

varParFrac object returned by fitExtractVarPart or extractVarPart

col

vector of colors

label.angle

angle of labels on x-axis

main

title of plot

ylab

text on y-axis

convertToPercent

multiply fractions by 100 to convert to percent values

ncol

number of columns in the plot

...

additional arguments

Value

Violin plot showing variance fractions

Examples

library(muscat)
library(SingleCellExperiment)

data(example_sce)

# create pseudobulk for each sample and cell cluster
pb <- aggregateToPseudoBulk(example_sce,
  assay = "counts",
  cluster_id = "cluster_id",
  sample_id = "sample_id",
  verbose = FALSE
)

# voom-style normalization
res.proc <- processAssays(pb, ~group_id)
#>   B cells...
#> 0.22 secs
#>   CD14+ Monocytes...
#> 0.31 secs
#>   CD4 T cells...
#> 0.23 secs
#>   CD8 T cells...
#> 0.17 secs
#>   FCGR3A+ Monocytes...
#> 0.27 secs

# variance partitioning analysis
vp <- fitVarPart(res.proc, ~group_id)
#>   B cells...
#> 2.4 secs
#>   CD14+ Monocytes...
#> 2.5 secs
#>   CD4 T cells...
#> 2 secs
#>   CD8 T cells...
#> 1.2 secs
#>   FCGR3A+ Monocytes...
#> 2.4 secs
#> 

# Summarize variance fractions genome-wide for each cell type
plotVarPart(vp)
#> Warning: Ignoring unknown aesthetics: outlier.colour