addPrcomp {dittoSeq} | R Documentation

## Add a prcomp pca calculation to a SingleCellExperiment object containing bulk or single-cell data

### Description

Add a prcomp pca calculation to a SingleCellExperiment object containing bulk or single-cell data

### Usage

    addPrcomp(object, prcomp, name = "pca", key = "PC")

### Arguments

`object` | the `SingleCellExperiment` object.
`prcomp` | a prcomp output which will be added to the `object`
`name` | String name for the reduction slot. Normally, this will be "pca", but you can hold any number of PCA calculations so long as a unique `name` is given to each. This will become the name of the slot and what should be provided to the `reduction.use` input when making a `dittoDimPlot`. When the name given is the same as that of a slot that already exists inside the `object`, the previous slot is replaced with the newly provided data.
`key` | String, like "PC", which sets the default axes-label prefix when this reduction is used for making a `dittoDimPlot`

### Value

Outputs an `SingleCellExperiment` object with an added or replaced pca reduction slot.

### Author(s)

Daniel Bunis

### See Also

`addDimReduction` for adding other types of dimensionality reductions

`importDittoBulk` for initial import of bulk RNAseq data into dittoSeq as a `SingleCellExperiment`.

`dittoDimPlot` for visualizing how samples group within added dimensionality reduction spaces

### Examples

    example("importDittoBulk", echo = FALSE)

    # Calculate PCA with prcomp
    #   NOTE: This is typically not done with all genes in a dataset.
    #   The inclusion of this example code is not an endorsement of a particular
    #   method of PCA. Consult yourself, a bioinformatician, or literature for
    #   tips on proper techniques.
    calc <- prcomp(t(logcounts(myRNA)), center = TRUE, scale = TRUE)

    myRNA <- addPrcomp(
        object = myRNA,
        prcomp = calc)

    # Now we can visualize conditions metadata on a PCA plot
    dittoDimPlot(myRNA, "conditions", reduction.use = "pca", size = 3)

[Package dittoSeq version 1.6.0 Index]