runDeconvolution: Run Deconvolution using NNLS model

View source: R/runDeconvolution.R

runDeconvolutionR Documentation

Run Deconvolution using NNLS model

Description

This function takes in the mixture data, the trained model & the topic profiles and returns the proportion of each cell type within each mixture

Usage

runDeconvolution(
  x,
  mod,
  ref,
  scale = TRUE,
  min_prop = 0.01,
  verbose = TRUE,
  slot = "counts"
)

Arguments

x

mixture dataset. Can be a numeric matrix, SingleCellExperiment or SpatialExperiment.

mod

object of class NMFfit as obtained from trainNMF.

ref

Object of class matrix containing the topic profiles for each cell type as obtained from trainNMF.

scale

logical specifying whether to scale single-cell counts to unit variance. This gives the user the option to normalize the data beforehand as you see fit (CPM, FPKM, ...) when passing a matrix or specifying the slot from where to extract the count data.

min_prop

scalar in [0,1] setting the minimum contribution expected from a cell type in x to observations in y. By default 0.

verbose

logical. Should information on progress be reported?

slot

If the object is of class SpatialExperiment indicates matrix to use. By default "counts".

Value

base a list where the first element is an NMFfit object and the second is a matrix containing the topic profiles learnt.

Author(s)

Marc Elosua Bayes & Helena L Crowell

Examples

set.seed(321)
# mock up some single-cell, mixture & marker data
sce <- mockSC(ng = 200, nc = 10, nt = 3)
spe <- mockSP(sce)
mgs <- getMGS(sce)

res <- trainNMF(
    x = sce,
    y = spe,
    groups = sce$type,
    mgs = mgs,
    weight_id = "weight",
    group_id = "type",
    gene_id = "gene")
# Run deconvolution
decon <- runDeconvolution(
    x = spe,
    mod = res[["mod"]],
    ref = res[["topic"]])

MarcElosua/SPOTlight documentation built on March 7, 2024, 4:58 p.m.