Learn R Programming

RaceID (version 0.3.9)

inspectKNN: Function for inspecting pruned k-nearest neighbourhoods

Description

This function allows inspection of the local background model and the pruning of nearest neighbours for a given cell. A dimensional reduction representation is plotted where k nearest neighours and outliers are highlighted. Alternatively, the dependence of the transcript count variance or, alternatively, the coefficient of variation (CV) on the mean in log2 space is plotted. The mean-variance dependence is plotted along with a loess-regression, a second order polynomial fit, and the background model of the local variability. The CV plot also highlights the local variability associated with cell-to-cell variability of total transcript counts, as calculated directly from the mean and variance of total transcript counts (turquoise) or from a local fit of a gamma distribution (orange).

Usage

inspectKNN(
  i,
  expData,
  res,
  cl,
  object = NULL,
  nb = res$pars$nb,
  pvalue = 0.01,
  backModel = NULL,
  alpha = res$alpha[i],
  plotSymbol = FALSE,
  id = NULL,
  degree = 2,
  span = 0.75,
  cv = FALSE,
  ...
)

Value

List object with six components:

pv.neighbours.cell

Vector of outlier p-values (Bonferroni-corrected) for each of the k-nearest neighbours.

cluster.neighours

Vector of cluster numbers for central cell and each of the k-nearest neighbours.

alpha

alpha parameter used for pruning.

expr.neighbours

Matrix of normalized transcript counts for the central cell and each of the k-nearest neighbours (normalized to the minimum number of total trascript counts across all neighours). Additional columns indicate inferred local mean, standard deviation, and strongest outlier p-value. Rows are sorted by p-values of the strongest outlier cell in increasing order.

pv.neighbours

Matrix of outlier p-values of all genes for the central cells and each of the k-nearest neighbours. Rows are sorted by p-values of the strongest outlier cell in increasing order.

strongest.outlier

Column name of strongest outlier.

Arguments

i

Either integer column index or column name of expData. Pruning is inspected for the neighbourhood of this cell.

expData

Matrix of gene expression values with genes as rows and cells as columns. These values have to correspond to unique molecular identifier counts.

res

List object with k nearest neighbour information returned by pruneKnn function.

cl

List object with clustering information, returned by the graphCluster function.

object

SCseq class object. Required if plotSymbol is TRUE. Default is NULL.

nb

Input parameter of pruneKnn. See help(pruneKnn). Default is res$pars$nb.

pvalue

Positive real number between 0 and 1. All nearest neighbours with link probability < pvalue are pruned. Default is 0.01.

backModel

Optional background model. Second order polynomial fitting the mean-variance dpendence on log2 scales as returned by lm. Default is NULL and the local background model is computed as in pruneKnn.

alpha

Input parameter of pruneKnn. See help(pruneKnn). Default is res$pars$alpha.

plotSymbol

Logical. If TRUE then a dimensional reduction representation is plotted highlighting cell i, all k nearest neighbours, all outliers, and the stringest outlier in different colours. Function plotsymbolsmap is used. Additional parameter for this function, such as um=TRUE can be given. Default is FALSE, and the local mean-variance dependence is plotted along with a second order polynomial fit and a local regression. See plotMV.

id

Valid column name of expData. If plotSymbol=TRUE this corresponding cell is highlighted in the dimensional reduction representation.

degree

Input parameter for mean-variance fit. See plotMV.

span

Input parameter for mean-variance fit. See plotMV.

cv

Input parameter for mean-variance fit. See plotMV.

...

Additional parameters for plotsymbolsmap.