Learn R Programming

cellGeometry (version 0.5.7)

quantile_map: Quantile mapping function between two scRNA-Seq datasets

Description

Quantile mapping to combine two scRNA-Seq datasets based on mapping either the distribution of mean log2+1 gene expression in cell clusters to the distribution of the 2nd dataset, or mapping the quantiles of one matrix of gene expression (with genes in rows) to another.

Usage

quantile_map(
  x,
  y,
  n = 10000,
  remove_noncoding = TRUE,
  remove_zeros = FALSE,
  smooth = "loess",
  span = 0.15,
  knots = c(0.25, 0.75, 0.85, 0.95, 0.97, 0.99, 0.999),
  respace = FALSE,
  silent = FALSE
)

Value

A list object of class 'qqmap' containing:

quantiles

Dataframe containing matching quantiles of x and y

map

A function of form FUN(x) where x can be supplied as a numeric vector or matrix and the same type is returned. The function converts given data points to the distribution of y.

Arguments

x

scRNA-Seq data whose distribution is to be mapped onto y: either a matrix of gene expression on log2+1 scale, or a 'cellMarkers' class object, in which case the $genemeans list element is extracted.

y

Reference scRNA-Seq data: either a matrix of gene expression on log2+1 scale, or a 'cellMarkers' class object, in which case the $genemeans list element is extracted.

n

Number of quantiles to split x and y.

remove_noncoding

Logical, whether to remove noncoding. This is a basic filter which looks at the gene names (rownames) in both matrices and removes genes containing "-" which are usually antisense or mitochondrial genes, or "." which are either pseudogenes or ribosomal genes.

remove_zeros

Logical, whether to remove zeros from both datasets. This shifts the quantile relationships.

smooth

Either "loess" or "lowess" which apply loess() or lowess() to smooth the QQ fitted line, or "ns" which uses natural splines via ns(). With any other value no smoothing is applied. With no smoothing or "loess/lowess", interpolation is limited to the original range of x, i.e. it will clip for values > max(x).

span

controls the degree of smoothing in loess() and lowess().

knots

Vector of quantile points for knots for fitting natural splines.

respace

Logical whether to respace quantile points so their x axis density is more even. Can help spline fitting.

silent

Logical whether to suppress messages.

Details

The conversion uses the function approxfun() which uses interpolation. It is not designed to perform stepwise (exact) quantile transformation of every individual datapoint.

See Also