Extract residuals for top n highly variable genes
Usage
topHVGs(x, fit, n = nrow(x))Arguments
- x
ResidualMatrixGLMmatrix- fit
model fit from
lucida()- n
number of genes to extract
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:01
#>
| | 0%, ETA NA
|=======================================================| 100%, Elapsed 00:00
#>
# extract residuals as a ResidualMatrixGLM
res <- residuals(fit, sce)
# Extract top 100 highly variables genes
topHVGs( res, fit, 100)
#> <100 x 1556> DelayedMatrix object of type "double":
#> ATCATGCTGCGTAT-1 GTACGAACTGTCAG-1 ... TCAAGGTGGAATGA-1 GAATGGCTAAACAG-1
#> FTH1 19.583616 12.068644 . 38.588972 38.312189
#> MALAT1 22.063063 27.029746 . 33.867262 53.946640
#> B2M 17.905081 16.172044 . 26.076119 47.126060
#> FTL 3.729061 1.945190 . 4.945306 11.284633
#> TMSB4X 5.838556 9.095312 . 24.693523 37.767697
#> ... . . . . .
#> RPL18 6.71501636 6.71501636 . -0.06890475 5.73855468
#> IFIT3 -0.06052771 -0.06052771 . 14.37607837 15.08728053
#> RPS5 -0.06918068 6.64209215 . 5.68144382 8.25281526
#> IFITM3 -0.05633518 -0.05633518 . 11.33393261 11.73624188
#> ANXA2 -0.05229725 -0.05229725 . 9.32236380 6.93187352