treecor_degheatmap: Plot heatmap for top n differentially expressed genes

View source: R/treecor_degheatmap.R

treecor_degheatmapR Documentation

Plot heatmap for top n differentially expressed genes

Description

Plot heatmap for top n differentially expressed genes

Usage

treecor_degheatmap(
  sample_meta,
  pseudobulk,
  deg_result,
  top_n = 10,
  deg_logFC = "both",
  scale = "row",
  cluster_rows = F,
  cluster_cols = F,
  show_colnames = F,
  show_rownames = T,
  annotation_col = NA,
  annotation_colors = NA,
  color = colorRampPalette(rev(brewer.pal(n = 7, name = "RdYlBu")))(100),
  breaks = NA,
  fontsize = 12
)

Arguments

sample_meta

A data frame for sample-level metadata, where each row is a sample. Must contain 'sample' column and additional variables such as covariates or outcome of interest.

pseudobulk

A sample-level pseudobulk, which can be obtained by running 'limma_expr' pipeline and can be extracted via 'result$pseudobulk.ls[[cell_type_name]]'.

deg_result

Differential expression output obtained by running limma_expr' pipeline' and can be extracted via 'result$dge.ls[[phenotype]][[cell_type_name]]'.

top_n

A number to extract top n differentially expressed genes. If deg_logFC = 'both', then top n DEGs with positive logFC will be combined with top n DEGs with negative logFC, resulting in a total of 2n genes.

deg_logFC

Filter 'deg_result' by logFC. One of the following: #'

  • positive: limit to genes with logFC>0.

  • negative: limit to genes with logFC<0.

  • both (default): keep genes with both positive and negative logFC.

scale

A character indicates if the values should be centered and scaled in either the 'row' direction or the 'column' direction, or 'none'.

cluster_rows

A True of False indicator to determine if rows should be clustered.

cluster_cols

A True of False indicator to determine if column names should be displayed.

annotation_col

A vector specifying column names to be annotated in the sidebars of a heatmap.

annotation_colors

List for manually specifying colors for annotation_col.

color

A vector of colors used in heatmap.

breaks

A sequence of numbers specifying range of values in the matrix. Must be an element longer than color vector. See more in '?pheatmap'.

fontsize

Font size.

show_rows

A True of False indicator to determine if row names should be displayed.

Value

Heatmap with DEGs on the row and samples on the column.

Author(s)

Boyang Zhang <bzhang34@jhu.edu>, Hongkai Ji

Examples

# Assume obtain pseudobulk of celltype 'T' from treecor_deg()
result <- treecor_deg(expr,hierarchy_list, cell_meta, sample_meta, response_variable = 'severity')
pseudobulk <- result$pseudobulk.ls[['T']]
deg_result <- result$dge.ls$severity[['T']]
# Top 10 DEGs with logFC>0
treecor_degheatmap(sample_meta,pseudobulk, deg_result, top_n = 10, deg_logFC = 'positive')
# Top 10 DEGs with logFC<0
treecor_degheatmap(sample_meta,pseudobulk, deg_result, top_n = 10, deg_logFC = 'negative')
# Combined the above two options: top 10 positively-associated DEGs and top 10 negatively-associated DEGs
treecor_degheatmap(sample_meta,pseudobulk, deg_result, top_n = 10, deg_logFC = 'both')

byzhang23/TreeCorTreat documentation built on May 7, 2024, 8:37 a.m.