expandRadius {cydar} | R Documentation

## Expand the hypersphere radius

### Description

Expands the hypersphere radius to account for intensity shifting between non-barcoded samples.

### Usage

    expandRadius(prepared, design = NULL, tol = 0.5)

### Arguments

`prepared` | A List object containing a BiocNeighborIndex object, typically produced by `prepareCellData`.
`design` | A numeric matrix specifying the experimental design.
`tol` | A numeric scalar proportional to the hypersphere radius, see `countCells`.

### Details

This function increases the hypersphere radius to account for random shifts in marker intensity between non-barcoded samples. The required increase is estimated by taking the mean of all intensities for each marker in each sample; computing the variance of the mean intensities across samples for each marker; and taking the mean variance across all markers. This is equivalent to the square of the extra distance between cells caused by intensity shifts between samples.

The estimated increase is added onto `tol`, and the returned value can be directly used in the `tol` argument of `countCells`. This expands the hyperspheres to ensure that corresponding subpopulations in different samples are still counted together. Otherwise, an intensity shift in one sample may move the cells in a subpopulation out of a hypersphere. This will inflate the variability if it occurs between replicate samples, and introduce spurious differences if it occurs between samples in different conditions.

### Value

A numeric scalar specifying a modified `tol` to use in `countCells`.

### Author(s)

Aaron Lun

### See Also

`prepareCellData`, to generate the required input.

`countCells`, where the `tol` can be set to the output of this function.

### Examples

    ### Mocking up some data: ###
    nmarkers <- 20
    marker.names <- paste0("X", seq_len(nmarkers))
    nsamples <- 8
    sample.names <- paste0("Y", seq_len(nsamples))

    x <- list()
    for (i in sample.names) {
        ex <- matrix(rgamma(nmarkers*1000, 2, 2), ncol=nmarkers, nrow=1000)
        ex <- t(t(ex) + rnorm(nmarkers, 0, 0.25)) # Adding a shift per marker
        colnames(ex) <- marker.names
        x[[i]] <- ex
    }

    ### Running the function: ###
    cd <- prepareCellData(x)
    expandRadius(cd)

[Package cydar version 1.11.6 Index]