deconvDigitalDLSorterObj: Deconvolute bulk gene expression samples (bulk RNA-Seq)

View source: R/dnnModel.R

deconvDigitalDLSorterObjR Documentation

Deconvolute bulk gene expression samples (bulk RNA-Seq)

Description

Deconvolute bulk gene expression samples (bulk RNA-Seq). This function requires a DigitalDLSorter object with a trained Deep Neural Network model (trained.model slot) and the new bulk RNA-Seq samples to be deconvoluted in the deconv.data slot. See ?loadDeconvData for more details.

Usage

deconvDigitalDLSorterObj(
  object,
  name.data,
  batch.size = 128,
  normalize = TRUE,
  scaling = "standarize",
  simplify.set = NULL,
  simplify.majority = NULL,
  verbose = TRUE
)

Arguments

object

DigitalDLSorter object with trained.data and deconv.data slots.

name.data

Name of the data stored in the DigitalDLSorter object. If not provided, the first data set will be used.

batch.size

Number of samples per gradient update. If not specified, batch.size will default to 128.

normalize

Normalize data before deconvolution (TRUE by default).

scaling

How to scale data before training. It may be: "standarize" (values are centered around the mean with a unit standard deviation) or "rescale" (values are shifted and rescaled so that they end up ranging between 0 and 1). If normalize = FALSE, data is not scaled.

simplify.set

List specifying which cell types should be compressed into a new label whose name will be the list item. See examples for details. If provided, results are stored in a list with 'raw' and 'simpli.set' results.

simplify.majority

List specifying which cell types should be compressed into the cell type with the highest proportion in each sample. Unlike simplify.set, it allows to maintain the complexity of the results while compressing the information, as no new labels are created. If provided, the results are stored in a list with 'raw' and 'simpli.majority' results.

verbose

Show informative messages during the execution.

Details

This function is intended for users who have built a devonvolution model using their own single-cell RNA-Seq data. If you want to use a pre-trained model to deconvolute your samples, see ?deconvDigitalDLSorter.

Value

DigitalDLSorter object with deconv.results slot. The resulting information is a data frame with samples (i) as rows and cell types (j) as columns. Each entry represents the proportion of j cell type in i sample. If simplify.set or/and simpplify.majority are provided, the deconv.results slot will contain a list with raw and simplified results.

References

Torroja, C. and Sánchez-Cabo, F. (2019). digitalDLSorter: A Deep Learning algorithm to quantify immune cell populations based on scRNA-Seq data. Frontiers in Genetics 10, 978. doi: doi: 10.3389/fgene.2019.00978

See Also

trainDigitalDLSorterModel DigitalDLSorter

Examples

## Not run: 
set.seed(123)
sce <- SingleCellExperiment::SingleCellExperiment(
  assays = list(
    counts = matrix(
      rpois(30, lambda = 5), nrow = 15, ncol = 20,
      dimnames = list(paste0("Gene", seq(15)), paste0("RHC", seq(20)))
    )
  ),
  colData = data.frame(
    Cell_ID = paste0("RHC", seq(20)),
    Cell_Type = sample(x = paste0("CellType", seq(6)), size = 20,
                       replace = TRUE)
  ),
  rowData = data.frame(
    Gene_ID = paste0("Gene", seq(15))
  )
)
DDLS <- loadSCProfiles(
  single.cell.data = sce,
  cell.ID.column = "Cell_ID",
  gene.ID.column = "Gene_ID"
)
probMatrixValid <- data.frame(
  Cell_Type = paste0("CellType", seq(6)),
  from = c(1, 1, 1, 15, 15, 30),
  to = c(15, 15, 30, 50, 50, 70)
)
DDLS <- generateBulkCellMatrix(
  object = DDLS,
  cell.ID.column = "Cell_ID",
  cell.type.column = "Cell_Type",
  prob.design = probMatrixValid,
  num.bulk.samples = 50,
  verbose = TRUE
)
# training of DDLS model
tensorflow::tf$compat$v1$disable_eager_execution()
DDLS <- trainDigitalDLSorterModel(
  object = DDLS,
  on.the.fly = TRUE,
  batch.size = 15,
  num.epochs = 5
)
# simulating bulk RNA-Seq data
countsBulk <- matrix(
  stats::rpois(100, lambda = sample(seq(4, 10), size = 100, replace = TRUE)),
  nrow = 40, ncol = 15,
  dimnames = list(paste0("Gene", seq(40)), paste0("Bulk", seq(15)))
)
seBulk <- SummarizedExperiment(assay = list(counts = countsBulk))
DDLS <- loadDeconvData(
  object = DDLS,
  data = seBulk,
  name.data = "Example"
)
# simplify arguments
simplify <- list(CellGroup1 = c("CellType1", "CellType2", "CellType4"),
                 CellGroup2 = c("CellType3", "CellType5"))
DDLS <- deconvDigitalDLSorterObj(
  object = DDLS,
  name.data = "Example",
  simplify.set = simplify,
  simplify.majority = simplify
)

## End(Not run)

digitalDLSorteR documentation built on Oct. 5, 2022, 9:05 a.m.