prepareCellData {cydar} | R Documentation

## Prepare mass cytometry data

### Description

Convert single-cell marker intensities from a mass cytometry experiment into a format for efficient counting.

### Usage

    prepareCellData(x, markers = NULL, ...)

### Arguments

`x` | A named list of numeric matrices, where each matrix corresponds to a sample and contains expression intensities for each cell (row) and each marker (column). Alternatively, a ncdfFlowSet object containing the same information.
`markers` | A character vector containing the names of the markers to use in downstream analyses.
`...` | Additional arguments to pass to `buildIndex`.

### Details

This function constructs a BiocNeighborIndex object from the marker intensities of each cell in one or more samples. The precomputed index is used to speed up downstream nearest-neighbour searching, avoiding redundant work from repeated calls to `countCells` (e.g., with different values of `tol`).

If `markers` is specified, only the selected markers will be used in the precomputation. This restricts the markers that are used in downstream functions - namely, `countCells` and `neighborDistances`. By default, `markers=NULL` which means that all supplied markers will be used.

Markers that are not in `markers` will be ignored in distance calculations. However, their intensities are still stored in the output object, for use in functions like `medIntensities`.

### Value

A List containing precomputed values for use in `countCells`. This includes:

- `precomputed`, a BiocNeighborIndex object containing a pre-built index for the neighbor search.

- `sample.id`, an integer vector specifying the sample of origin for each cell in `precomputed`.

- `cell.id`, an integer vector specifying the original index in the corresponding sample of `x` for each cell in `precomputed`.

- `unused`, a matrix of intensity values for markers not in `markers`.

- `colData`, a DataFrame containing per-sample statistics.

### Author(s)

Aaron Lun

### See Also

`countCells`, where the output of this function is used to obtain hypersphere counts.

### 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)
        colnames(ex) <- marker.names
        x[[i]] <- ex
    }

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

[Package cydar version 1.11.6 Index]