Learn R Programming

rescue (version 1.0.3)

bootstrapImputation: Bootstrap Imputation

Description

Subsample informative genes, cluster cells using SNN, estimate missing expression values with the distribution mean of means extrapolated from these cell clusterings

Usage

bootstrapImputation(
  expression_matrix,
  select_cells = NULL,
  select_genes = NULL,
  log_transformed = TRUE,
  log_base = exp(1),
  proportion_genes = 0.6,
  bootstrap_samples = 100,
  number_pcs = 8,
  k_neighbors = 30,
  snn_resolution = 0.9,
  impute_index = NULL,
  use_mclapply = FALSE,
  cores = 2,
  return_individual_results = FALSE,
  python_path = NULL,
  verbose = FALSE
)

Arguments

expression_matrix

Row by column log-normalized expression matrix

select_cells

Subset cells if desired

select_genes

A vector of highly variable of differentially expressed gene names, defaults to the most variable

log_transformed

Whether the expression matrix has been log-transformed

log_base

If log-transformed, log-base used

proportion_genes

Proportion of informative genes to sample

bootstrap_samples

Number of samples for the bootstrap

number_pcs

Number of dimensions to inform SNN clustering

k_neighbors

Number of k neighbors to use for NN network

snn_resolution

Resolution parameter for SNN

impute_index

Index to impute, will default to all zeroes

use_mclapply

Run in parallel, default FALSE

cores

Number of cores for parallelization

return_individual_results

Return a list of subsampled means

python_path

path to your python binary (default = system path)

verbose

Print progress output to the console

Value

Returns a list with the imputed and original expression matrices

Examples

Run this code
# NOT RUN {
set.seed(0)
requireNamespace("Matrix")

## generate (meaningless) counts
c1 <- stats::rpois(5e3, 1)
c2 <- stats::rpois(5e3, 2)
m <- t(
  rbind(
    matrix(c1, nrow = 20),
    matrix(c2, nrow = 20)
  )
)

## construct an expression matrix m
colnames(m) <- paste0('cell', 1:ncol(m))
rownames(m) <- paste0('gene', 1:nrow(m))
m <- log(m/colSums(m)*1e4 + 1)
m <- methods::as(m, 'dgCMatrix')

## impute
# }
# NOT RUN {
m_imputed <- rescue::bootstrapImputation(
  expression_matrix = m,
  proportion_genes = .9,
  bootstrap_samples = 2,
  k_neighbors = 10
)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab