gsea.clusters: GSEA for clusters.

Description Usage Arguments Details Value Examples

View source: R/standalone_gsea.R

Description

A function to perform GSEA on differentially expressed gene lists from clusters and plot as a heatmap.

Usage

1
2
3
4
5
6
7
8
gsea.clusters(
  degdf,
  pathways = NULL,
  nperm = NULL,
  weightmethod = NULL,
  onlypos = NULL,
  filter_nonsig_pathways = NULL
)

Arguments

degdf

A dataframe in the format of the output of Seurat::FindAllMarkers.

pathways

A named "list of lists" of genes. The format of this object is important for functionality of this function and can be previewed in the tamlabscpipeline::hallmark object. The names of each list element provides the Y axis; the genes within each list element are the target genes used for GSEA. If NULL, defaults to the Msigdb's Hallmark pathways for mouse.

nperm

An integer denoting how many permutations FGSEA will run. Default = 10000.

weightmethod

A string, one of either "pvalue", "padj", or "foldchange". Default = "pvalue".

onlypos

T/F. Whether to filter each cluster to only include upregulated genes. Default = F.

filter_nonsig_pathways

T/F. Whether to remove non-significant rows from resulting heatmap. Useful if running very large numbers of pathways, or to generate finalized plots after exploratory analysis. Default = F.

Details

Expects as input a data.frame with column names consistent with output of Seurat::FindAllMarkers(). Essentially, a dataframe where each row corresponds to a gene, and columns consists of the following: "p_val", "avg_logFC", "pct.1", "pct.2", "p_val_adj", "cluster", and "gene". Minimally requires "cluster", "gene", and "avg_logFC". Pvalue and/or adjusted pvalue can be included if weighting by those values.

Pathways must be a named list of character vectors; by default uses mouse orthologs of Msigdb Hallmark sets, accessible via tamlabscpipeline::hallmark.

See FGSEA package docs for details. Also check out the Broad's Msigdb to view a large database of pathways and the MsigdbR package to get orthologs of the Msigdb pathways for your species of interest.

Output plots can be difficult to read if many pathways are used. Recommended 50-75 or so pathways as the maximum, many more will generate very ugly heatmaps. Utilizes special characters, so pdf printing may be problematic. Alternative PDF devices should be able to handle this though, one can use Quartz if on Mac, or CairoPDF if on Windows.

Value

Returns a ggplot object, and prints a heatmap to the standard out.

Examples

1
2
3
4
5
## Not run: 
sobjmarkers <- Seurat::FindAllMarkers(sobj)
gsea.clusters(sobjmarkers)

## End(Not run)

apf2139/tamlabscpipeline documentation built on July 23, 2021, 11 a.m.