View source: R/runColDataPCA.R

runColDataPCA | R Documentation |

Perform a principal components analysis (PCA) on cells, based on the column metadata in a SingleCellExperiment object.

```
runColDataPCA(
x,
ncomponents = 2,
variables = NULL,
scale = TRUE,
outliers = FALSE,
BSPARAM = ExactParam(),
BPPARAM = SerialParam(),
name = "PCA_coldata"
)
```

`x` |
A SingleCellExperiment object. |

`ncomponents` |
Numeric scalar indicating the number of principal components to obtain. |

`variables` |
List of strings or a character vector indicating which variables in |

`scale` |
Logical scalar, should the expression values be standardised so that each feature has unit variance? This will also remove features with standard deviations below 1e-8. |

`outliers` |
Logical indicating whether outliers should be detected based on PCA coordinates. |

`BSPARAM` |
A BiocSingularParam object specifying which algorithm should be used to perform the PCA. |

`BPPARAM` |
A BiocParallelParam object specifying whether the PCA should be parallelized. |

`name` |
String specifying the name to be used to store the result in the |

This function performs PCA on variables from the column-level metadata instead of the gene expression matrix.
Doing so can be occasionally useful when other forms of experimental data are stored in the `colData`

,
e.g., protein intensities from FACs or other cell-specific phenotypic information.

This function is particularly useful for identifying low-quality cells based on QC metrics with `outliers=TRUE`

.
This uses an “outlyingness” measure computed by `adjOutlyingness`

in the robustbase package.
Outliers are defined those cells with outlyingness values more than 5 MADs above the median, using `isOutlier`

.

A SingleCellExperiment object containing the first `ncomponent`

principal coordinates for each cell.
By default, these are stored in the `"PCA_coldata"`

entry of the `reducedDims`

slot.
The proportion of variance explained by each PC is stored as a numeric vector in the `"percentVar"`

attribute.

If `outliers=TRUE`

, the output `colData`

will also contain a logical `outlier`

field.
This specifies the cells that correspond to the identified outliers.

Aaron Lun, based on code by Davis McCarthy

`runPCA`

, for the corresponding method operating on expression data.

```
example_sce <- mockSCE()
qc.df <- perCellQCMetrics(example_sce, subset=list(Mito=1:10))
colData(example_sce) <- cbind(colData(example_sce), qc.df)
# Can supply names of colData variables to 'variables',
# as well as AsIs-wrapped vectors of interest.
example_sce <- runColDataPCA(example_sce, variables=list(
"sum", "detected", "subsets_Mito_percent", "altexps_Spikes_percent"
))
reducedDimNames(example_sce)
head(reducedDim(example_sce))
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.