Skip to contents

Matrix of residuals form lucida fit with genes along rows. This is stored as a ResidualMatrixGLM and entries are only evaluated when accessed

Usage

# S4 method for class 'lucida'
residuals(
  object,
  sce,
  type = c("deviance", "pearson", "response"),
  chunkSize = floor(3/(ncol(sce) * 8/1024^3)),
  ...
)

Arguments

object

model fit from lucida()

sce

SingleCellExperiment used for lucida()

type

of residuals: c("deviance", "pearson", "response")

chunkSize

number of rows to read into memory at a time

...

other args

Value

ResidualMatrixGLM of residuals with genes along rows

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))

# fit joint model on all cells
fit <- lucida(sce, ~ 1)
#> Analyze all cells jointly...
#> all 
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:00
#> 
  |                                                              |   0%, ETA NA
  |=======================================================| 100%, Elapsed 00:00
#> 

# extract residuals as a ResidualMatrixGLM
res <- residuals(fit, sce)

res[1:3, 1:3]
#> <3 x 3> DelayedMatrix object of type "double":
#>          ATCATGCTGCGTAT-1 GTACGAACTGTCAG-1 CGTGATGAATTTCC-1
#> HES4          -0.01601760      -0.01601760      -0.01601760
#> ISG15          3.24949708       2.20217242      -0.15216263
#> AURKAIP1       3.87051294      -0.01974081       3.87051294