calculate_module_coherence: Calculate WGCNA module coherence

View source: R/calculate_module_coherence.R

calculate_module_coherenceR Documentation

Calculate WGCNA module coherence

Description

Calculate within module pairwise gene correlations from WGCNA modules and gene expression data. Test the coherence of modules built from Dataset A in data from Dataset B.

Usage

calculate_module_coherence(
  mods,
  mods_title = "STUDY1",
  mods_var = "module.char",
  remove_mods = c(0, "0", "00", "grey"),
  dat,
  gene_var = "geneName",
  dat_title = "STUDY2",
  return_plot = TRUE,
  r_cutoff = 0.3,
  p_cutoff = 0.01
)

Arguments

mods

Dataframe giving module membership such as output by make_modules. Must include mods_var with module names/IDs and gene_var with gene symbols/IDs

mods_title

Character string specifying name the study/dataset from which modules were built. This is used simply for labeling of outputs. Default = "STUDY1"

mods_var

Character string specifying name of the column in mods df which defines modules. Defaults to "module.char" which is output by make_modules()

remove_mods

Vector of character strings naming modules which you want removed from the analysis. Default includes 0,"0","00","grey"

dat

limma EList output by voom( ) or dataframe contains expression data (like dat$E) in which module coherence is to be tested.

gene_var

Character string specifying name of the column in mods df which gives gene IDs. Values must match rownames in expression data (dat). Defaults to "geneName" which is output by make_modules()

dat_title

Character string specifying name of the study from which the data come. This is used simply for labeling of outputs. Default = "STUDY2"

return_plot

Logical indicating whether plot should be printed when function runs. Defaults = TRUE.

r_cutoff

Vector or single numeric value at which to draw red cutoff lines in correlation plot. Default = 0.3

p_cutoff

Vector or single numeric value at which to draw red cutoff lines in significance plot. Default = 0.01

Value

List including:

  • coherence_boxplot_combined A ggplot plot object visualizing distributions of correlation and p values.

  • coherence_boxplot_cor A ggplot plot object visualizing distributions of correlation values.

  • coherence_boxplot_p A ggplot plot object visualizing distributions of correlation p values.

  • subgene_correlation_df Dataframe containing pairwise gene correlations within modules.

  • GSabsent A list of missing genes enumerating genes defined in modules but missing from expression data.

#'

Examples

moduleCoherence <- calculate_module_coherence(mods = example.mods,
dat = example.voom, mods_title = "Example WGCNA Modules",
dat_title = "Example Data", r_cutoff = 0.3, p_cutoff = 0.01)

BIGslu/RNAetc documentation built on Feb. 13, 2025, 7:42 a.m.