Skip to contents

Compute the sum of squares of the residuals and compare to a chisq null distribution. This gives very liberal p-values sicen the null distribution is often not satisifed with real data

Usage

findHVGs(x, fit)

Arguments

x

ResidualMatrixGLM matrix

fit

model fit from lucida()

Value

tibble storing

ID

gene identifier

sumSq

p-value that sumSq is larger than expected under the null

P.Value

p-value that sumSq is larger than expected under the null

FDR

false discovery rate

isHVG

is FDR < 0.05

Examples

library(SingleCellExperiment)
#> Loading required package: SummarizedExperiment
#> Loading required package: MatrixGenerics
#> Loading required package: matrixStats
#> 
#> Attaching package: ‘MatrixGenerics’
#> The following objects are masked from ‘package:matrixStats’:
#> 
#>     colAlls, colAnyNAs, colAnys, colAvgsPerRowSet, colCollapse,
#>     colCounts, colCummaxs, colCummins, colCumprods, colCumsums,
#>     colDiffs, colIQRDiffs, colIQRs, colLogSumExps, colMadDiffs,
#>     colMads, colMaxs, colMeans2, colMedians, colMins, colOrderStats,
#>     colProds, colQuantiles, colRanges, colRanks, colSdDiffs, colSds,
#>     colSums2, colTabulates, colVarDiffs, colVars, colWeightedMads,
#>     colWeightedMeans, colWeightedMedians, colWeightedSds,
#>     colWeightedVars, rowAlls, rowAnyNAs, rowAnys, rowAvgsPerColSet,
#>     rowCollapse, rowCounts, rowCummaxs, rowCummins, rowCumprods,
#>     rowCumsums, rowDiffs, rowIQRDiffs, rowIQRs, rowLogSumExps,
#>     rowMadDiffs, rowMads, rowMaxs, rowMeans2, rowMedians, rowMins,
#>     rowOrderStats, rowProds, rowQuantiles, rowRanges, rowRanks,
#>     rowSdDiffs, rowSds, rowSums2, rowTabulates, rowVarDiffs, rowVars,
#>     rowWeightedMads, rowWeightedMeans, rowWeightedMedians,
#>     rowWeightedSds, rowWeightedVars
#> Loading required package: GenomicRanges
#> Loading required package: stats4
#> Loading required package: BiocGenerics
#> Loading required package: generics
#> 
#> Attaching package: ‘generics’
#> The following objects are masked from ‘package:base’:
#> 
#>     as.difftime, as.factor, as.ordered, intersect, is.element, setdiff,
#>     setequal, union
#> 
#> Attaching package: ‘BiocGenerics’
#> The following objects are masked from ‘package:stats’:
#> 
#>     IQR, mad, sd, var, xtabs
#> The following objects are masked from ‘package:base’:
#> 
#>     Filter, Find, Map, Position, Reduce, anyDuplicated, aperm, append,
#>     as.data.frame, basename, cbind, colnames, dirname, do.call,
#>     duplicated, eval, evalq, get, grep, grepl, is.unsorted, lapply,
#>     mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int,
#>     rank, rbind, rownames, sapply, saveRDS, table, tapply, unique,
#>     unsplit, which.max, which.min
#> Loading required package: S4Vectors
#> 
#> Attaching package: ‘S4Vectors’
#> The following object is masked from ‘package:utils’:
#> 
#>     findMatches
#> The following objects are masked from ‘package:base’:
#> 
#>     I, expand.grid, unname
#> Loading required package: IRanges
#> Loading required package: Seqinfo
#> Loading required package: Biobase
#> Welcome to Bioconductor
#> 
#>     Vignettes contain introductory material; view with
#>     'browseVignettes()'. To cite Bioconductor, see
#>     'citation("Biobase")', and for packages 'citation("pkgname")'.
#> 
#> Attaching package: ‘Biobase’
#> The following object is masked from ‘package:MatrixGenerics’:
#> 
#>     rowMedians
#> The following objects are masked from ‘package:matrixStats’:
#> 
#>     anyMissing, rowMedians

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

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

# Find highly variable genes
findHVGs( res, fit)
#> # A tibble: 1,205 × 5
#>    ID         sumSq   P.Value       FDR isHVG
#>    <chr>      <dbl>     <dbl>     <dbl> <lgl>
#>  1 HES4       5033. 0         0         TRUE 
#>  2 ISG15    226595. 0         0         TRUE 
#>  3 AURKAIP1   7030. 0         0         TRUE 
#>  4 MRPL20     4081. 1.88e-225 2.05e-225 TRUE 
#>  5 SSU72      5723. 0         0         TRUE 
#>  6 RER1       7515. 0         0         TRUE 
#>  7 RPL22      8038. 0         0         TRUE 
#>  8 PARK7      9331. 0         0         TRUE 
#>  9 ENO1      18893. 0         0         TRUE 
#> 10 FBXO6      4181. 4.45e-239 4.96e-239 TRUE 
#> # ℹ 1,195 more rows