importGeneSetsFromCollection {singleCellTK} | R Documentation

## Imports gene sets from a GeneSetCollection object

### Description

Converts a list of gene sets stored in a GeneSetCollection object and stores it in the metadata of the SingleCellExperiment object. These gene sets can be used in downstream quality control and analysis functions in singleCellTK.

### Usage

    importGeneSetsFromCollection(
      inSCE,
      geneSetCollection,
      collectionName = "GeneSetCollection",
      by = "rownames"
    )

### Arguments

`inSCE` | Input SingleCellExperiment object.
`geneSetCollection` | A GeneSetCollection object. See GeneSetCollection for more details.
`collectionName` | Character. Name of collection to add gene sets to. If this collection already exists in `inSCE`, then these gene sets will be added to that collection. Any gene sets within the collection with the same name will be overwritten. Default `GeneSetCollection`.
`by` | Character, character vector, or NULL. Describes the location within `inSCE` where the gene identifiers in `geneSetCollection` should be mapped. If set to `"rownames"` then the features will be searched for among `rownames(inSCE)`. This can also be set to one of the column names of `rowData(inSCE)` in which case the gene identifies will be mapped to that column in the `rowData` of `inSCE`. `by` can be a vector the same length as the number of gene sets in the `GeneSetCollection` and the elements of the vector can point to different locations within `inSCE`. Finally, `by` can be `NULL`. In this case, the location of the gene identifiers in `inSCE` should be saved in the description slot for each gene set in the `GeneSetCollection`. See featureIndex for more information. Default `"rownames"`.

### Details

The gene identifiers in gene sets in the `GeneSetCollection` will be mapped to the rownames of `inSCE` using the `by` parameter and stored in a GeneSetCollection object from package GSEABase. This object is stored in `metadata(inSCE)$sctk$genesets`, which can be accessed in downstream analysis functions such as runCellQC.

### Value

A SingleCellExperiment object with gene set from `collectionName` output stored to the metadata slot.

### Author(s)

Joshua D. Campbell

### See Also

importGeneSetsFromList for importing from lists, importGeneSetsFromGMT for importing from GMT files, and importGeneSetsFromMSigDB for importing MSigDB gene sets.

### Examples

    data(scExample)
    library(GSEABase)
    gs1 <- GeneSet(setName = "geneset1", geneIds = rownames(sce)[1:10])
    gs2 <- GeneSet(setName = "geneset2", geneIds = rownames(sce)[11:20])
    gsc <- GeneSetCollection(list(gs1, gs2))
    sce <- importGeneSetsFromCollection(inSCE = sce,
                                        geneSetCollection = gsc,
                                        by = "rownames")

[Package singleCellTK version 2.0.0 Index]