Skip to contents

Plot trend of variance fractions for a specified component versus count magnitude for each gene and cell cluster

Usage

plotTrendVP(x, vp, component, cluster_ids = names(x), ...)

# S4 method for class 'lucida,data.frame'
plotTrendVP(x, vp, component, cluster_ids = names(x), ...)

Arguments

x

object returned by lucida()

vp

data.frame from fitVarPart()

component

variance component to extract from vp

cluster_ids

which cell types to plot

...

additional arguments

Value

Plot of variance fraction vs count magnitude

Examples

library(SingleCellExperiment)

# Load example data
data(example_sce, package="muscat")
sce <- example_sce

# Compute library size for each cell
sce$libSize <- colSums(counts(sce))

# Specify regression formula and cell annotation 
form <- ~ group_id + (1|sample_id)
fit <- lucida(sce, form, "cluster_id", verbose=FALSE)
#> B cells 
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:00
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:01
#> CD14+ Monocytes 
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:01
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:01
#> CD4 T cells 
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:00
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:01
#> CD8 T cells 
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:00
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:01
#> FCGR3A+ Monocytes 
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:01
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:01

# Model with only intercept and random effect
form <- ~ (1|sample_id)
fit.null <- lucida(sce, form, "cluster_id", verbose=FALSE)
#> B cells 
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:00
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:00
#> CD14+ Monocytes 
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:00
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:00
#> CD4 T cells 
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:00
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:00
#> CD8 T cells 
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:00
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:00
#> FCGR3A+ Monocytes 
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:00
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:00

# Variance partitioning analysis
vp <- fitVarPart(fit, fit.null) 

plotTrendVP(fit, vp, "CountNoise")