getTopHVG: Get or set top HVG after calculation

View source: R/getTopHVG.R

getTopHVGR Documentation

Get or set top HVG after calculation

Description

Extracts or select the top variable genes from an input SingleCellExperiment object. Note that the variability metrics must be computed using the runFeatureSelection method before extracting the feature names of the top variable features. getTopHVG only returns a character vector of the HVG selection, while with setTopHVG, a logical vector of the selection will be saved in the rowData, and optionally, a subset object for the HVGs can be stored in the altExps slot at the same time.

Usage

getTopHVG(
  inSCE,
  method = c("vst", "dispersion", "mean.var.plot", "modelGeneVar", "seurat", "seurat_v3",
    "cell_ranger"),
  hvgNumber = 2000,
  useFeatureSubset = "hvf",
  featureDisplay = metadata(inSCE)$featureDisplay
)

setTopHVG(
  inSCE,
  method = c("vst", "dispersion", "mean.var.plot", "modelGeneVar", "seurat", "seurat_v3",
    "cell_ranger"),
  hvgNumber = 2000,
  featureSubsetName = "hvg2000",
  genes = NULL,
  genesBy = NULL,
  altExp = FALSE
)

Arguments

inSCE

Input SingleCellExperiment object

method

Specify which method to use for variable gene extraction from Seurat "vst", "mean.var.plot", "dispersion" or Scran "modelGeneVar" or Scanpy "seurat", "cell_ranger", "seurat_v3". Default "vst"

hvgNumber

Specify the number of top variable genes to extract.

useFeatureSubset

Get the feature names in the HVG list set by setTopHVG. method and hvgNumber will not be used if not this is not NULL. Default "hvf".

featureDisplay

A character string for the rowData variable name to indicate what type of feature ID should be displayed. If set by setSCTKDisplayRow, will by default use it. If NULL, will use rownames(inSCE).

featureSubsetName

A character string for the rowData variable name to store a logical index of selected features. Default "hvg2000".

genes

A customized character vector of gene list to be set as a rowData variable. Will ignore method and hvgNumber if set. Default NULL.

genesBy

If setting customized genes, where should it be found in rowData? Leave NULL for matching rownames. Default NULL.

altExp

TRUE for also creating a subset inSCE object with the selected HVGs and store this subset in the altExps slot, named by hvgListName. Default FALSE.

Value

getTopHVG

A character vector of the top hvgNumber variable feature names

setTopHVG

The input inSCE object with the logical vector of HVG selection updated in rowData, and related parameter updated in metadata. If altExp is TRUE, an altExp is also added

Author(s)

Irzam Sarfraz, Yichen Wang

See Also

runFeatureSelection, runSeuratFindHVG, runModelGeneVar, plotTopHVG

Examples

data("scExample", package = "singleCellTK")

# Create a "highy variable feature" subset using Seurat's vst method:
sce <- runSeuratFindHVG(sce,  method = "vst", hvgNumber = 2000,
       createFeatureSubset = "hvf")
       
# Get the list of genes for a feature subset:
hvgs <- getTopHVG(sce, useFeatureSubset = "hvf")

# Create a new feature subset on the fly without rerunning the algorithm:
sce <- setTopHVG(sce, method = "vst", hvgNumber = 100,
                featureSubsetName = "hvf100")
hvgs <- getTopHVG(sce, useFeatureSubset = "hvf100")

# Get a list of variable features without creating a new feature subset:
hvgs <- getTopHVG(sce, useFeatureSubset = NULL,
                  method = "vst", hvgNumber = 10)


compbiomed/singleCellTK documentation built on Oct. 27, 2024, 3:26 a.m.