sampleImputation: Sample-mean Estimation

Description Usage Arguments Value Examples

View source: R/imputation.R

Description

Cluster cells using SNN and a list of given genes, estimate missing expression values for each cell-gene combination with the within-cluster non-zero expression mean

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
sampleImputation(
  expression_matrix,
  subset_genes = NULL,
  scale_data = TRUE,
  number_pcs = 8,
  k_neighbors = 30,
  snn_resolution = 0.9,
  impute_index = NULL,
  pseudo_zero = NULL,
  python_path = NULL,
  verbose = FALSE
)

Arguments

expression_matrix

Row by column log-normalized expression matrix

subset_genes

A vector of informative gene names, defaults to all genes

scale_data

Whether to standardize expression by gene, default TRUE

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

pseudo_zero

Pseudo-zero expression value

python_path

path to your python binary (default = system path)

verbose

Print progress output to the console

Value

Returns a sparse matrix of class 'dgCMatrix'

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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

m_imputed <- rescue::sampleImputation(
  expression_matrix = m,
  k_neighbors = 10
)

rescue documentation built on July 18, 2020, 5:06 p.m.