Skip to contents

Runs WGCNA. Largely a wrapper for the blockwiseModules function that reformats data into a format convenient for creating a ModularExperiment object and changes module names from colours to numbers by default.

Usage

runWGCNA(
  X,
  power,
  cor_type = "pearson",
  networkType = "signed",
  module_labels = "numbers",
  maxBlockSize = 30000,
  verbose = 0,
  standardise_reduced = TRUE,
  ...
)

Arguments

X

Either a SummarizedExperiment object or a matrix containing data to be subject to WGCNA. X should have rows as features and columns as samples.

power

soft-thresholding power for network construction.

cor_type

The type of correlation to be used to generate a correlation matrix during network formation. One of "pearson" (cor) and "bicor" (bicor).

networkType

network type. Allowed values are (unique abbreviations of) "unsigned", "signed", "signed hybrid". See adjacency.

module_labels

Specifies whether the modules should be named based on "numbers" or "colours. If module_labels is set to "numbers", then "module_0" represents unclustered genes, whereas if it is set to "colours" then "grey" represents unclustered genes.

maxBlockSize

The chunk size (in terms of the number of features/genes) to process the data. See blockwiseModules for more details. The default (30000) should process standard transcriptomic datasets in a single chunk. Results may differ if the number of features exceeds the chunk size. Lower values of this parameter may use less memory to calculate networks.

verbose

integer level of verbosity. Zero means silent, higher values make the output progressively more and more verbose.

standardise_reduced

If TRUE, the reduced data (eigengenes) are standardised to have a mean of 0 and a standard deviation of 1.

...

Additional arguments to be passed to blockwiseModules.

Value

Returns a list containing:

"E"

The reduced data (eigengenes).

"L"

The module loadings. This represents the values of the PCA rotation matrix for the first principal component generated for each module.

"assignments"

A named vector representing the assignments of genes to modules.

Details

Note that if module_labels is set to "numbers", then "module_0" represents unclustered genes, whereas if it is set to "colours" then "grey" represents unclustered genes.

The function also stores the loadings matrices generated when PCA is performed for each module to calculate eigengenes. These loadings can be used to recalculate the reduced data matrix (eigengenes).

Author

Jack Gisby

Examples

# Get the airway data as a SummarizedExperiment (with a subset of features)
set.seed(2)
airway_se <- ReducedExperiment:::.getAirwayData(n_features = 500)

# Choose an appropriate soft-thresholding power
WGCNA::disableWGCNAThreads()
fit_indices <- assessSoftThreshold(airway_se)
estimated_power <- fit_indices$Power[fit_indices$estimated_power]

# Identify modules using the airway expression matrix
wgcna_res <- runWGCNA(
    assay(airway_se, "normal"),
    verbose = 0,
    power = estimated_power
)

# We find just one module for this small dataset (module_0 indicates unclustered genes)
table(names(wgcna_res$assignments))
#> 
#> module_0 module_1 module_2 module_3 module_4 module_5 
#>       40      265       92       43       35       25