Skip to contents

This function estimates the abundances of SEs in bulk tumor gene expression data using a provided basis matrix (`W`) from NMF model.

Usage

DeconvoluteSE(
  dat,
  scale = TRUE,
  W = NULL,
  nsample.per.run = 500,
  sum2one = TRUE,
  ncores = 8
)

Arguments

dat

A numeric matrix of gene expression data, e.g. TPM matrix for bulk RNA-seq data, logCPM matrix for Visium data etc.

scale

Logical. If `TRUE`, the input data is scaled before making predictions.

W

A numeric matrix representing the basis matrix (`W`) from a pretrained NMF model.

nsample.per.run

Integer specifying the maximum number of samples to process per prediction run to manage memory usage efficiently.

sum2one

Logical. If `TRUE`, normalizes the predicted SE abundances so that they sum to 1 for each sample.

ncores

Integer specifying the number of CPU cores to use for parallel processing.

Value

A matrix of SE abundances in bulk tumors.

Examples

library(SpatialEcoTyper)
library(data.table)
bulkdata <- fread("https://spatialecotyper.stanford.edu/inc/inc.public.vignettes.php?file=SKCM_RNASeqV2.geneExp.tsv",
                  sep = "\t", header = TRUE, data.table = FALSE)
#> Warning: URL 'https://spatialecotyper.stanford.edu/inc/inc.public.vignettes.php?file=SKCM_RNASeqV2.geneExp.tsv': Timeout of 60 seconds was reached
#> Error in download.file(file, tmpFile, method = method, mode = "wb", quiet = !showProgress): download from 'https://spatialecotyper.stanford.edu/inc/inc.public.vignettes.php?file=SKCM_RNASeqV2.geneExp.tsv' failed
rownames(bulkdata) = bulkdata[, 1]
#> Error in eval(expr, envir, enclos): object 'bulkdata' not found
bulkdata = as.matrix(bulkdata[, -1])
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'as.matrix': object 'bulkdata' not found

# Predict SE abundances in bulk tumors
se_abundances <- DeconvoluteSE(dat = bulkdata)
#> Error in eval(expr, envir, enclos): object 'bulkdata' not found
head(se_abundances[, 1:5])
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'head': object 'se_abundances' not found