getDEGs: Retrieve differentially expressed genes from edgeR or DESeq2...

View source: R/func_markers.R

getDEGsR Documentation

Retrieve differentially expressed genes from edgeR or DESeq2 analysis

Description

This function parses an object of class TopTags, DGEExact or DGELRT from edgeR or DESeqResults class from DESeq2, and returns the differentially expressed genes (DEGs) that passed the specified thresholds.

Usage

getDEGs(
  object,
  direction = "both",
  fdr = 0.05,
  logfc = c(0, 0),
  max = 1000,
  column_by = NULL
)

Arguments

object

An object of class TopTags, DGEExact, DGELRT or DESeqResults.

direction

A string indicating the directionality of expression changes of DEGs to retreive. Allowable character values are "both", "up" and "down". Default is "both".

fdr

A numeric scalar indicating the FDR threashold used to select DEGs. Default is 0.05.

logfc

A numeric scalar indicating the logFC cutoffs used to select DEGs. Default is c(0, 0).

max

An integer scalar indicating the maximum number of DEGs to return. Default is 1000.

column_by

A string indicating the column name containing the gene symbols or IDs in the input object and the selected information is returned. When column_by = NULL, it retreives the row names from the DataFrame. Default is NULL.

Details

The function parses the standard output objects from edgeR and DESeq2 to selects DEGs that "passed" the fdr, logfc and max threshold.

The accapted class types includes:

  • DGEExact, returned by exactTest() from edgeR.

  • DGELRT, returned by glmLRT(), glmTreat() or glmQLFTest() from edgeR.

  • TopTags, returned by topTags() from edgeR.

  • DESeqResults returned by results() from DESeq2.

By specifying direction, the function selects DEGs with a positive and negative logFC when direction = "both" (default), only positive logFC when direction = "up", and only negative logFC when direction = "down".

Value

A character vector

Author(s)

I-Hsuan Lin

See Also

edgeR::exactTest(), edgeR::glmLRT(), edgeR::glmTreat(), edgeR::glmQLFTest(), edgeR::topTags(), DESeq2::results()

Examples

# Load demo dataset
data(res_deseq2)
data(res_edger)

# Retrieve first 250 up-regulated DEGs from DESeq2's output,
# return rownames (Ensembl ID)
getDEGs(res_deseq2, direction = "up", max = 250)

# Retrieve first 1000 DEGs at FDR = 10% from edgeR's output,
# return values from the `external_gene_name` column (Gene Symbol)
getDEGs(res_edger, fdr = 0.1, column_by = "external_gene_name")

ycl6/scRUtils documentation built on Feb. 18, 2025, 6:14 a.m.