assignUnassigned {clusterExperiment} | R Documentation

## Assign unassigned samples to nearest cluster

### Description

Assigns the unassigned samples in a cluster to the nearest cluster based on distance to the medians of the clusters.

### Usage

    ## S4 method for signature 'ClusterExperiment'
    assignUnassigned(object,
      whichCluster = "primary", clusterLabel, makePrimary = TRUE,
      whichAssay = 1, reduceMethod = "none", ...)

    ## S4 method for signature 'ClusterExperiment'
    removeUnassigned(object,
      whichCluster = "primary")

### Arguments

`object` | A Cluster Experiment object
`whichCluster` | argument that can be a single numeric or character value indicating the single clustering to be used. Giving values that result in more than one clustering will result in an error. See details of `getClusterIndex`.
`clusterLabel` | if missing, the current cluster label of the cluster will be appended with the string "_AllAssigned".
`makePrimary` | whether to make the added cluster the primary cluster (only relevant if `y` is a vector)
`whichAssay` | which assay to use to calculate the median per cluster and take dimensionality reduction (if requested)
`reduceMethod` | character. A method (or methods) for reducing the size of the data, either by filtering the rows (genes) or by a dimensionality reduction method. Must either be 1) must match the name of a built-in method, in which case if it is not already existing in the object will be passed to `makeFilterStats` or `link{makeReducedDims}`, or 2) must match a stored filtering statistic or dimensionality reduction in the object
`...` | arguments passed to `getReducedData` specifying the dimensionality reduction (if any) to be taken of the data for calculating the medians of the clusters

### Details

The function `assignUnassigned` calculates the median values of each variable for each cluster, and then calculates the euclidean distance of each unassigned sample to the median of each cluster. Each unassigned sample is assigned to the cluster for which it closest to the median.

All unassigned samples in the cluster are given a clustering, regardless of whether they are classified as -1 or -2.

`removeUnclustered` removes all samples that are unclustered (i.e. -1 or -2 assignment) in the designated cluster of `object` (so they may be unclustered in other clusters found in `clusterMatrix(object)`).

### Value

The function `assignUnassigned` returns a `ClusterExperiment` object with the unassigned samples assigned to one of the existing clusters.

The function `removeUnassigned` returns a `ClusterExperiment` object with the unassigned samples removed.

### See Also

`getReducedData`

### Examples

    #load CE object
    data(rsecFluidigm)
    smallCE<-rsecFluidigm[,1:50]
    #assign the unassigned samples
    assignUnassigned(smallCE, makePrimary=TRUE)

    #note how samples are REMOVED:
    removeUnassigned(smallCE)

[Package clusterExperiment version 2.7.2 Index]