| Title: | High-dimensional Weighted Gene Co-expression Network Analysis |
|---|---|
| Description: | hdWGCNA is an R package for performing weighted gene co-expression network analysis in high dimensional -omics such as single-cell RNA-seq or spatial transcriptomics. It provides tools for constructing metacells, building co-expression networks, computing module eigengenes, and performing various downstream analyses including module trait correlation, module preservation, and transcription factor network analysis. |
| Authors: | Zaoqu Liu [aut, cre] (ORCID: <https://orcid.org/0000-0002-0452-742X>), Sam Morabito [ctb] (ORCID: <https://orcid.org/0000-0002-7768-4856>), Zechuan Shi [ctb] (ORCID: <https://orcid.org/0000-0002-2844-5816>) |
| Maintainer: | Zaoqu Liu <[email protected]> |
| License: | GPL-3 |
| Version: | 0.5.00 |
| Built: | 2026-05-24 09:17:58 UTC |
| Source: | https://github.com/Zaoqu-Liu/hdWGCNA |
Define the set of likely target genes (Regulons) for each transcrition factor
AssignTFRegulons( seurat_obj, strategy = "A", reg_thresh = 0.01, n_tfs = 10, n_genes = 50, wgcna_name = NULL )AssignTFRegulons( seurat_obj, strategy = "A", reg_thresh = 0.01, n_tfs = 10, n_genes = 50, wgcna_name = NULL )
seurat_obj |
A Seurat object |
strategy |
method for defining regulons, "A", "B", or "C". See Details for more info. |
reg_thresh |
threshold for regulatory score in strategies A, B, and C |
n_tfs |
for strategy A, the number of top TFs to keep for each gene |
n_genes |
for strategy B, the number of top target genes to keep for each TF |
wgcna_name |
name of the WGCNA experiment |
AssignTFRegulons uses the TF network information from ConstructTFNetwork to define sets of confident TF-gene pairs. A "regulon" is the set of target genes for a given TF, and this function provides three different strategies to define TF regulons. Strategy "A" selects the top TFs for each gene, strategy "B" selects the top genes for each TF, and strategy "C" retains all TF-gene pairs above a certain regulatory score (reg_thresh).
seurat_obj with the TF Regulon information added
Computes module eigengenes for all WGCNA co-expression modules
AvgModuleExpr(seurat_obj, n_genes = 25, wgcna_name = NULL, ...)AvgModuleExpr(seurat_obj, n_genes = 25, wgcna_name = NULL, ...)
seurat_obj |
A Seurat object |
Makes evenly-spaced bins of cells along a pseudotime trajectory.
BinPseudotime(seurat_obj, n_bins = 50, pseudotime_col = "pseudotime")BinPseudotime(seurat_obj, n_bins = 50, pseudotime_col = "pseudotime")
seurat_obj |
A Seurat object |
n_bins |
number of hub genes to use in the UMAP computation |
pseudotime_col |
name of the column in [email protected] containing pseudotime information |
Check inputs prior to running to_pseudobulk
check_inputs( input, meta = meta, replicate_col = "replicate", cell_type_col = "cell_type", label_col = "label" )check_inputs( input, meta = meta, replicate_col = "replicate", cell_type_col = "cell_type", label_col = "label" )
input |
a single-cell matrix to be converted, with features (genes) in rows
and cells in columns. Alternatively, a |
meta |
the accompanying meta data whereby the rownames match the column
names of |
replicate_col |
the vector in |
cell_type_col |
the vector in |
label_col |
the vector in |
min_cells |
the minimum number of cells in a cell type to retain it.
Defaults to |
min_reps |
the minimum number of replicates in a cell type to retain it.
Defaults to |
min_features |
the minimum number of expressing cells (or replicates)
for a gene to retain it. Defaults to |
a cleaned up expression matrix and meta data object
Function to check if Seurat version is v5
CheckSeurat5()CheckSeurat5()
CheckWGCNAName
CheckWGCNAName(seurat_obj, wgcna_name)CheckWGCNAName(seurat_obj, wgcna_name)
seurat_obj |
A Seurat object |
Internal helper function that computes module eigengene for a single module.
ComputeModuleEigengene( seurat_obj, cur_mod, modules, group.by.vars = NULL, verbose = TRUE, vars.to.regress = NULL, scale.model.use = "linear", pc_dim = 1, assay = NULL, wgcna_name = NULL, ... )ComputeModuleEigengene( seurat_obj, cur_mod, modules, group.by.vars = NULL, verbose = TRUE, vars.to.regress = NULL, scale.model.use = "linear", pc_dim = 1, assay = NULL, wgcna_name = NULL, ... )
seurat_obj |
A Seurat object |
cur_mod |
name of a module found in seurat_obj@misc[seurat_obj@misc$active_wgcna]$wgcna_net$colors |
modules |
table containing module / gene assignments, as in GetModules(seurat_obj). |
group.by.vars |
groups to harmonize by |
verbose |
logical indicating whether to print messages |
vars.to.regress |
character vector of variables in [email protected] to regress when running ScaleData |
scale.model.use |
model to scale data when running ScaleData choices are "linear", "poisson", or "negbinom" |
pc_dim |
Which PC to use as the module eigengene? Default to 1. |
assay |
Assay in seurat_obj to compute module eigengenes. Default is DefaultAssay(seurat_obj) |
wgcna_name |
name of the WGCNA experiment |
This function takes a Seurat object and constructs averaged 'metacells' based on neighboring cells.
ConstructMetacells( seurat_obj, name = "agg", ident.group = "seurat_clusters", k = 25, reduction = "pca", dims = NULL, assay = "RNA", cells.use = NULL, slot = "counts", layer = "counts", meta = NULL, return_metacell = FALSE, mode = "average", max_shared = 15, target_metacells = 1000, max_iter = 5000, verbose = FALSE, wgcna_name = NULL )ConstructMetacells( seurat_obj, name = "agg", ident.group = "seurat_clusters", k = 25, reduction = "pca", dims = NULL, assay = "RNA", cells.use = NULL, slot = "counts", layer = "counts", meta = NULL, return_metacell = FALSE, mode = "average", max_shared = 15, target_metacells = 1000, max_iter = 5000, verbose = FALSE, wgcna_name = NULL )
seurat_obj |
A Seurat object |
name |
A string appended to resulting metalcells. Default = 'agg' |
k |
Number of nearest neighbors to aggregate. Default = 50 |
reduction |
A dimensionality reduction stored in the Seurat object. Default = 'umap' |
dims |
A vector represnting the dimensions of the reduction to use. Either specify the names of the dimensions or the indices. Default = NULL to include all dims. |
assay |
Assay to extract data for aggregation. Default = 'RNA' |
slot |
Slot to extract data for aggregation. Default = 'counts'. Slot is used with Seurat v4 instead of layer. |
layer |
Layer to extract data for aggregation. Default = 'counts'. Layer is used with Seurat v5 instead of slot. |
return_metacell |
Logical to determine if we return the metacell seurat object (TRUE), or add it to the misc in the original Seurat object (FALSE). Default to FALSE. |
mode |
determines how to make gene expression profiles for metacells from their constituent single cells. Options are "average" or "sum". |
max_shared |
the maximum number of cells to be shared across two metacells |
target_metacells |
the maximum target number of metacells to construct |
max_iter |
the maximum number of iterations in the metacells bootstrapping loop |
verbose |
logical indicating whether to print additional information |
wgcna_name |
name of the WGCNA experiment |
Computes metaspots in a given Seurat object containing spatial transcriptomics data. This function is called by MetaspotsByGroups and should NOT be run directly!
ConstructMetaspots( cur_seurat, mode = "sum", assay = "Spatial", slot = "counts", layer = "counts" )ConstructMetaspots( cur_seurat, mode = "sum", assay = "Spatial", slot = "counts", layer = "counts" )
cur_seurat |
A Seurat object |
mode |
"sum" or "average" |
assay |
Assay to extract data for aggregation. Default = 'Spatial' |
slot |
Slot to extract data for aggregation. Default = 'counts' |
layer |
Layer to extract data for aggregation. Default = 'counts'. Layer is used with Seurat v5 instead of slot. |
Constructs a co-expression network and groups genes into modules given a Seurat object that has been prepared for network analysis.
ConstructNetwork( seurat_obj, soft_power = NULL, min_power = 3, tom_outdir = "TOM", tom_name = NULL, consensus = FALSE, overwrite_tom = FALSE, wgcna_name = NULL, blocks = NULL, maxBlockSize = 30000, randomSeed = 12345, corType = "pearson", consensusQuantile = 0.3, networkType = "signed", TOMType = "signed", TOMDenom = "min", scaleTOMs = TRUE, calibrationQuantile = 0.95, sampleForCalibration = TRUE, sampleForCalibrationFactor = 1000, useDiskCache = TRUE, chunkSize = NULL, deepSplit = 4, pamStage = FALSE, detectCutHeight = 0.995, minModuleSize = 50, mergeCutHeight = 0.2, saveConsensusTOMs = TRUE, ... )ConstructNetwork( seurat_obj, soft_power = NULL, min_power = 3, tom_outdir = "TOM", tom_name = NULL, consensus = FALSE, overwrite_tom = FALSE, wgcna_name = NULL, blocks = NULL, maxBlockSize = 30000, randomSeed = 12345, corType = "pearson", consensusQuantile = 0.3, networkType = "signed", TOMType = "signed", TOMDenom = "min", scaleTOMs = TRUE, calibrationQuantile = 0.95, sampleForCalibration = TRUE, sampleForCalibrationFactor = 1000, useDiskCache = TRUE, chunkSize = NULL, deepSplit = 4, pamStage = FALSE, detectCutHeight = 0.995, minModuleSize = 50, mergeCutHeight = 0.2, saveConsensusTOMs = TRUE, ... )
seurat_obj |
A Seurat object |
soft_power |
the soft power used for network construction. Automatically selected by default. |
min_power |
the smallest soft power to be selected if soft_power=NULL |
tom_outdir |
path to the directory where the TOM will be written |
tom_name |
prefix name given to the TOM output file |
consensus |
flag indicating whether or not to perform Consensus network analysis |
wgcna_name |
name of the WGCNA experiment |
... |
additional parameters passed to blockwiseConsensusModules |
ConstructNetwork builds a co-expression network and identifies clusters of highly co-expressed genes (modules) from the metacell or metaspot expression matrix stored in the Seurat object. Before running this function, the following functions must be run on the input Seurat object:
SetupForWGCNA
MetacellsByGroups or MetaspotsByGroups, and NormalizeMetacells
SetDatExpr or SetMultiExpr
TestSoftPowers or TestSoftPowersConsensus
This function can also be used to perform consensus network analysis if consensus=TRUE is selected. ConstructNetwork calls the WGCNA function blockwiseConsensusModules to compute the adjacency matrix, topological overlap matrix, and to run the Dynamic Tree Cut algorithm to identify gene modules. blockwiseConsensusModules has numerous parameters but here we have selected default parameters that we have found to provide reasonable results on a variety of single-cell and spatial transcriptomic datasets.
seurat_obj with the co-expression network and gene modules computed for the selected wgcna experiment
Constructs a "pseudobulk" gene expression matrix summarizing the expression levels of each gene across a grouping variable (cell types for example) in each biological replicate.
ConstructPseudobulk( seurat_obj, group.by, replicate_col, label_col = NULL, assay = "RNA", slot = "counts", layer = "counts", min_reps = 20, wgcna_name = NULL )ConstructPseudobulk( seurat_obj, group.by, replicate_col, label_col = NULL, assay = "RNA", slot = "counts", layer = "counts", min_reps = 20, wgcna_name = NULL )
seurat_obj |
A Seurat object |
group.by |
column in [email protected] containing grouping info, ie clusters or celltypes |
replicate_col |
column in [email protected] denoting each replicate / sample |
label_col |
column in [email protected] denoting an additional label of interest, for example disease status or biological sex. This is not a required argument and is typically only used for consensus WGCNA |
assay |
Assay in seurat_obj containing isoform expression information. |
slot |
Slot to extract data for aggregation. Default = 'counts' |
layer |
Layer to extract data for aggregation. Default = 'counts'. Layer is used with Seurat v5 instead of slot. |
min_reps |
The minimum number of different biological replicates allowed. Error will be thrown if the number of reps is too low. |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
This function constructs pseudobulk gene expression profiles across the provided cell groups and the provided biological replicates. We note that low numbers of replicates are typical in single-cell and spatial transcriptomics due to the large monetary cost of running these experiments, and pseudobulk-ing your data for hdWGCNA is only recommended in the case where you have a sufficient number of replicates. Here we have set the minimum recommended number to 20. Using fewer than 20 replicates risks the results not being reproducible or robust, and therefore are not biologically meaningful due to spurious noisy correlations.
a matrix containing pseudobulk expression profiles
Construct a network of transcription factors and target genes based on gene co-expression
ConstructTFNetwork( seurat_obj, model_params, nfold = 5, callbacks = NULL, wgcna_name = NULL )ConstructTFNetwork( seurat_obj, model_params, nfold = 5, callbacks = NULL, wgcna_name = NULL )
seurat_obj |
A Seurat object |
model_params |
a list of model parameters to pass to xgboost |
nfold |
number of folds for cross validation |
callbacks |
callback functions for the xgboost model |
wgcna_name |
name of the WGCNA experiment |
ConstructTFNetwork uses motif-gene information to build a directed network of transcription factors (TFs) and target genes. XGBoost regression is leveraged to model the expression of each gene based on its candidate TF regulators. This analysis gives us information about how important each TF is for predicting each gene, allowing us to prioritize the most likely regulators of each gene. This process is done on the gene expression matrix stored with SetDatExpr, which is typically the hdWGCNA metacell gene expression matrix.
seurat_obj with the TF network added
Compute the Pearson correlation matrix between columns of two sparse matrices.
corSparse(X, Y = NULL, cov = FALSE)corSparse(X, Y = NULL, cov = FALSE)
X |
A matrix |
Y |
A matrix |
cov |
return covariance matrix |
Originally from http://stackoverflow.com/questions/5888287/running-cor-or-any-variant-over-a-sparse-matrix-in-r and the qlcMatrix & Signac packages.
Michael Cysouw, Karsten Looschen
Wrapper function to run Seurat's DimPlot function on the metacell object.
DimPlotMetacells(seurat_obj, ...)DimPlotMetacells(seurat_obj, ...)
seurat_obj |
A Seurat object |
This function makes an expression heatmap of the top n hub genes per module using Seurat's DoHeatmap, and then assembles them all into one big heatmap.
DoHubGeneHeatmap( seurat_obj, n_hubs = 10, n_cells = 200, group.by = NULL, module_names = NULL, combine = TRUE, draw.lines = TRUE, disp.min = -2.5, disp.max = 2.5, wgcna_name = NULL )DoHubGeneHeatmap( seurat_obj, n_hubs = 10, n_cells = 200, group.by = NULL, module_names = NULL, combine = TRUE, draw.lines = TRUE, disp.min = -2.5, disp.max = 2.5, wgcna_name = NULL )
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
DoHubGeneHeatmapDoHubGeneHeatmap
Generates bar plots from Enrichr data to visualize enriched terms for hdWGCNA modules in a Seurat object. The function outputs a PDF file for each module, with separate bar plots for each database.
EnrichrBarPlot( seurat_obj, outdir = "enrichr_plots", n_terms = 25, p_cutoff = 0.05, p_adj = TRUE, plot_size = c(6, 15), logscale = FALSE, plot_bar_color = NULL, plot_text_color = NULL, wgcna_name = NULL )EnrichrBarPlot( seurat_obj, outdir = "enrichr_plots", n_terms = 25, p_cutoff = 0.05, p_adj = TRUE, plot_size = c(6, 15), logscale = FALSE, plot_bar_color = NULL, plot_text_color = NULL, wgcna_name = NULL )
seurat_obj |
A Seurat object |
outdir |
A string specifying the directory where the output PDF files will be saved. Default is "enrichr_plots". |
n_terms |
An integer indicating the number of top enriched terms to include in each bar plot. Default is 25. |
p_cutoff |
A numeric value specifying the significance threshold for including terms (p-value or adjusted p-value). Only terms with p-values below this threshold are plotted. Default is 0.05. |
p_adj |
Logical indicating whether to use the adjusted p-value (default: TRUE) or raw p-value for filtering terms. |
plot_size |
A numeric vector of length 2 specifying the width and height of the output PDF files in inches. Default is c(6, 15). |
logscale |
Logical specifying whether to log-transform the enrichment scores before plotting. Default is FALSE. |
plot_bar_color |
A string specifying the color of the bars in the bar plots. If NULL (default), bars are colored according to the module's assigned color. |
plot_text_color |
A string specifying the color of the text labels on the bar plots. If NULL (default), the color is automatically determined based on the bar color. |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
This function processes the Enrichr output stored in a Seurat object, filters enriched terms by significance, and generates bar plots for each WGCNA module. Separate plots are created for each database included in the Enrichr results. The top enriched terms for each module and database are ordered by their combined enrichment score. If there are ties in the enrichment scores, the function uses all tied terms.
The bar plot text and bar colors can be customized, and plots can be saved with log-transformed enrichment scores if specified. Text wrapping is applied to long term names for better readability.
Generates PDF files in the specified output directory, with one file per WGCNA module. Each file contains bar plots for all databases associated with that module.
Generate a dot plot visualizing enrichment results from Enrichr for hdWGCNA modules.
EnrichrDotPlot( seurat_obj, database, mods = "all", n_terms = 3, p_cutoff = 0.05, p_adj = TRUE, break_ties = TRUE, term_size = 10, wgcna_name = NULL )EnrichrDotPlot( seurat_obj, database, mods = "all", n_terms = 3, p_cutoff = 0.05, p_adj = TRUE, break_ties = TRUE, term_size = 10, wgcna_name = NULL )
seurat_obj |
A Seurat object |
database |
A character string specifying the name of the Enrichr database to use (e.g., "GO_Biological_Process_2021"). |
mods |
A character vector specifying the names of modules to include in the plot.
If |
n_terms |
An integer specifying the number of top enriched terms to plot for each module (default = 3). |
p_cutoff |
A numeric value specifying the p-value threshold for filtering enriched terms (default = 0.05). |
p_adj |
A logical value indicating whether to use adjusted p-values ( |
break_ties |
A logical value indicating whether to randomly select among tied terms to enforce |
term_size |
A numeric value specifying the font size of the enriched terms displayed on the y-axis (default = 10). |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
This function creates dot plots from Enrichr results associated with hdWGCNA modules. Each module is represented by its most enriched terms from the specified Enrichr database. The size of the dots indicates the enrichment score, and the color indicates the statistical significance (-log10 transformed p-value).
The function first retrieves WGCNA module and Enrichr data from the specified Seurat object.
Modules are filtered based on the mods parameter, and enriched terms are filtered by significance using p_cutoff and p_adj.
The top n_terms terms for each module are selected based on the Combined Score. If ties occur, the break_ties parameter determines how they are resolved.
A dot plot is generated where each dot represents an enriched term, its size corresponds to the Combined Score (log-transformed), and its color indicates the significance (-log10 transformed p-value).
A ggplot2 object representing the dot plot of enriched terms for the specified modules and database.
Function to compare expression levels of co-expression modules between two sets of cell barcodes.
FindAllDMEs( seurat_obj, group.by, features = "MEs", harmonized = TRUE, add_missing = FALSE, wgcna_name = NULL, test.use = "wilcox", only.pos = FALSE, logfc.threshold = 0, min.pct = 0, verbose = FALSE, pseudocount.use = 0, ... )FindAllDMEs( seurat_obj, group.by, features = "MEs", harmonized = TRUE, add_missing = FALSE, wgcna_name = NULL, test.use = "wilcox", only.pos = FALSE, logfc.threshold = 0, min.pct = 0, verbose = FALSE, pseudocount.use = 0, ... )
seurat_obj |
A Seurat object |
group.by |
column in [email protected] containing cell grouping information |
features |
indicate whether to use "MEs" or "ModuleScores" for the comparison |
harmonized |
logical determining whether or not to use harmonized MEs |
add_missing |
logical determining whether or not to add missing modules back into the resulting dataframe with NA values. |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
... |
Additional parameters for the FindMarkers function |
A dataframe contaning differential ME results
FindAllDMEsFindAllDMEs
Function to compare TF regulon scores between two sets of cell barcodes.
FindDifferentialRegulons( seurat_obj, barcodes1, barcodes2, assay = "RNA", slot = "data", layer = "data", wgcna_name = NULL, test.use = "wilcox", only.pos = FALSE, logfc.threshold = 0, min.pct = 0, verbose = FALSE, pseudocount.use = 0, ... )FindDifferentialRegulons( seurat_obj, barcodes1, barcodes2, assay = "RNA", slot = "data", layer = "data", wgcna_name = NULL, test.use = "wilcox", only.pos = FALSE, logfc.threshold = 0, min.pct = 0, verbose = FALSE, pseudocount.use = 0, ... )
seurat_obj |
A Seurat object |
barcodes1 |
character vector containing cell barcodes for the first group to test. Positive fold-change means up-regulated in this group. |
barcodes2 |
character vector containing cell barcodes for the second group to test. Negative fold-change means up-regulated in this group. |
assay |
Assay to extract data for aggregation. Default = 'RNA' |
slot |
Slot to extract data for aggregation. Default = 'counts'. Slot is used with Seurat v4 instead of layer. |
layer |
Layer to extract data for aggregation. Default = 'counts'. Layer is used with Seurat v5 instead of slot. |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
... |
Additional parameters for the Seurat FindMarkers function |
FindDifferentialRegulons compares two groups based on their TF regulon scores. Three comparisons are made for different sets of features: positive regulon scores, negative regulon scores, and gene expression. The same settings for the test will be used for all three tests.
A dataframe contaning differential regulon results
Function to compare expression levels of co-expression modules between two sets of cell barcodes.
FindDMEs( seurat_obj, barcodes1, barcodes2, features = "MEs", harmonized = TRUE, wgcna_name = NULL, add_missing = FALSE, test.use = "wilcox", only.pos = FALSE, logfc.threshold = 0, min.pct = 0, verbose = FALSE, pseudocount.use = 0, ... )FindDMEs( seurat_obj, barcodes1, barcodes2, features = "MEs", harmonized = TRUE, wgcna_name = NULL, add_missing = FALSE, test.use = "wilcox", only.pos = FALSE, logfc.threshold = 0, min.pct = 0, verbose = FALSE, pseudocount.use = 0, ... )
seurat_obj |
A Seurat object |
barcodes1 |
character vector containing cell barcodes for the first group to test. Positive fold-change means up-regulated in this group. |
barcodes2 |
character vector containing cell barcodes for the second group to test. Negative fold-change means up-regulated in this group. |
features |
indicate whether to use "MEs" or "ModuleScores" for the comparison |
harmonized |
logical determining whether or not to use harmonized MEs |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
add_missing |
logical determining whether or not to add missing modules back into the resulting dataframe with NA values. |
... |
Additional parameters for the FindMarkers function |
A dataframe contaning differential ME results
FindDMEsFindDMEs
Finds the set of "major isoforms" for each gene in each cell population. The set of major isoforms consists of the isoforms accounting for a desired proportion of a gene's expression. Pseudobulk replicates in each sample and cell population are used for this calculation.
FindMajorIsoforms( seurat_obj, group.by, replicate_col, isoform_delim = "[.]", proportion_thresh = 0.8, low_thresh = 25, assay = "iso", slot = "counts", cluster_markers = NULL, wgcna_name = NULL )FindMajorIsoforms( seurat_obj, group.by, replicate_col, isoform_delim = "[.]", proportion_thresh = 0.8, low_thresh = 25, assay = "iso", slot = "counts", cluster_markers = NULL, wgcna_name = NULL )
seurat_obj |
A Seurat object |
group.by |
column in [email protected] containing grouping info, ie clusters or celltypes |
replicate_col |
column in [email protected] denoting each replicate / sample |
isoform_delim |
|
proportion_thresh |
desired proportion of expression to define the set of major isoforms. Default = 0.8. |
low_thresh |
lower bound of expression level for considering an isoform as part of the major isoform set. |
assay |
Assay in seurat_obj containing isoform expression information. |
slot |
Slot in seurat_obj, default to counts slot. |
cluster_markers |
Cell population marker gene table from Seurat FindAllMarkers for the same cell populations specified in group.by. Optional parameter, will exclude isoforms that are not from marker genes. |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
FindMajorIsoforms computes the set of major isoforms in a given Seurat object that contains isoform-level expression information. First, pseudobulk replicates are computed for the given cell populations and samples present in the Seurat object. For each gene in each cell population, we rank the gene's isoforms by expression level and take the top expressing isoforms that make up the desired proportion of the gene's total expression, making sure to exclude any very lowly expressed isoforms.
Optionally, the user may supply a marker gene table for each cell population (formatted like the output of Seurat FindAllMarkers), and then the algorithm will only return major isoforms of the given marker genes.
a list of major isoforms for each cell population
GetActiveWGCNA
GetActiveWGCNA(seurat_obj)GetActiveWGCNA(seurat_obj)
seurat_obj |
A Seurat object |
GetActiveWGCNAName
GetActiveWGCNAName(seurat_obj)GetActiveWGCNAName(seurat_obj)
seurat_obj |
A Seurat object |
GetAvgModuleExpr
GetAvgModuleExpr(seurat_obj, wgcna_name = NULL)GetAvgModuleExpr(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
This function gets the WGCNA expression matrix.
GetDatExpr(seurat_obj, wgcna_name = NULL)GetDatExpr(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
GetDegrees
GetDegrees(seurat_obj, wgcna_name = NULL)GetDegrees(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetEnrichrRegulonTable
GetEnrichrRegulonTable(seurat_obj, wgcna_name = NULL)GetEnrichrRegulonTable(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetEnrichrTable
GetEnrichrTable(seurat_obj, wgcna_name = NULL)GetEnrichrTable(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
Extract the top N hub genes for a given set of modules. This function outputs a table with the gene name, the module, and the kME for that module for the top N hub genes.
GetHubGenes(seurat_obj, n_hubs = 10, mods = NULL, wgcna_name = NULL)GetHubGenes(seurat_obj, n_hubs = 10, mods = NULL, wgcna_name = NULL)
seurat_obj |
A Seurat object |
n_hubs |
the number of hub genes to select for each module |
mods |
list of modules, selects all modules by default |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
Function to retrieve module eigengens from Seurat object.
GetMELoadings(seurat_obj, harmonized = TRUE, wgcna_name = NULL)GetMELoadings(seurat_obj, harmonized = TRUE, wgcna_name = NULL)
seurat_obj |
A Seurat object |
harmonized |
logical indicating whether MEs have been harmonized |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
Function to retrieve module eigengens from Seurat object.
GetMEs(seurat_obj, harmonized = TRUE, wgcna_name = NULL)GetMEs(seurat_obj, harmonized = TRUE, wgcna_name = NULL)
seurat_obj |
A Seurat object |
harmonized |
logical indicating whether MEs have been harmonized |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetMetacellObject
GetMetacellObject(seurat_obj, wgcna_name = NULL)GetMetacellObject(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetMetacellParams
GetMetacellParams(seurat_obj, wgcna_name = NULL)GetMetacellParams(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetModulePreservation
GetModulePreservation(seurat_obj, mod_name, wgcna_name = NULL)GetModulePreservation(seurat_obj, mod_name, wgcna_name = NULL)
seurat_obj |
A Seurat object |
mod_name |
name of the module preservation test to store |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetModules
GetModules(seurat_obj, wgcna_name = NULL)GetModules(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetModuleScores
GetModuleScores(seurat_obj, wgcna_name = NULL)GetModuleScores(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetModuleTraitCorrelation
GetModuleTraitCorrelation(seurat_obj, wgcna_name = NULL)GetModuleTraitCorrelation(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetModuleUMAP
GetModuleUMAP(seurat_obj, wgcna_name = NULL)GetModuleUMAP(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetMotifMatrix
GetMotifMatrix(seurat_obj)GetMotifMatrix(seurat_obj)
seurat_obj |
A Seurat object |
GetMotifMatrixGetMotifMatrix
GetMotifOverlap
GetMotifOverlap(seurat_obj, wgcna_name = NULL)GetMotifOverlap(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetMotifs
GetMotifs(seurat_obj)GetMotifs(seurat_obj)
seurat_obj |
A Seurat object |
GetMotifsGetMotifs
GetMotifScores
GetMotifScores(seurat_obj, wgcna_name = NULL)GetMotifScores(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetMotifTargets
GetMotifTargets(seurat_obj)GetMotifTargets(seurat_obj)
seurat_obj |
A Seurat object |
GetMotifTargetsGetMotifTargets
This function gets the expression matrix from the metacell object.
GetMultiExpr(seurat_obj, wgcna_name = NULL)GetMultiExpr(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
GetNetworkData
GetNetworkData(seurat_obj, wgcna_name = NULL)GetNetworkData(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetPFMList
GetPFMList(seurat_obj)GetPFMList(seurat_obj)
seurat_obj |
A Seurat object |
GetPFMListGetPFMList
GetPowerTable
GetPowerTable(seurat_obj, wgcna_name = NULL)GetPowerTable(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetRegulonScores
GetRegulonScores(seurat_obj, target_type, wgcna_name = NULL)GetRegulonScores(seurat_obj, target_type, wgcna_name = NULL)
seurat_obj |
A Seurat object |
target_type |
dataframe storing the TF regulon scores |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetTFEval
GetTFEval(seurat_obj, wgcna_name = NULL)GetTFEval(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetTFNetwork
GetTFNetwork(seurat_obj, wgcna_name = NULL)GetTFNetwork(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetTFRegulons
GetTFRegulons(seurat_obj, wgcna_name = NULL)GetTFRegulons(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
Retrieve target genes for a set of transcription factors (TFs) from a Seurat object, based on either regulons or the full TF network. The function allows exploration of direct targets or extending the network by adding target genes of TFs that are downstream in the network.
GetTFTargetGenes( seurat_obj, selected_tfs, depth = 1, target_type = "both", use_regulons = TRUE, wgcna_name = NULL )GetTFTargetGenes( seurat_obj, selected_tfs, depth = 1, target_type = "both", use_regulons = TRUE, wgcna_name = NULL )
seurat_obj |
A Seurat object containing the TF network or regulon information. This must include WGCNA results in the @misc slot. |
selected_tfs |
A list of transcription factors (TFs) to use as the starting point for network exploration. |
depth |
Integer value specifying the number of layers to extend the TF network from the selected TFs. For example, if depth=2, the target genes of selected_tfs are shown, and additional target genes are shown for TFs that are targets of the original selected_tfs. |
target_type |
The type of target genes to include in the output. Options are "positive" (genes with expression positively correlated with TFs), "negative" (genes with expression negatively correlated with TFs), or "both" (default, includes all targets). |
use_regulons |
Logical flag indicating whether to use regulons (default = TRUE) or the entire TF network for target gene discovery. |
wgcna_name |
Character string specifying the name of the WGCNA experiment. This should be stored in the @misc slot of the Seurat object. |
This function retrieves direct and extended targets of a set of TFs based on the regulatory network stored in the Seurat object. The depth parameter controls how many layers of TF-target interactions to explore, while the target_type parameter allows filtering based on correlation direction. The use_regulons flag specifies whether to use regulon data, which may provide a more confident set of interactions, or the full TF network.
A data frame containing the TF-target interactions at each specified depth level, with additional information such as regulatory score, correlation, and depth.
GetTOM
GetTOM(seurat_obj, wgcna_name = NULL)GetTOM(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetWGCNAGenes
GetWGCNAGenes(seurat_obj, wgcna_name = NULL)GetWGCNAGenes(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
GetWGCNAParams
GetWGCNAParams(seurat_obj, wgcna_name = NULL)GetWGCNAParams(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
Construct a unified network plot comprising hub genes for multiple modules.
HubGeneNetworkPlot( seurat_obj, mods = "all", n_hubs = 6, n_other = 3, sample_edges = TRUE, edge_prop = 0.5, return_graph = FALSE, edge.alpha = 0.25, vertex.label.cex = 0.5, hub.vertex.size = 4, other.vertex.size = 1, wgcna_name = NULL, ... )HubGeneNetworkPlot( seurat_obj, mods = "all", n_hubs = 6, n_other = 3, sample_edges = TRUE, edge_prop = 0.5, return_graph = FALSE, edge.alpha = 0.25, vertex.label.cex = 0.5, hub.vertex.size = 4, other.vertex.size = 1, wgcna_name = NULL, ... )
seurat_obj |
A Seurat object |
mods |
Names of the modules to plot. If mods = "all", all modules are plotted. |
n_hubs |
The number of hub genes to plot for each module. |
n_other |
The number of non-hub genes to sample from each module |
edge_prop |
The proportion of edges in the graph to sample. |
return_graph |
logical determining whether we return the graph (TRUE) or plot the graph (FALSE) |
edge.alpha |
Scaling factor for the edge opacity |
vertex.label.cex |
The font size of the gene labels |
hub.vertex.size |
The size of the hub gene nodes |
other.vertex.size |
The size of the other gene nodes |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
HubGeneNetworkPlotHubGeneNetworkPlot
This function takes a Seurat object and constructs averaged 'metacells' based on neighboring cells in provided groupings, such as cluster or cell type.
MetacellsByGroups( seurat_obj, group.by = c("seurat_clusters"), ident.group = "seurat_clusters", k = 25, reduction = "pca", dims = NULL, assay = NULL, slot = "counts", layer = "counts", mode = "average", cells.use = NULL, min_cells = 100, max_shared = 15, target_metacells = 1000, max_iter = 5000, verbose = FALSE, wgcna_name = NULL )MetacellsByGroups( seurat_obj, group.by = c("seurat_clusters"), ident.group = "seurat_clusters", k = 25, reduction = "pca", dims = NULL, assay = NULL, slot = "counts", layer = "counts", mode = "average", cells.use = NULL, min_cells = 100, max_shared = 15, target_metacells = 1000, max_iter = 5000, verbose = FALSE, wgcna_name = NULL )
seurat_obj |
A Seurat object |
group.by |
A character vector of Seurat metadata column names representing groups for which metacells will be computed. |
k |
Number of nearest neighbors to aggregate. Default = 50 |
reduction |
A dimensionality reduction stored in the Seurat object. Default = 'pca' |
dims |
A vector represnting the dimensions of the reduction to use. Either specify the names of the dimensions or the indices. Default = NULL to include all dims. |
assay |
Assay to extract data for aggregation. Default = 'RNA' |
slot |
Slot to extract data for aggregation. Default = 'counts'. Slot is used with Seurat v4 instead of layer. |
layer |
Layer to extract data for aggregation. Default = 'counts'. Layer is used with Seurat v5 instead of slot. |
mode |
determines how to make gene expression profiles for metacells from their constituent single cells. Options are "average" or "sum". |
min_cells |
the minimum number of cells in a particular grouping to construct metacells |
max_shared |
the maximum number of cells to be shared across two metacells |
target_metacells |
the maximum target number of metacells to construct |
max_iter |
the maximum number of iterations in the metacells bootstrapping loop |
verbose |
logical indicating whether to print additional information |
wgcna_name |
name of the WGCNA experiment |
name |
A string appended to resulting metalcells. Default = 'agg' |
MetacellsByGroups merges transcriptomically similar cells into "metacells". Given a dimensionally-reduced representation of the input dataset, this algorithm first uses KNN to identify similar cells. A bootstrapped sampling procedure is then used to group together similar cells until convergence is reached. Importantly, this procedure is done in a context-specific manner based on the provided group.by parameters. Typically this means that metacells will be constructed separately for each biological replicate, cell type or cell state, disease condition, etc. The metacell representation is considerably less sparse than the original single-cell dataset, which is preferable for co-expression network analysis or othter analyses that rely on correlations.
seurat_obj with a metacell seurat_obj stored in the specified WGCNA experiment
Computes metaspots in a given Seurat object containing spatial transcriptomics data.
MetaspotsByGroups( seurat_obj, group.by = c("seurat_clusters"), ident.group = "seurat_clusters", assay = "Spatial", slot = "counts", layer = "counts", mode = "sum", min_spots = 50, wgcna_name = NULL )MetaspotsByGroups( seurat_obj, group.by = c("seurat_clusters"), ident.group = "seurat_clusters", assay = "Spatial", slot = "counts", layer = "counts", mode = "sum", min_spots = 50, wgcna_name = NULL )
group.by |
A character vector of Seurat metadata column names representing groups for which metacells will be computed. |
assay |
Assay to extract data for aggregation. Default = 'Spatial' |
slot |
Slot to extract data for aggregation. Default = 'counts' |
layer |
Layer to extract data for aggregation. Default = 'counts'. Layer is used with Seurat v5 instead of slot. |
mode |
determines how to make gene expression profiles for metacells from their constituent single cells. Options are "average" or "sum". |
min_spots |
the minimum number of spots in a particular grouping to construct metaspots |
wgcna_name |
name of the WGCNA experiment |
cur_seurat |
A Seurat object |
Computes eigengene-based connectivity (kME) based on module eigengenes and the feature expression in selected cell populations / spatial regions.
ModuleConnectivity( seurat_obj, group.by = NULL, group_name = NULL, corFnc = "bicor", corOptions = "use='p'", harmonized = TRUE, assay = NULL, slot = "data", layer = "data", sparse = TRUE, reassign_modules = TRUE, TOM_use = NULL, wgcna_name = NULL, ... )ModuleConnectivity( seurat_obj, group.by = NULL, group_name = NULL, corFnc = "bicor", corOptions = "use='p'", harmonized = TRUE, assay = NULL, slot = "data", layer = "data", sparse = TRUE, reassign_modules = TRUE, TOM_use = NULL, wgcna_name = NULL, ... )
seurat_obj |
A Seurat object |
group.by |
column in [email protected] containing grouping info, ie clusters or celltypes |
group_name |
name of the group(s) in group.by to use for kME calculation |
corFnc |
character string specifying the function to be used to calculate co-expression similarity. Defaults to bicor. Any function returning values |
corOptions |
character string specifying additional arguments to be passed to the function given by corFnc. Use "use = 'p', method = 'spearman'" to obtain Spearman correlation. Use "use = 'p'" to obtain Pearson correlation. |
harmonized |
logical determining whether to use harmonized MEs for kME calculation |
assay |
Assay in seurat_obj containing expression information. |
slot |
Slot in seurat_obj, default to normalized 'data' slot. |
sparse |
logical indicating whether or not to run the correlation using a sparse matrix. |
reassign_modules |
logical indicating whether or not to reassign genes to different co-expression modules if their kME value in the assigned module is negative. |
TOM_use |
name of the hdWGCNA experiment that contains the TOM which will be used to compute the intramodular degree of each gene. If the TOM is not found, this calculation will be skipped. |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
ModuleConnectivity computes the eigengene-based connectivity (kME) of each feature and each module. This is done by correlating the gene expression signal with the module eigengenes for each module. Features with high kME values have greater network connectivity within that module, and we can identify module hub genes by taking the top genes for each module by kME values.
We recommend using the group.by and group_name parameters that were previously used in the SetDatExpr function, so only the relevant cell populations / spatial regions are considered for computing kMEs.
Depending on the parameters for network analysis, sometimes a feature has a negative kME in the module that it was originally assigned. This discrepancy arises since the network construction is done on the metacell/metaspot matrix but the kME calculation is done on the cell/spot matrix. By default, we account for this by reassigning features with negative kMEs in their assigned module to the module that had the highest kME for that feature.
seurat_obj with the kMEs computed for the selected wgcna experiment
Plot Module Eigengene correlogram
ModuleCorrelogram( seurat_obj, MEs2 = NULL, features = "hMEs", order = "original", method = "ellipse", exclude_grey = TRUE, type = "upper", tl.col = "black", tl.srt = 45, sig.level = c(1e-04, 0.001, 0.01, 0.05), pch.cex = 0.7, col = NULL, ncolors = 200, wgcna_name = NULL, wgcna_name2 = NULL, ... )ModuleCorrelogram( seurat_obj, MEs2 = NULL, features = "hMEs", order = "original", method = "ellipse", exclude_grey = TRUE, type = "upper", tl.col = "black", tl.srt = 45, sig.level = c(1e-04, 0.001, 0.01, 0.05), pch.cex = 0.7, col = NULL, ncolors = 200, wgcna_name = NULL, wgcna_name2 = NULL, ... )
seurat_obj |
A Seurat object |
features |
What to plot? Can select hMEs, MEs, scores, or average |
MECorrelogramMECorrelogram
Plot Module Eigengene correlogram
ModuleCorrNetwork( seurat_obj, cluster_col = NULL, exclude_grey = TRUE, features = "hMEs", reduction = "umap", cor_cutoff = 0.2, label_vertices = FALSE, edge_scale = 5, vertex_size = 15, niter = 100, vertex_frame = FALSE, wgcna_name = NULL )ModuleCorrNetwork( seurat_obj, cluster_col = NULL, exclude_grey = TRUE, features = "hMEs", reduction = "umap", cor_cutoff = 0.2, label_vertices = FALSE, edge_scale = 5, vertex_size = 15, niter = 100, vertex_frame = FALSE, wgcna_name = NULL )
seurat_obj |
A Seurat object |
ModuleCorrNetworkModuleCorrNetwork
Computes module eigengenes for co-expression modules
ModuleEigengenes( seurat_obj, group.by.vars = NULL, modules = NULL, vars.to.regress = NULL, scale.model.use = "linear", verbose = TRUE, assay = NULL, pc_dim = 1, wgcna_name = NULL, ... )ModuleEigengenes( seurat_obj, group.by.vars = NULL, modules = NULL, vars.to.regress = NULL, scale.model.use = "linear", verbose = TRUE, assay = NULL, pc_dim = 1, wgcna_name = NULL, ... )
seurat_obj |
A Seurat object |
group.by.vars |
groups to harmonize by |
modules |
table containing module / gene assignments, as in GetModules(seurat_obj). |
vars.to.regress |
character vector of variables in [email protected] to regress when running ScaleData |
scale.model.use |
model to scale data when running ScaleData choices are "linear", "poisson", or "negbinom" |
verbose |
logical indicating whether to print messages |
assay |
Assay in seurat_obj to compute module eigengenes. Default is DefaultAssay(seurat_obj) |
pc_dim |
Which PC to use as the module eigengene? Default to 1. |
wgcna_name |
name of the WGCNA experiment |
ModuleEigengenes summarizes the gene expression signatures of entire co-expression modules. This is done by performing singular value decomposition (SVD) on a subset of the scaled expression matrix containing only features assigned to each module. The module eigengene (ME), defined as the first dimension of the SVD matrix, retains the most variation, and we use this vector as a summary of gene expression for the whole module.
The module gene expression matrix is first scaled using the Seurat ScaleData function. The user can optionally adjust for covariates of interest in this step using the vars.to.regress parameter. Additionally, the module eigengenes themselves can be adjusted for technical biases such as sequencing batch, dataset of origin, or other factors using the Harmony algorithm with the group.by.vars parameter.
seurat_obj with the module eigengenes computed for the selected wgcna experiment
Computes a module score for each co-expression module using Seurat AddModuleScore or UCell.
ModuleExprScore( seurat_obj, n_genes = 25, method = "Seurat", wgcna_name = NULL, ... )ModuleExprScore( seurat_obj, n_genes = 25, method = "Seurat", wgcna_name = NULL, ... )
seurat_obj |
A Seurat object |
n_genes |
the number of genes to use for each module, ranked by kME. Setting n_genes = 'all' uses all of the genes in a module |
method |
selected method for module scoring, valid choices are "Seurat" or "UCell" |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
ModuleExprScore provides an alternative function to ModuleEigengenes for summarizing the expression level of each module. The user can choose between Seurat AddModuleScore or UCell using the method parameter.
seurat_obj with module scores computed for the selected wgcna experiment
Plot module eigengenes as a FeaturePlot
ModuleFeaturePlot( seurat_obj, module_names = NULL, wgcna_name = NULL, reduction = "umap", features = "hMEs", order_points = TRUE, restrict_range = TRUE, point_size = 0.5, alpha = 1, label_legend = FALSE, ucell = FALSE, raster = FALSE, raster_dpi = 500, raster_scale = 1, plot_ratio = 1, title = TRUE )ModuleFeaturePlot( seurat_obj, module_names = NULL, wgcna_name = NULL, reduction = "umap", features = "hMEs", order_points = TRUE, restrict_range = TRUE, point_size = 0.5, alpha = 1, label_legend = FALSE, ucell = FALSE, raster = FALSE, raster_dpi = 500, raster_scale = 1, plot_ratio = 1, title = TRUE )
seurat_obj |
A Seurat object |
features |
What to plot? Can select hMEs, MEs, scores, or average |
order |
TRUE, FALSE, or "shuffle" are valid options |
ModuleFeaturePlotModuleFeaturePlot
Visualizes the top hub genes for selected modules as a circular network plot with one inner circle and one outer circle.
ModuleNetworkPlot( seurat_obj, n_inner = 10, n_outer = 15, n_conns = 500, mods = "all", outdir = "ModuleNetworks", wgcna_name = NULL, plot_size = c(6, 6), edge.alpha = 0.25, edge.width = 1, vertex.label.cex = 1, vertex.size = 6, ... )ModuleNetworkPlot( seurat_obj, n_inner = 10, n_outer = 15, n_conns = 500, mods = "all", outdir = "ModuleNetworks", wgcna_name = NULL, plot_size = c(6, 6), edge.alpha = 0.25, edge.width = 1, vertex.label.cex = 1, vertex.size = 6, ... )
seurat_obj |
A Seurat object |
n_inner |
Number of genes to plot on the inner circle |
n_outer |
Number of genes to plot on the outer circle. |
n_conns |
Number of gene-gene co-expression connections to plot, sorted by the strongest connections. |
mods |
Names of the modules to plot. If mods = "all", all modules are plotted. |
outdir |
The directory where the plots will be stored. |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
plot_size |
A vector containing the width and height of the network plots. example: c(5,5) |
edge.alpha |
value between 0 and 1 determining the alpha (transparency) scaling factor for the network edges |
edge.width |
value determining the width of the network edges |
vertex.label.cex |
vertex label font size |
vertex.size |
vertex size |
Computes module preservation statistics in a query dataset for a given reference dataset
ModulePreservation( seurat_obj, seurat_ref, name, n_permutations = 500, parallel = FALSE, seed = 12345, gene_mapping = NULL, genome_ref_col = NULL, genome_query_col = NULL, return_raw = FALSE, wgcna_name = NULL, wgcna_name_ref = NULL, ... )ModulePreservation( seurat_obj, seurat_ref, name, n_permutations = 500, parallel = FALSE, seed = 12345, gene_mapping = NULL, genome_ref_col = NULL, genome_query_col = NULL, return_raw = FALSE, wgcna_name = NULL, wgcna_name_ref = NULL, ... )
seurat_obj |
A Seurat object |
seurat_ref |
A Seurat object serving as the reference for the module preservation analysis |
name |
The name to give the module preservation analysis. |
n_permutations |
Number of permutations for the module preservation test. |
parallel |
logical determining whether to run preservation analysis in parallel |
seed |
random seed for the permutation analysis. |
gene_mapping |
a dataframe containing gene name mappings between the query and the reference dataset. One column should have the gene name in the query dataset, and anotehr column should have the corresponding gene name in the reference dataset. |
genome_ref_col |
the column name containing the gene names for the reference dataset |
genome_query_col |
the column name containing the gene names for the query dataset |
return_raw |
if TRUE, returns the module preservation statistics, else returns seurat_obj with the stats added to the hdWGCNA experiment. |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
wgcna_name_ref |
The name of the hdWGCNA experiment in the seurat_ref@misc slot |
ModulePreservation performs a statistical test to assess the preservation of co-expression modules identified in one dataset in an independent dataset. This method is originally described by Langfelder et al. in the 2011 paper "Is My Network Module Preserved and Reproducible?". This method can be used to assess biological differences in networks, as well as technical differences / reproducibility across different batches.
Computes module preservation statistics in a query dataset for a given reference dataset
ModulePreservationNetRep( seurat_query, seurat_ref, name, n_permutations = 10000, n_threads = 8, gene_mapping = NULL, genome_ref_col = NULL, genome_query_col = NULL, TOM_use = NULL, ref_power = 1, query_power = 1, wgcna_name = NULL, wgcna_name_ref = NULL, ... )ModulePreservationNetRep( seurat_query, seurat_ref, name, n_permutations = 10000, n_threads = 8, gene_mapping = NULL, genome_ref_col = NULL, genome_query_col = NULL, TOM_use = NULL, ref_power = 1, query_power = 1, wgcna_name = NULL, wgcna_name_ref = NULL, ... )
seurat_query |
A Seurat object |
seurat_ref |
A Seurat object serving as the reference for the module preservation analysis |
name |
The name to give the module preservation analysis. |
n_permutations |
Number of permutations for the module preservation test. |
n_threads |
Number of parallel threads to use for the module preservation test |
gene_mapping |
a dataframe containing gene name mappings between the query and the reference dataset. One column should have the gene name in the query dataset, and anotehr column should have the corresponding gene name in the reference dataset. |
genome_ref_col |
the column name containing the gene names for the reference dataset |
genome_query_col |
the column name containing the gene names for the query dataset |
TOM_use |
The name of the hdWGCNA experiment containing the TOM that will be used for plotting |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
wgcna_name_ref |
The name of the hdWGCNA experiment in the seurat_ref@misc slot |
ModulePreservationNetRep performs a statistical test to assess the preservation of co-expression modules identified in one dataset in an independent dataset using the NetRep implementation rather than the WGCNA implementation. This method is originally described by Langfelder et al. in the 2011 paper "Is My Network Module Preserved and Reproducible?". The NetRep implementation of the module preservation test is described by Ritchie et al. in the 2016 paper "A Scalable Permutation Approach Reveals Replication and Preservation Patterns of Networks Modules in Large Datasets" This method can be used to assess biological differences in networks, as well as technical differences / reproducibility across different batches. Note that the outputs of ModulePreservation and ModulePreservationNetRep are not identical. This function requires separate installation of the NetRep package, which is not directly included as a dependency in hdWGCNA.
A Seurat Object containing the module preservation statistics from NetRep.
Plots the expression level (module eigengene) of each co-expression module for different groups as a radar plot.
ModuleRadarPlot( seurat_obj, group.by = NULL, barcodes = NULL, combine = TRUE, ncol = 4, features = "hMEs", wgcna_name = NULL, fill = TRUE, draw.points = FALSE, ... )ModuleRadarPlot( seurat_obj, group.by = NULL, barcodes = NULL, combine = TRUE, ncol = 4, features = "hMEs", wgcna_name = NULL, fill = TRUE, draw.points = FALSE, ... )
seurat_obj |
A Seurat object |
group.by |
the column name of the selected comparison in the DMEs dataframe |
barcodes |
A list of barcodes from colnames(seurat_obj) which will be used to subset the data before plotting. |
combine |
logical indicating whether or not to combine plots using patchwork |
ncol |
The number of columns for the combined plot if patchwork is being used |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
... |
additional parameters for ggradar |
ModuleRadarPlot visualizes the expression level (module eigengene, ME) of each co-expression module for different groups in a radial coordinate system. The ME for each module is averaged for each group, scaled, and then is plotted radially. The resulting plots help us to interpret which cell groups (clusters, cell types, etc) are expressing each module.
ggplot object containing the ModuleRadarPlot
This function visualizes the regulatory network between gene modules as a heatmap, where each cell represents the regulatory score between a source and target module. The heatmap can display either positive, negative, or delta (positive minus negative) regulatory scores. Optionally, a dendrogram can be plotted to cluster modules based on their regulatory interactions.
ModuleRegulatoryHeatmap( seurat_obj, feature = "delta", TFs_only = TRUE, dendrogram = TRUE, coord_fixed = TRUE, max_val = 1, min_val_label = 3, high_color = "orange2", mid_color = "white", low_color = "dodgerblue", wgcna_name = NULL )ModuleRegulatoryHeatmap( seurat_obj, feature = "delta", TFs_only = TRUE, dendrogram = TRUE, coord_fixed = TRUE, max_val = 1, min_val_label = 3, high_color = "orange2", mid_color = "white", low_color = "dodgerblue", wgcna_name = NULL )
seurat_obj |
A Seurat object containing single-cell data and WGCNA results. |
feature |
A character string specifying the type of regulatory score to plot. Options are 'positive' (positive regulatory score), 'negative' (negative regulatory score), or 'delta' (difference between positive and negative scores). Default is 'delta'. |
TFs_only |
Logical; if TRUE (default), only transcription factor (TF) genes are included in the heatmap. If FALSE, all genes are considered in the regulatory network. |
dendrogram |
Logical; if TRUE (default), a dendrogram is added to the heatmap to cluster modules based on their regulatory interactions. Default is TRUE. |
coord_fixed |
Logical; if TRUE (default), aspect ratio in x and y axes are equal. Default is TRUE. |
max_val |
Numeric; sets the maximum absolute value for the regulatory score. Any values exceeding this threshold are capped. Default is 1. |
min_val_label |
Numeric; the minimum number of interactions required for a label to be displayed on a heatmap cell. Default is 3. |
high_color |
Character string; the color representing high regulatory scores in the heatmap. Default is 'orange2'. |
mid_color |
Character string; the color representing intermediate regulatory scores in the heatmap. Default is 'white'. |
low_color |
Character string; the color representing low regulatory scores in the heatmap. Default is 'dodgerblue'. |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
The function visualizes the regulatory network between gene modules by plotting regulatory scores as a heatmap. Each cell in the heatmap represents the regulatory interaction between a source module (columns) and a target module (rows). The color of the cell represents the magnitude and direction (positive or negative) of the regulatory score. Users can choose to plot positive, negative, or delta scores and can adjust the color gradient and score thresholds. A dendrogram can be added to cluster modules based on their regulatory patterns, and labels can be shown for cells with a sufficient number of interactions.
A ggplot2 object visualizing the module regulatory network as a heatmap, which can be
further customized or displayed using plot().
Summarizes Transcription Factor regulatory networks across co-expression modules.
ModuleRegulatoryNetwork(seurat_obj, TFs_only = TRUE, wgcna_name = NULL)ModuleRegulatoryNetwork(seurat_obj, TFs_only = TRUE, wgcna_name = NULL)
seurat_obj |
A Seurat object containing the single-cell data and WGCNA results. |
TFs_only |
Logical; if TRUE (default), only transcription factor (TF) genes are included in the regulatory network. If FALSE, the network includes all genes. |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
This function summarizes transcription factor regulatory networks across modules to infer module-module relationships. The number of directed TF links across modules are counted and normalized. The strength of these links from the XGBoost model are also tracked.
A data frame with the following columns:
source |
The source module in the regulatory interaction. |
target |
The target module in the regulatory interaction. |
n_pos |
The number of positive regulatory links from the source module to the target module. |
sum_pos |
The sum of the gain values for the positive links. |
n_neg |
The number of negative regulatory links from the source module to the target module. |
sum_neg |
The sum of the gain values for the negative links. |
mean_pos |
The average gain of the positive links. |
mean_neg |
The average gain of the negative links. |
score_pos |
The number of positive links normalized by the number of TFs in the source module. |
score_neg |
The number of negative links normalized by the number of TFs in the source module. |
This function visualizes the regulatory network between gene modules from a Seurat object. The plot displays transcription factor (TF) regulatory interactions between modules, with edges representing positive or negative regulatory links.
ModuleRegulatoryNetworkPlot( seurat_obj, feature = "delta", TFs_only = TRUE, layout = "umap", umap_background = FALSE, max_val = 1, cutoff = 0, focus_source = NULL, focus_target = NULL, loops = TRUE, label_modules = TRUE, high_color = "orange2", mid_color = "white", low_color = "dodgerblue", wgcna_name = NULL, ... )ModuleRegulatoryNetworkPlot( seurat_obj, feature = "delta", TFs_only = TRUE, layout = "umap", umap_background = FALSE, max_val = 1, cutoff = 0, focus_source = NULL, focus_target = NULL, loops = TRUE, label_modules = TRUE, high_color = "orange2", mid_color = "white", low_color = "dodgerblue", wgcna_name = NULL, ... )
seurat_obj |
A Seurat object containing single-cell data and WGCNA results. |
feature |
A character string specifying the type of regulatory score to plot. Options are 'positive' (positive regulatory score), 'negative' (negative regulatory score), or 'delta' (difference between positive and negative scores). Default is 'delta'. |
TFs_only |
Logical; if TRUE (default), only transcription factor (TF) genes are included in the plot. If FALSE, all genes are considered in the regulatory network. |
layout |
A character string specifying the layout for the plot. Default is 'umap', which
arranges the modules according to UMAP coordinates. Other layout options from |
umap_background |
Logical; if TRUE, the UMAP of module eigengenes is plotted in the
background (if |
max_val |
Numeric; sets the maximum absolute value for the regulatory score. Any values exceeding this threshold are capped. Default is 1. |
cutoff |
Numeric; edges with absolute regulatory scores below this value are excluded from the plot. Default is 0. |
focus_source |
Character vector; optionally restricts the plot to only show regulatory links from specified source modules. Default is NULL (all modules included). |
focus_target |
Character vector; optionally restricts the plot to only show regulatory links targeting specified modules. Default is NULL (all modules included). |
loops |
Logical; if TRUE (default), loops (self-regulatory connections) are shown in the plot. |
label_modules |
Logical; if TRUE (default), module names are displayed as labels in the plot. |
high_color |
Character string; the color representing high regulatory scores in the color gradient. Default is 'orange2'. |
mid_color |
Character string; the color representing intermediate regulatory scores in the color gradient. Default is 'white'. |
low_color |
Character string; the color representing low regulatory scores in the color gradient. Default is 'dodgerblue'. |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
... |
Additional arguments passed to the |
The function visualizes the regulatory network between gene modules by plotting transcription factor regulatory interactions. Positive and negative regulatory scores are displayed as edges connecting nodes (modules), with node sizes proportional to the number of genes in each module. Users can customize the network layout (e.g., UMAP or other graph layouts), filter edges based on score thresholds, and highlight specific modules by using the focus parameters. Edge colors represent the strength and direction (positive or negative) of regulatory interactions, and loops can optionally be plotted to indicate self-regulation.
A ggplot2 object visualizing the regulatory network, which can be further customized or displayed
using plot().
Plots a ranked barplot of genes in a co-expression module by intramodular connectivity
ModuleTopologyBarplot( seurat_obj, mod, features = "kME", plot_color = NULL, alpha = TRUE, genes_order = NULL, return_genes = FALSE, wgcna_name = NULL )ModuleTopologyBarplot( seurat_obj, mod, features = "kME", plot_color = NULL, alpha = TRUE, genes_order = NULL, return_genes = FALSE, wgcna_name = NULL )
seurat_obj |
A Seurat object |
mod |
the name of the co-expression module to plot |
features |
specify the features to use in the barplot, 'kME' or 'degree' or 'weighted_degree' (degree scaled to 0 or 1) |
plot_color |
color used for the bar plot, default is the module's unique color |
alpha |
logical indicating whether or not to add opacity to the barplot based on the strength (kME or degree) |
genes_order |
a character vector of genes to plot in this specific order, this option will override the order_by parameter |
return_genes |
logical indicating whether or not to return |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
ModuleTopologyBarplot generates a barplot showing the intramodular connectivity of each gene in a specific co-expression module. Each bar in this plot represents a single gene, and they are ranked based on the strength of their connections within that particular module. A custom gene ordering can be supplied, which is helpful when comparing the module topologies side by side with more than one dataset.
ggplot object containing the ModuleTopologyBarplot
Plots a heatmap of the co-expression network topology of a given module.
ModuleTopologyHeatmap( seurat_obj, mod, matrix = "TOM", matrix_name = NULL, order_by = "kME", high_color = NULL, low_color = "white", raster = TRUE, raster_dpi = 200, plot_max = "q99", plot_min = 0, return_genes = FALSE, genes_order = NULL, TOM_use = NULL, datExpr_use = NULL, wgcna_name = NULL, ... )ModuleTopologyHeatmap( seurat_obj, mod, matrix = "TOM", matrix_name = NULL, order_by = "kME", high_color = NULL, low_color = "white", raster = TRUE, raster_dpi = 200, plot_max = "q99", plot_min = 0, return_genes = FALSE, genes_order = NULL, TOM_use = NULL, datExpr_use = NULL, wgcna_name = NULL, ... )
seurat_obj |
A Seurat object |
mod |
the name of the co-expression module to plot |
matrix |
specify which matrix to plot, use 'TOM' (topological overlap matrix) or 'Cor' (correlation matrix), or pass a custom square matrix where the rownames and colnames match the genes in this module |
matrix_name |
name of the matrix plotted that will be used as the label in the plot legend |
order_by |
order genes in this module by 'kME' (default) or by 'degree' (sum of all connections to this gene in the co-expression network) |
high_color |
color used for high values in the heatmap, default is the module's unique color |
low_color |
color used for low values in the heatmap, default is 'white' |
raster |
logical indicating whether or not to rasterise the plot |
raster_dpi |
dpi used for a rasterised plot |
plot_max |
maximum value to plot on the heatmap, can pass a numeric value or a string indicating the quantile ('q99' would be the 99th percentile) |
plot_min |
minimum value to plot on the heatmap, can pass a numeric value or a string indicating the quantile ('q1' would be the 1st percentile) |
return_genes |
logical indicating whether or not to return |
genes_order |
a character vector of genes to plot in this specific order, this option will override the order_by parameter |
TOM_use |
The name of the hdWGCNA experiment containing the TOM that will be used for plotting |
datExpr_use |
The name of the hdWGCNA experiment containing the datExpr that will be used for calculating the correlation matrix |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
ModuleTopologyHeatmap generates a triangular heatmap plot showing the network "topology" of a specific co-expression module. Each cell in the heatmap represents a gene-gene pair, and the the heatmap is colored by the strength of the connection between these two genes. By default the genes in this heatmap are ordered in both the rows and the columns based on their importance in the module, ranked either by eigengene-based connectivity (kME) or by network degree.
ggplot object containing the ModuleTopologyHeatmap
Correlates categorical and numeric variables with Module Eigengenes or hub-gene scores.
ModuleTraitCorrelation( seurat_obj, traits, group.by = NULL, features = "hMEs", cor_method = "pearson", subset_by = NULL, subset_groups = NULL, wgcna_name = NULL, ... )ModuleTraitCorrelation( seurat_obj, traits, group.by = NULL, features = "hMEs", cor_method = "pearson", subset_by = NULL, subset_groups = NULL, wgcna_name = NULL, ... )
seurat_obj |
A list of column names in the Seurat object's metadata that you wish to correlate with each module. Traits must be a categorical variable (not a character vector), or a numeric variable. |
features |
Which features to use to summarize each modules? Valid choices are hMEs, MEs, or scores |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
cor_meth |
Which method to use for correlation? Valid choices are pearson, spearman, kendall. |
ModuleTraitCorrelationModuleTraitCorrelation
Makes a igraph network plot using the module UMAP
ModuleUMAPPlot( seurat_obj, sample_edges = TRUE, edge_prop = 0.2, label_hubs = 5, edge.alpha = 0.25, vertex.label.cex = 0.5, label_genes = NULL, return_graph = FALSE, keep_grey_edges = TRUE, wgcna_name = NULL, ... )ModuleUMAPPlot( seurat_obj, sample_edges = TRUE, edge_prop = 0.2, label_hubs = 5, edge.alpha = 0.25, vertex.label.cex = 0.5, label_genes = NULL, return_graph = FALSE, keep_grey_edges = TRUE, wgcna_name = NULL, ... )
seurat_obj |
A Seurat object |
sample_edges |
logical determining whether we downsample edges for plotting (TRUE), or take the strongst edges. |
edge_prop |
proportion of edges to plot. If sample_edges=FALSE, the strongest edges are selected. |
label_hubs |
the number of hub genes to label in each module |
edge.alpha |
scaling factor for edge opacity |
vertex.label.cex |
font size for labeled genes |
return_graph |
logical determining whether to plot thr graph (FALSE) or return the igraph object (TRUE) |
keep_grey_edges |
logical determining whether to show edges between genes in different modules (grey edges) |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
ModuleUMAPPlotModuleUMAPPlot
Displays the top n TFs in a set of modules as a bar plot
MotifOverlapBarPlot( seurat_obj, n_tfs = 10, plot_size = c(5, 6), outdir = "MotifOverlaps/", motif_font = "helvetica_regular", module_names = NULL, wgcna_name = NULL )MotifOverlapBarPlot( seurat_obj, n_tfs = 10, plot_size = c(5, 6), outdir = "MotifOverlaps/", motif_font = "helvetica_regular", module_names = NULL, wgcna_name = NULL )
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
MotifOverlapBarPlotMotifOverlapBarPlot
This function scans the promoter regions of protein-coding genes for transcription factor (TF) motifs.
It extracts promoter sequences using an Ensembl database (EnsDb) and then searches these sequences
for TF binding motifs using position frequency matrices (PFMs). The Seurat object is updated with a matrix
of motif-gene matches, a list of target genes for each TF, and additional motif information.
MotifScan(seurat_obj, pfm, EnsDb, species_genome, wgcna_name = NULL)MotifScan(seurat_obj, pfm, EnsDb, species_genome, wgcna_name = NULL)
seurat_obj |
A Seurat object that will be updated with motif scan results. |
pfm |
A list of position frequency matrices (PFMs), such as those from the JASPAR2020 database. |
EnsDb |
An Ensembl database object (e.g., |
species_genome |
A character string specifying the genome version (e.g., "hg38" for human or "mm10" for mouse). |
wgcna_name |
A character string specifying the name of the WGCNA experiment to associate with the motif data (optional).
If NULL, the active WGCNA experiment in |
The MotifScan function performs the following steps:
It extracts promoter regions (typically 2 kb upstream of the transcription start site) of protein-coding genes from the provided EnsDb.
It uses the motifmatchr package to search these promoters for TF motifs, using the input PFMs.
The function returns the Seurat object updated with several key pieces of information:
A motif-gene match matrix indicating the presence or absence of each motif in the promoter of each gene.
A list of target genes for each TF based on motif presence.
A summary of motifs, including the number of target genes for each TF.
This data is stored in the seurat_obj's metadata and can be used for downstream analysis, such as regulatory network inference.
A modified Seurat object containing the results of the motif scan, including:
seurat_obj@misc$motif_matrix: A binary matrix indicating motif matches for each gene.
seurat_obj@misc$motif_info: A data frame containing motif names, IDs, and the number of target genes.
seurat_obj@misc$motif_targets: A list of genes targeted by each motif.
seurat_obj@misc$pfm: The original PFMs used for the motif scan.
Wrapper function to run Seurat's NormalizeData function on the metacell object.
NormalizeMetacells(seurat_obj, wgcna_name = NULL, ...)NormalizeMetacells(seurat_obj, wgcna_name = NULL, ...)
seurat_obj |
A Seurat object |
Plots the results from OverlapModulesDEGs as a bar plot
OverlapBarPlot( overlap_df, plot_var = "odds_ratio", logscale = FALSE, neglog = FALSE, label_size = 2, ... )OverlapBarPlot( overlap_df, plot_var = "odds_ratio", logscale = FALSE, neglog = FALSE, label_size = 2, ... )
overlap_df |
the Module/DEG overlap table from OverlapModulesDEGs |
plot_var |
the name of the overlap statistic to plot |
logscale |
logical controlling whether to plot the result on a log scale, useful for odds ratio |
neglog |
logical controlling wehether to plot the result as a negative log, useful for p-value / FDR |
label_size |
the size of the module labels in the bar plot |
OverlapBarPlotOverlapBarPlot
Makes barplots from Enrichr data
OverlapDotPlot( overlap_df, plot_var = "odds_ratio", logscale = TRUE, neglog = FALSE, plot_significance = TRUE, ... )OverlapDotPlot( overlap_df, plot_var = "odds_ratio", logscale = TRUE, neglog = FALSE, plot_significance = TRUE, ... )
overlap_df |
the Module/DEG overlap table from OverlapModulesDEGs |
plot_var |
the name of the overlap statistic to plot |
logscale |
logical controlling whether to plot the result on a log scale, useful for odds ratio |
neglog |
logical controlling wehether to plot the result as a negative log, useful for p-value / FDR |
plot_significance |
logical controlling whether to plot the significance levels on top of the dots |
OverlapDotPlotOverlapDotPlot
Performs Fisher's Exact Test for overlap between DEGs and hdWGCNA modules.
OverlapModulesDEGs( seurat_obj, deg_df, fc_cutoff = 0.5, group_col = "cluster", wgcna_name = NULL, ... )OverlapModulesDEGs( seurat_obj, deg_df, fc_cutoff = 0.5, group_col = "cluster", wgcna_name = NULL, ... )
seurat_obj |
A Seurat object |
deg_df |
DEG table formatted like the output from Seurat's FindMarkers |
fc_cutoff |
log fold change cutoff for DEGs to be included in the overlap test |
group_col |
the name of the column in deg_df containing the cell grouping information |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
Overlap modules with TF target genes
OverlapModulesMotifs(seurat_obj, wgcna_name = NULL)OverlapModulesMotifs(seurat_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
OverlapModulesDEGsOverlapModulesDEGs
Plot WGCNA dendrogram
PlotDendrogram( seurat_obj, groupLabels = "Module colors", wgcna_name = NULL, dendroLabels = FALSE, hang = 0.03, addGuide = TRUE, guideHang = 0.05, main = "", ... )PlotDendrogram( seurat_obj, groupLabels = "Module colors", wgcna_name = NULL, dendroLabels = FALSE, hang = 0.03, addGuide = TRUE, guideHang = 0.05, main = "", ... )
seurat_obj |
A Seurat object |
PlotDendrogramPlotDendrogram
Function to visualize differential TF regulon activity between two groups of cells based on regulon scores. The plot shows the average log fold-change (logFC) for positive and negative regulon scores in a scatter plot, with the points colored by their associated module and optionally labeled with the most differentially active regulons.
PlotDifferentialRegulons( seurat_obj, dregs, n_label = 10, logfc_thresh = 0.1, lm = TRUE, wgcna_name = NULL )PlotDifferentialRegulons( seurat_obj, dregs, n_label = 10, logfc_thresh = 0.1, lm = TRUE, wgcna_name = NULL )
seurat_obj |
A Seurat object that contains the WGCNA experiment and TF regulon scores. |
dregs |
Dataframe output from the |
n_label |
Integer specifying the number of top up- and down-regulated regulons to label on the plot. If 'all', all significant regulons will be labeled. Default = 10. |
logfc_thresh |
Numeric threshold for labeling and annotating regulons based on logFC values. Default = 0.1. |
lm |
Logical indicating whether to plot a linear regression line for the logFC values of positive vs. negative regulons. Default = TRUE. |
wgcna_name |
The name of the WGCNA experiment in the |
This function generates a scatter plot where each point represents a TF regulon, with the x-axis showing the average log fold-change for positive regulon scores and the y-axis showing the average log fold-change for negative regulon scores. Points are colored by their module assignment, and the size of the points reflects the module eigengene correlation (kME) value of the TF.
Differentially expressed regulons can be highlighted, and the most significantly up- and down-regulated regulons can be labeled. Additional options allow adding a linear regression line and controlling label density based on logFC thresholds.
A ggplot object representing the differential regulon scatter plot.
Plotting function for the results of FindDMEs and FindAllDMEs
PlotDMEsLollipop( seurat_obj, DMEs, wgcna_name, group.by = NULL, comparison = NULL, pvalue, avg_log2FC = "avg_log2FC" )PlotDMEsLollipop( seurat_obj, DMEs, wgcna_name, group.by = NULL, comparison = NULL, pvalue, avg_log2FC = "avg_log2FC" )
seurat_obj |
A Seurat object |
DMEs |
dataframe output from FindDMEs or FindAllDMEs |
group.by |
the column name of the selected comparison in the DMEs dataframe |
comparison |
character vector or a list of character vectors containing the comparison in the DMEs dataframe |
pvalue |
p_value or fdr used for the comparison in the DMEs dataframe |
A ggplot object PlotDMEsLollipop
Plotting function for the results of FindDMEs and FindAllDMEs.
PlotDMEsVolcano( seurat_obj, DMEs, plot_labels = TRUE, mod_point_size = 4, label_size = 4, show_cutoff = TRUE, wgcna_name = NULL, xlim_range = NULL, ylim_range = NULL )PlotDMEsVolcano( seurat_obj, DMEs, plot_labels = TRUE, mod_point_size = 4, label_size = 4, show_cutoff = TRUE, wgcna_name = NULL, xlim_range = NULL, ylim_range = NULL )
seurat_obj |
A Seurat object containing the WGCNA analysis in the @misc slot. |
DMEs |
A dataframe output from FindDMEs or FindAllDMEs containing DME results. |
plot_labels |
Logical, determines whether to plot the module labels on the volcano plot. Default is TRUE. |
mod_point_size |
Numeric, the size of the points on the volcano plot. Default is 4. |
label_size |
Numeric, the size of the module labels on the plot. Default is 4. |
show_cutoff |
Logical, determines whether to plot the significance cutoff. Set this to FALSE if using facet_wrap. Default is TRUE. |
wgcna_name |
Character, the name of the hdWGCNA experiment in the |
xlim_range |
A numeric vector of length 2 specifying the x-axis limits for the log2 fold change. Default is NULL, which automatically calculates limits based on the data. |
ylim_range |
A numeric vector of length 2 specifying the y-axis limits for the -log10(p-value). Default is NULL, which automatically calculates limits based on the data. |
This function generates a volcano plot for differential module expression (DME) analysis results.
It can handle both two-group comparisons (using the output of FindDMEs) and one-vs-all comparisons
(using the output of FindAllDMEs).
A ggplot object containing the volcano plot for the DME results.
# Example usage: # Assuming `seurat_obj` is your Seurat object and `DMEs` is the output from FindDMEs PlotDMEsVolcano(seurat_obj, DMEs, wgcna_name = "MG")# Example usage: # Assuming `seurat_obj` is your Seurat object and `DMEs` is the output from FindDMEs PlotDMEsVolcano(seurat_obj, DMEs, wgcna_name = "MG")
Plotting function to show genes by kME value in each module
PlotKMEs( seurat_obj, n_hubs = 10, text_size = 2, ncol = 5, plot_widths = c(3, 2), wgcna_name = NULL )PlotKMEs( seurat_obj, n_hubs = 10, text_size = 2, ncol = 5, plot_widths = c(3, 2), wgcna_name = NULL )
seurat_obj |
A Seurat object |
n_hubs |
number of hub genes to display |
text_size |
controls the size of the hub gene text |
ncol |
number of columns to display individual plots |
plot_widths |
the relative width between the kME rank plot and the hub gene text |
wgcna_name |
the name of the WGCNA experiment in the seurat object |
An Internal function for PlotDMEsLollipop to Plotting function for the results of FindDMEs and FindAllDMEs
PlotLollipop(modules, cur_DMEs, pvalue, avg_log2FC = "avg_log2FC")PlotLollipop(modules, cur_DMEs, pvalue, avg_log2FC = "avg_log2FC")
pvalue |
p_value or fdr used for the comparison in the DMEs dataframe |
seurat_obj |
A Seurat object |
DMEs |
dataframe output from FindDMEs or FindAllDMEs |
group.by |
the column name of the selected comparison in the DMEs dataframe |
comparison |
character vector or a list of character vectors containing the comparison in the DMEs dataframe |
A ggplot object
plot_list <- PlotLollipop(modules, DMEs, cur_title= c("Group1_vs_Group2"), pvalue, avg_log2FC = 'avg_log2FC')plot_list <- PlotLollipop(modules, DMEs, cur_title= c("Group1_vs_Group2"), pvalue, avg_log2FC = 'avg_log2FC')
Plotting function for Module Preservation statistics
PlotModulePreservation( seurat_obj, name, statistics = "summary", plot_labels = TRUE, label_size = 4, mod_point_size = 4, wgcna_name = NULL )PlotModulePreservation( seurat_obj, name, statistics = "summary", plot_labels = TRUE, label_size = 4, mod_point_size = 4, wgcna_name = NULL )
seurat_obj |
A Seurat object |
name |
The name of the module preservation analysis to plot given in ModulePreservation |
statistics |
Which module preservation statistics to plot? Choices are summary, all, or a custom list |
plot_labels |
logical determining whether to plot the module labels |
label_size |
the size of the module labels |
mod_point_size |
the size of the points in each plot |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
This function creates a scatter plot showing the module preservation statistics for each module compared to the size of the module (number of genes).
Plots a ranked lollipop plot of co-expression modules based on the results of module preservation analysis.
PlotModulePreservationLollipop( seurat_obj, name, features = NULL, fdr = TRUE, wgcna_name = NULL )PlotModulePreservationLollipop( seurat_obj, name, features = NULL, fdr = TRUE, wgcna_name = NULL )
seurat_obj |
A Seurat object |
name |
The name to give the module preservation analysis. |
features |
The name of the module preservation features to plot. |
fdr |
logical indicating whether or not to plot FDR-corrected p-values |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
PlotModulePreservationLollipop generates a lollipop plot showing module preservation results. If the module preservation test was performed using the WGCNA method, the statistic that will be shown is the Z-summary preservation statistic. If the analysis was performed using NetRep, then the statistic that will be shown is the FDR corrected averaged p-values from the module preservation permutation test.
ggplot object containing the PlotModulePreservationLollipop
Plotting function for Module Preservation statistics
PlotModuleTraitCorrelation( seurat_obj, high_color = "red", mid_color = "grey90", low_color = "blue", label = NULL, label_symbol = "stars", plot_max = NULL, text_size = 2, text_color = "black", text_digits = 3, combine = TRUE, wgcna_name = NULL )PlotModuleTraitCorrelation( seurat_obj, high_color = "red", mid_color = "grey90", low_color = "blue", label = NULL, label_symbol = "stars", plot_max = NULL, text_size = 2, text_color = "black", text_digits = 3, combine = TRUE, wgcna_name = NULL )
seurat_obj |
A Seurat object |
high_color |
color for positive correlation |
mid_color |
color for zero correlation |
low_color |
color for negative correlation |
label |
logical determining whether to add p-val label in each cell of the heatmap |
label_symbol |
show the labels as 'stars' or as 'numeric' |
plot_max |
maximum value of correlation to show on the colorbar |
text_size |
size of the labels |
text_color |
color of the text labels |
text_digits |
how many digits to show in the text labels |
combine |
logical determining whether to plot as one combined plot (TRUE) or to return individual plots as a list (FALSE) |
Plots module eigengene dynamics over a pseudotime trajectory.
PlotModuleTrajectory( seurat_obj, pseudotime_col = "pseudotime", n_bins = 20, harmonized = TRUE, ncol = 4, point_size = 1, line_size = 1, se = TRUE, group_colors = NULL, wgcna_name = NULL )PlotModuleTrajectory( seurat_obj, pseudotime_col = "pseudotime", n_bins = 20, harmonized = TRUE, ncol = 4, point_size = 1, line_size = 1, se = TRUE, group_colors = NULL, wgcna_name = NULL )
seurat_obj |
A Seurat object |
pseudotime_col |
name of the column in [email protected] containing pseudotime information. Multiple names can be passed to plot multiple trajectories simultaneously. |
n_bins |
number of pseudotime bins/windows used to smooth the MEs |
harmonized |
logical determining whether or not to use the harmonized MEs |
point_size |
size of the points in the plot |
line_size |
width of the lines in the plot |
se |
logical determining whether or not to show the standard error on the plot |
group_colors |
optional list of colors to differentiate multiple pseudotime trajectories. Must be the same length as pseudotime_col |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
n_col |
number of columns for different modules in the plot |
Plot Soft Power Threshold results
PlotSoftPowers( seurat_obj, selected_power = NULL, point_size = 5, text_size = 3, plot_connectivity = TRUE, wgcna_name = NULL )PlotSoftPowers( seurat_obj, selected_power = NULL, point_size = 5, text_size = 3, plot_connectivity = TRUE, wgcna_name = NULL )
seurat_obj |
A Seurat object |
selected_power |
power to highlight in the plots |
point_size |
the size of the points in the plot |
text_size |
the size of the text in the plot |
plot_connectivity |
logical indicating whether to plot the connectivity in addition to the scale free topplogy fit. |
wgcna_name |
The name of the WGCNA experiment in seurat_obj |
PlotSoftPowersPlotSoftPowers
Project a set of co-expression modules from a reference to a query dataset
ProjectModules( seurat_obj, seurat_ref = NULL, modules = NULL, group.by.vars = NULL, gene_mapping = NULL, genome1_col = NULL, genome2_col = NULL, overlap_proportion = 0.5, vars.to.regress = NULL, scale.model.use = "linear", wgcna_name = NULL, wgcna_name_proj = NULL, ... )ProjectModules( seurat_obj, seurat_ref = NULL, modules = NULL, group.by.vars = NULL, gene_mapping = NULL, genome1_col = NULL, genome2_col = NULL, overlap_proportion = 0.5, vars.to.regress = NULL, scale.model.use = "linear", wgcna_name = NULL, wgcna_name_proj = NULL, ... )
seurat_obj |
A Seurat object where the modules will be projected to |
seurat_ref |
A Seurat object containing the co-expression modules to be projected |
modules |
optionally provide a dataframe containing gene-module information to bypass seurat_ref |
group.by.vars |
groups to harmonize by |
gene_mapping |
dataframe to map gene names between genomes |
genome1_col |
column in gene_mapping containing the genes for seurat_ref (reference) |
genome2_col |
column in gene_mapping containing the genes for seurat_obj (query) |
overlap_proportion |
the proportion of genes that must be present in seurat_obj for a given module to be projected. Default = 0.5 (50% of genes) |
vars.to.regress |
character vector of variables in [email protected] to regress when running ScaleData |
scale.model.use |
model to scale data when running ScaleData choices are "linear", "poisson", or "negbinom" |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_ref@misc slot |
wgcna_name_proj |
The name of the hdWGCNA experiment to be created for the projected modules in seurat_obj |
ProjectModulesProjectModules
Reassigns features to different modules
ReassignModules( seurat_obj, harmonized = TRUE, features = NULL, new_modules = NULL, ignore = FALSE, auto_reassign = FALSE, wgcna_name = NULL )ReassignModules( seurat_obj, harmonized = TRUE, features = NULL, new_modules = NULL, ignore = FALSE, auto_reassign = FALSE, wgcna_name = NULL )
seurat_obj |
A Seurat object |
harmonized |
logical indicating whether or not to use harmonized MEs |
features |
character vector containing features for manual module reassignment, |
new_modules |
character vector containing modules to reassign the genes |
ignore |
logical indicating whether or not to ignore error message about reassigning non-grey features |
auto_reassign |
logical, automatically re-assign selected features to the module with the highest kME? |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
ReassignModules reassigns features with negative kMEs in their assigned module to the module that had the highest kME for that feature. Alternatively, this function can manually assign features to different modules, which can be helpful if certain genes of interest are assigned to the grey module. We generally do not advise reassigning features to new modules if they are in non-grey modules, but the user can do so at their own risk by setting ignore=TRUE.
seurat_obj with the an updated modules table for the selected wgcna experiment
Plots the top target genes within a specific TF regulon
RegulonBarPlot( seurat_obj, selected_tf, cutoff = 0.2, top_n = Inf, TFs_only = FALSE, high_color = "orange2", mid_color = "white", low_color = "dodgerblue", wgcna_name = NULL )RegulonBarPlot( seurat_obj, selected_tf, cutoff = 0.2, top_n = Inf, TFs_only = FALSE, high_color = "orange2", mid_color = "white", low_color = "dodgerblue", wgcna_name = NULL )
seurat_obj |
A Seurat object |
cutoff |
Cutoff for the edge weights, links below this value will not be included. |
top_n |
Number of top and bottom target genes to include in the plot. |
TFs_only |
Logical indicating whether or not to use only TFs in the plot or to use TFs and other genes. |
high_color |
Color corresponding to positive edge weights |
mid_color |
Color corresponding to edge weights close to 0 |
low_color |
Color corresponding to negative edge weights |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
selected_tfs |
A TF whose target genes will be shown |
RegulonBarPlot creates a bar plot showing the top target genes for a particular TF based on the TF regulatory network analysis. Target genes are ranked by the predicted interaction strength from XGBoost (Gain) multiplied by the sign of the correlation between the TF and the target gene.
ggplot object containing the RegulonBarPlot
Calculate expression scores for TF Regulons
RegulonScores( seurat_obj, target_type = "positive", cor_thresh = 0.05, exclude_grey_genes = TRUE, wgcna_name = NULL, ... )RegulonScores( seurat_obj, target_type = "positive", cor_thresh = 0.05, exclude_grey_genes = TRUE, wgcna_name = NULL, ... )
seurat_obj |
A Seurat object |
target_type |
Which types of TF target genes to compute scores for? "positive", "negative", or "both" |
cor_thresh |
threshold for TF-gene correlation for genes to be included in the regulon score |
exclude_grey_genes |
option to exclude genes that are in the grey module from the regulon scores |
wgcna_name |
name of the WGCNA experiment |
RegulonScores calculates expression signatures for each TF regulon using the UCell algorithm This function can calculate separate scores for TF regulons for target genes that are positively or negatively correlated with the TF, representing putative acivated or repressed genes. These scores conveniently summarize the expression levels of the entire TF regulon, similar to module eigengenes for the co-expression network analyssis.
seurat_obj with the TF Regulon Scores added
Reset the unique color for each hdWGCNA module
ResetModuleColors(seurat_obj, new_colors, wgcna_name = NULL)ResetModuleColors(seurat_obj, new_colors, wgcna_name = NULL)
seurat_obj |
A Seurat object |
new_colors |
a character vector containing the new colors |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
Reset the uname of each hdWGCNA module
ResetModuleNames( seurat_obj, new_name = "M", reset_levels = FALSE, wgcna_name = NULL )ResetModuleNames( seurat_obj, new_name = "M", reset_levels = FALSE, wgcna_name = NULL )
seurat_obj |
A Seurat object |
new_name |
string containing the base name to re-name the modules |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
Run Enrichr gene set enrichment tests on hdWGCNA modules
RunEnrichr( seurat_obj, dbs = c("GO_Biological_Process_2021", "GO_Cellular_Component_2021", "GO_Molecular_Function_2021"), max_genes = 100, wait = TRUE, wait_time = 5, wgcna_name = NULL, ... )RunEnrichr( seurat_obj, dbs = c("GO_Biological_Process_2021", "GO_Cellular_Component_2021", "GO_Molecular_Function_2021"), max_genes = 100, wait = TRUE, wait_time = 5, wgcna_name = NULL, ... )
seurat_obj |
A Seurat object |
dbs |
character vector of EnrichR databases |
max_genes |
Max number of genes to include per module, ranked by kME. |
wait |
logical indicating whether or not to wait some time between sending requests to the EnrichR server. |
wait_time |
the number of seconds to wait between sending requests to the EnrichR server. Value must be less than 60. |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
Run Enrichr gene set enrichment tests on hdWGCNA modules
RunEnrichrRegulons( seurat_obj, dbs = c("GO_Biological_Process_2021", "GO_Cellular_Component_2021", "GO_Molecular_Function_2021"), depth = 1, use_regulons = TRUE, min_genes = 5, wait = TRUE, wait_time = 5, wgcna_name = NULL, ... )RunEnrichrRegulons( seurat_obj, dbs = c("GO_Biological_Process_2021", "GO_Cellular_Component_2021", "GO_Molecular_Function_2021"), depth = 1, use_regulons = TRUE, min_genes = 5, wait = TRUE, wait_time = 5, wgcna_name = NULL, ... )
seurat_obj |
A Seurat object |
dbs |
character vector of EnrichR databases |
depth |
Include primary TF target genes (depth=1) or primary + secondary (depth=2) |
use_regulons |
Use the regulons (default=TRUE) or the full set of TF target genes? |
wait |
logical indicating whether or not to wait some time between sending requests to the EnrichR server. |
wait_time |
the number of seconds to wait between sending requests to the EnrichR server. Value must be less than 60. |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
max_genes |
Max number of genes to include per module, ranked by kME. |
Wrapper function to run harmony's RunHarmony function on the metacell object.
RunHarmonyMetacells(seurat_obj, ...)RunHarmonyMetacells(seurat_obj, ...)
seurat_obj |
A Seurat object |
Run UMAP on co-expression matrix using hub genes as features.
RunModuleUMAP( seurat_obj, n_hubs = 10, exclude_grey = TRUE, genes_use = NULL, wgcna_name = NULL, n_neighbors = 25, metric = "cosine", spread = 1, min_dist = 0.4, supervised = FALSE, ... )RunModuleUMAP( seurat_obj, n_hubs = 10, exclude_grey = TRUE, genes_use = NULL, wgcna_name = NULL, n_neighbors = 25, metric = "cosine", spread = 1, min_dist = 0.4, supervised = FALSE, ... )
seurat_obj |
A Seurat object |
n_hubs |
number of hub genes to use in the UMAP computation |
exclude_grey |
logical indicating whether to include grey module |
genes_use |
character vector of genes to use for the UMAP, must already be present in GetModules(seurat_obj) |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
... |
Additional parameters supplied to uwot::umap |
Wrapper function to run Seurat's RunPCA function on the metacell object.
RunPCAMetacells(seurat_obj, wgcna_name = NULL, ...)RunPCAMetacells(seurat_obj, wgcna_name = NULL, ...)
seurat_obj |
A Seurat object |
Wrapper function to run Seurat's RunUMAP function on the metacell object.
RunUMAPMetacells(seurat_obj, ...)RunUMAPMetacells(seurat_obj, ...)
seurat_obj |
A Seurat object |
Function to scale a numeric vector between 0 and 1.
scale01(x)scale01(x)
x |
numeric vector |
Wrapper function to run Seurat's ScaleData function on the metacell object.
ScaleMetacells(seurat_obj, wgcna_name = NULL, ...)ScaleMetacells(seurat_obj, wgcna_name = NULL, ...)
seurat_obj |
A Seurat object |
Select genes that will be used for co-expression network analysis
SelectNetworkGenes( seurat_obj, gene_select = "variable", fraction = 0.05, group.by = NULL, gene_list = NULL, assay = NULL, wgcna_name = NULL )SelectNetworkGenes( seurat_obj, gene_select = "variable", fraction = 0.05, group.by = NULL, gene_list = NULL, assay = NULL, wgcna_name = NULL )
seurat_obj |
A Seurat object |
fraction |
A numeric that determines the minimum cells that a gene must be expressed in order to be included. For example, fraction = 0.05 means that 5% of cells must express a gene (count > 0) for it to be included. |
gene_list |
A character string of gene names, only used if type = "custom" |
assay |
Assay in seurat_obj to compute module eigengenes. Default is DefaultAssay(seurat_obj) |
wgcna_name |
name of the WGCNA experiment |
type |
How to select genes? Select "variable", "fraction", "all", or "custom". |
SelectNetworkGenes allows us to specify the genes that will be used for co-expression network analysis. This function is called by SetupForWGCNA. By default, the variable features in VariableFeatures(seurat_obj) are used. A custom gene list can also be used with the gene_list parameter and setting gene_select="custom".
We can also identify genes that are expressed above 0 in a certain proportion of the dataset by settting gene_select='fraction'. For example, by setting fraction=0.1 and group.by='seurat_clusters', this function will identify the set of genes that are expressed in 10% of cells in at least one of the clusters.
SetActiveWGCNA
SetActiveWGCNA(seurat_obj, wgcna_name)SetActiveWGCNA(seurat_obj, wgcna_name)
seurat_obj |
A Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetAvgModuleExpr
SetAvgModuleExpr(seurat_obj, avg_mods, wgcna_name = NULL)SetAvgModuleExpr(seurat_obj, avg_mods, wgcna_name = NULL)
seurat_obj |
A Seurat object |
avg_mods |
dataframe storing the average expression of all genes in the same module |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
This function specifies the gene expression matrix for co-expression network analysis.
SetDatExpr( seurat_obj, group_name, use_metacells = TRUE, group.by = NULL, multi.group.by = NULL, multi_group_name = NULL, return_seurat = TRUE, assay = NULL, slot = "data", layer = "data", mat = NULL, features = NULL, wgcna_name = NULL, ... )SetDatExpr( seurat_obj, group_name, use_metacells = TRUE, group.by = NULL, multi.group.by = NULL, multi_group_name = NULL, return_seurat = TRUE, assay = NULL, slot = "data", layer = "data", mat = NULL, features = NULL, wgcna_name = NULL, ... )
seurat_obj |
A Seurat object |
group_name |
A string containing a group present in the provided group.by column or in the Seurat Idents. A character vector can be provided to select multiple groups at a time. |
use_metacells |
A logical determining if we use the metacells (TRUE) or the full expression matrix (FALSE) |
group.by |
A string containing the name of a column in the Seurat object with cell groups (clusters, cell types, etc). If NULL (default), hdWGCNA uses the Seurat Idents as the group. |
multi.group.by |
A string containing the name of a column in the Seurat object with groups for consensus WGCNA (dataset, sample, condition, etc) |
multi_group_name |
A string containing the name of a group present in the multi.group.by column. |
assay |
The name of the assay in the Seurat object |
slot |
Slot to extract data for aggregation. Default = 'counts'. Slot is used with Seurat v4 instead of layer. |
layer |
Layer to extract data for aggregation. Default = 'counts'. Layer is used with Seurat v5 instead of slot. |
mat |
A Matrix containing gene expression data. Supplying a matrix using this parameter ignores other options. This is almost exclusively used for pseudobulk analysis. |
features |
A list of features to use to override the features that have been previously set. |
wgcna_name |
A string containing the name of the WGCNA slot in seurat_obj@misc. Default = NULL which retrieves the currently active WGCNA data |
SetDatExpr is a critical function of the hdWGCNA pipeline that determines the gene expession matrix that will be used for network analysis. We typically use this function to select a cell type or group of cell types for network analysis using the group.by parameter, but we provide additional parameters for further customization.
SetDegrees
SetDegrees(seurat_obj, degree_df, wgcna_name = NULL)SetDegrees(seurat_obj, degree_df, wgcna_name = NULL)
seurat_obj |
A Seurat object |
degree_df |
dataframe containing gene module assignments |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetEnrichRegulonTable
SetEnrichrRegulonTable(seurat_obj, enrich_table, wgcna_name = NULL)SetEnrichrRegulonTable(seurat_obj, enrich_table, wgcna_name = NULL)
seurat_obj |
A Seurat object |
enrich_table |
dataframe storing the results of running enrichr |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetEnrichrTable
SetEnrichrTable(seurat_obj, enrich_table, wgcna_name = NULL)SetEnrichrTable(seurat_obj, enrich_table, wgcna_name = NULL)
seurat_obj |
A Seurat object |
enrich_table |
dataframe storing the results of running enrichr |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetMELoadings
SetMELoadings(seurat_obj, loadings, harmonized = TRUE, wgcna_name = NULL)SetMELoadings(seurat_obj, loadings, harmonized = TRUE, wgcna_name = NULL)
seurat_obj |
A Seurat object |
loadings |
named numeric vector with eigengene loadings |
harmonized |
logical indicating whether MEs have been harmonized |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetMEs
SetMEs(seurat_obj, MEs, harmonized = TRUE, wgcna_name = NULL)SetMEs(seurat_obj, MEs, harmonized = TRUE, wgcna_name = NULL)
seurat_obj |
A Seurat object |
MEs |
dataframe or matrix containing module eigengenes |
harmonized |
logical indicating whether MEs have been harmonized |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetMetacellObject
SetMetacellObject(seurat_obj, metacell_obj, wgcna_name = NULL)SetMetacellObject(seurat_obj, metacell_obj, wgcna_name = NULL)
seurat_obj |
A Seurat object |
metacell_obj |
metacell Seurat object |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetMetacellParams
SetMetacellParams(seurat_obj, params, wgcna_name = NULL)SetMetacellParams(seurat_obj, params, wgcna_name = NULL)
seurat_obj |
A Seurat object |
params |
list of WGCNA parameters |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetModulePreservation
SetModulePreservation(seurat_obj, mod_pres, mod_name, wgcna_name = NULL)SetModulePreservation(seurat_obj, mod_pres, mod_name, wgcna_name = NULL)
seurat_obj |
A Seurat object |
mod_name |
name of the module preservation test to store |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
mt_cor |
matrix of module-trait correlation results |
SetModules
SetModules(seurat_obj, modules, wgcna_name = NULL)SetModules(seurat_obj, modules, wgcna_name = NULL)
seurat_obj |
A Seurat object |
modules |
dataframe containing gene module assignments |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetModuleScores
SetModuleScores(seurat_obj, mod_scores, wgcna_name = NULL)SetModuleScores(seurat_obj, mod_scores, wgcna_name = NULL)
seurat_obj |
A Seurat object |
mod_scores |
dataframe storing the module expression scores |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetModuleTraitCorrelation
SetModuleTraitCorrelation(seurat_obj, mt_cor, wgcna_name = NULL)SetModuleTraitCorrelation(seurat_obj, mt_cor, wgcna_name = NULL)
seurat_obj |
A Seurat object |
mt_cor |
matrix of module-trait correlation results |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetModuleUMAP
SetModuleUMAP(seurat_obj, umap_df, wgcna_name = NULL)SetModuleUMAP(seurat_obj, umap_df, wgcna_name = NULL)
seurat_obj |
A Seurat object |
umap_df |
dataframe of UMAP coordinates |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetMotifMatrix
SetMotifMatrix(seurat_obj, tf_match)SetMotifMatrix(seurat_obj, tf_match)
seurat_obj |
A Seurat object |
tf_match |
matrix containing tf-promoter matches |
SetMotifMatrixSetMotifMatrix
SetMotifOverlap
SetMotifOverlap(seurat_obj, overlap_df, wgcna_name = NULL)SetMotifOverlap(seurat_obj, overlap_df, wgcna_name = NULL)
seurat_obj |
A Seurat object |
overlap_df |
dataframe containing motif-module overlap info |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetMotifs
SetMotifs(seurat_obj, motif_df)SetMotifs(seurat_obj, motif_df)
seurat_obj |
A Seurat object |
motif_df |
dataframe containing info about the motifs being analyzed |
SetMotifsSetMotifs
SetMotifScores
SetMotifScores(seurat_obj, tf_scores, wgcna_name = NULL)SetMotifScores(seurat_obj, tf_scores, wgcna_name = NULL)
seurat_obj |
A Seurat object |
tf_scores |
dataframe of tf motif target scores |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetMotifTargets
SetMotifTargets(seurat_obj, motif_targets)SetMotifTargets(seurat_obj, motif_targets)
seurat_obj |
A Seurat object |
motif_targets |
list of motifs and their target genes |
SetMotifTargetsSetMotifTargets
This function sets up the expression matrix input for consensus WGCNA based on the metacell expression matrix, the full expression matrix, or a provided pseudobulk expression matrix.
SetMultiExpr( seurat_obj, group_name, use_metacells = TRUE, group.by = NULL, multi.group.by = NULL, multi_groups = NULL, assay = NULL, slot = "data", layer = "data", mat = NULL, mat_group_delim = 3, wgcna_name = NULL, ... )SetMultiExpr( seurat_obj, group_name, use_metacells = TRUE, group.by = NULL, multi.group.by = NULL, multi_groups = NULL, assay = NULL, slot = "data", layer = "data", mat = NULL, mat_group_delim = 3, wgcna_name = NULL, ... )
seurat_obj |
A Seurat object |
group_name |
A string containing a group present in the provided group.by column or in the Seurat Idents. |
use_metacells |
A logical determining if we use the metacells (TRUE) or the full expression matrix (FALSE) |
group.by |
A string containing the name of a column in the Seurat object with cell groups (clusters, cell types, etc). If NULL (default), hdWGCNA uses the Seurat Idents as the group. |
multi.group.by |
A string containing the name of a column in the Seurat object with groups for consensus WGCNA (dataset, sample, condition, etc) |
multi_groups |
A character vecrtor containing the names of groups to select |
assay |
The name of the assay in the Seurat object |
slot |
The name of the slot in the Seurat object (counts, data) |
layer |
Layer to extract data for aggregation. Default = 'counts'. Layer is used with Seurat v5 instead of slot. |
mat |
A Matrix containing gene expression data. Supplying a matrix using this parameter ignores other options. This is almost exclusively used for pseudobulk analysis. |
wgcna_name |
A string containing the name of the WGCNA slot in seurat_obj@misc. Default = NULL which retrieves the currently active WGCNA data |
SetNetworkData
SetNetworkData(seurat_obj, net, wgcna_name = NULL)SetNetworkData(seurat_obj, net, wgcna_name = NULL)
seurat_obj |
A Seurat object |
net |
list of network data from WGCNA |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetPFMList
SetPFMList(seurat_obj, pfm_list)SetPFMList(seurat_obj, pfm_list)
seurat_obj |
A Seurat object |
pfm_list |
list of pfm objects |
SetPFMListSetPFMList
SetPowerTable
SetPowerTable(seurat_obj, power_table, wgcna_name = NULL)SetPowerTable(seurat_obj, power_table, wgcna_name = NULL)
seurat_obj |
A Seurat object |
power_table |
a dataframe containing the results of the soft power test |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetRegulonScores
SetRegulonScores(seurat_obj, regulon_scores, target_type, wgcna_name = NULL)SetRegulonScores(seurat_obj, regulon_scores, target_type, wgcna_name = NULL)
seurat_obj |
A Seurat object |
regulon_scores |
dataframe storing the TF regulon scores |
target_type |
dataframe storing the TF regulon scores |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetTFEval
SetTFEval(seurat_obj, tf_eval, wgcna_name = NULL)SetTFEval(seurat_obj, tf_eval, wgcna_name = NULL)
seurat_obj |
A Seurat object |
tf_eval |
dataframe storing the TF network evaluation info from ConstructTFNetwork |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetTFNetwork
SetTFNetwork(seurat_obj, tf_net, wgcna_name = NULL)SetTFNetwork(seurat_obj, tf_net, wgcna_name = NULL)
seurat_obj |
A Seurat object |
tf_net |
dataframe storing the TF network info in ConstructTFNetwork |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetTFRegulons
SetTFRegulons(seurat_obj, tf_regulons, wgcna_name = NULL)SetTFRegulons(seurat_obj, tf_regulons, wgcna_name = NULL)
seurat_obj |
A Seurat object |
tf_regulons |
dataframe storing the TF regulon info from AssignTFRegulons |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
Create a slot in a Seurat object to store hdWGCNA data
SetupForWGCNA( seurat_obj, wgcna_name, features = NULL, metacell_location = NULL, ... )SetupForWGCNA( seurat_obj, wgcna_name, features = NULL, metacell_location = NULL, ... )
seurat_obj |
A Seurat object |
wgcna_name |
name of the WGCNA experiment |
features |
list of features to use for WGCNA |
metacell_location |
name of the WGCNA experiment to copy the metacell object from |
... |
additional parameters to pass to SelectNetworkGenes |
SetupForWGCNA creates a new slot in the Seurat object (seurat_obj) to store an hdWGCNA experiment with a given name (wgcna_name). This function calls on SelectNetworkGenes to specify which features will be used for network analysis. If there is another hdWGCNA experiment already in the seurat_obj, the same metacell/metaspot object can be used by specifying the name of the hdWGCNA experiment to the metacell_location parameter.
SetWGCNAGenes
SetWGCNAGenes(seurat_obj, gene_list, wgcna_name = NULL)SetWGCNAGenes(seurat_obj, gene_list, wgcna_name = NULL)
seurat_obj |
A Seurat object |
gene_list |
vector of genes to be used for WGCNA |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
SetWGCNAParams
SetWGCNAParams(seurat_obj, params, wgcna_name = NULL)SetWGCNAParams(seurat_obj, params, wgcna_name = NULL)
seurat_obj |
A Seurat object |
params |
list of WGCNA parameters |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
Function to shuffle the rows of a dataframe.
shuffle_points(df)shuffle_points(df)
df |
dataframe |
Compute the scale-free topology model fit for different soft power thresholds
TestSoftPowers( seurat_obj, powers = c(seq(1, 10, by = 1), seq(12, 30, by = 2)), networkType = "signed", corFnc = "bicor", wgcna_name = NULL, ... )TestSoftPowers( seurat_obj, powers = c(seq(1, 10, by = 1), seq(12, 30, by = 2)), networkType = "signed", corFnc = "bicor", wgcna_name = NULL, ... )
seurat_obj |
A Seurat object |
powers |
numeric vector specifying soft powers to test |
networkType |
The type of network to use for network analysis. Options are "signed" (default), "unsigned", or "signed hybrid". This should be consistent with the network chosen for ConstructNetwork |
corFnc |
Correlation function for the gene-gene correlation adjacency matrix. |
wgcna_name |
name of the WGCNA experiment |
... |
additional parameters passed to WGCNA::pickSoftThreshold |
TestSoftPowers aims to find the optimal value of the "soft-power threshold" for co-expression network analysis. For varying values of this soft_power parameter, this function assesses the scale-free topology model fit of the resulting network and the function also calculates other network statistics such as the connectivity. The user may also vary the type of network used and the correlation function. For downstream functions, the lowest soft_power that reaches a fit of 0.8 is selected for network construction, but the user may select their own values.
Compute the scale-free topology model fit for different soft power thresholds separately for each input dataset
TestSoftPowersConsensus( seurat_obj, powers = c(seq(1, 10, by = 1), seq(12, 30, by = 2)), use_metacells = TRUE, networkType = "signed", corFnc = "bicor", setDatExpr = FALSE, group.by = NULL, group_name = NULL, multi.group.by = NULL, multi_groups = NULL, wgcna_name = NULL, ... )TestSoftPowersConsensus( seurat_obj, powers = c(seq(1, 10, by = 1), seq(12, 30, by = 2)), use_metacells = TRUE, networkType = "signed", corFnc = "bicor", setDatExpr = FALSE, group.by = NULL, group_name = NULL, multi.group.by = NULL, multi_groups = NULL, wgcna_name = NULL, ... )
seurat_obj |
A Seurat object |
powers |
numeric vector specifying soft powers to test |
use_metacells |
logical flag for whether to use the metacell expression matrix |
networkType |
The type of network to use for network analysis. Options are "signed" (default), "unsigned", or "signed hybrid". This should be consistent with the network chosen for ConstructNetwork |
corFnc |
Correlation function for the gene-gene correlation adjacency matrix. |
setDatExpr |
logical flag indicating whether to run setDatExpr. |
group.by |
A string containing the name of a column in the Seurat object with cell groups (clusters, cell types, etc). If NULL (default), hdWGCNA uses the Seurat Idents as the group. |
group_name |
A string containing a group present in the provided group.by column or in the Seurat Idents. A character vector can be provided to select multiple groups at a time. |
multi.group.by |
A string containing the name of a column in the Seurat object with groups for consensus WGCNA (dataset, sample, condition, etc) |
multi_groups |
A character vecrtor containing the names of groups to select |
... |
additional parameters passed to SetDatExpr |
# TestSoftPowers(pbmc)# TestSoftPowers(pbmc)
Plots a network of TFs and predicted target genes.
TFNetworkPlot( seurat_obj, selected_tfs, depth = 2, edge_weight = "Cor", cutoff = 0.01, color_cutoff = 0.75, target_type = "both", use_regulons = TRUE, label_genes = NULL, label_TFs = 1, no_labels = FALSE, TFs_only = FALSE, high_color = "orange2", mid_color = "white", low_color = "dodgerblue", node_colors = c("black", "darkorchid4", "mediumpurple2"), wgcna_name = NULL )TFNetworkPlot( seurat_obj, selected_tfs, depth = 2, edge_weight = "Cor", cutoff = 0.01, color_cutoff = 0.75, target_type = "both", use_regulons = TRUE, label_genes = NULL, label_TFs = 1, no_labels = FALSE, TFs_only = FALSE, high_color = "orange2", mid_color = "white", low_color = "dodgerblue", node_colors = c("black", "darkorchid4", "mediumpurple2"), wgcna_name = NULL )
seurat_obj |
A Seurat object |
selected_tfs |
A list of TFs |
depth |
Number of layers to extend the TF network from the selected_tfs. For example, if depth=2 (default), the target genes of selected_tfs are shown, and additional target genes are shown for other TFs that are target genes of the original selected_tfs. |
edge_weight |
Attribute to use to color the network edges. "Cor" to show the pearson correlation, or "Gain" to show the importance score from the XGBoost model. |
cutoff |
Cutoff for the edge weights, links below this value will not be included. |
color_cutoff |
Maximum value for the colorscale for the edge weights. |
target_type |
Type of target genes to show in the network. "Positive" shows genes with expression positively correlated with selected_tfs, "Negative" shows genes that are negatively correlated, and "Both" shows both (default). |
use_regulons |
Logical indicating whether to use the TF-gene links defined in the TF Regulons (TRUE, default), or all putative TF-gene links (FALSE). |
label_genes |
List of target genes to label in the network plot. |
label_TFs |
The depth level in the network to plot the names of TFs. |
no_labels |
Logical indicating whether or not to remove all labels. |
TFs_only |
Logical indicating whether or not to use only TFs in the plot or to use TFs and other genes. |
high_color |
Color corresponding to positive edge weights |
mid_color |
Color corresponding to edge weights close to 0 |
low_color |
Color corresponding to negative edge weights |
node_colors |
List of color names for the TFs and genes at each depth. For example, if depth=2, you should supply a list of 3 colors corresponding to the selected_tfs (depth 0), the primary target genes (depth 1), and the secondary target genes (depth 2). |
wgcna_name |
The name of the hdWGCNA experiment in the seurat_obj@misc slot |
TFNetworkPlot plots a network of TFs and their predicted target genes, based on the results from ConstructTFNetwork.
ggplot object containing the TFNetworkPlot
Convert a single-cell expression matrix (i.e., genes by cells) to a pseudobulk matrix by summarizing counts within biological replicates. This function is
to_pseudobulk( input, meta = NULL, replicate_col = "replicate", cell_type_col = "cell_type", label_col = "label", min_cells = 3, min_reps = 2, min_features = 0, external = T )to_pseudobulk( input, meta = NULL, replicate_col = "replicate", cell_type_col = "cell_type", label_col = "label", min_cells = 3, min_reps = 2, min_features = 0, external = T )
input |
a single-cell matrix to be converted, with features (genes) in rows
and cells in columns. Alternatively, a |
meta |
the accompanying meta data whereby the rownames match the column
names of |
replicate_col |
the vector in |
cell_type_col |
the vector in |
label_col |
the vector in |
min_cells |
the minimum number of cells in a cell type to retain it.
Defaults to |
min_reps |
the minimum number of replicates in a cell type to retain it.
Defaults to |
min_features |
the minimum number of expressing cells (or replicates)
for a gene to retain it. Defaults to |
a list of pseudobulk matrices, for each cell type.
Takes a module table and a gene mapping table (like from biomart) with gene names from two genomes in order to switch
TransferModuleGenome( modules, gene_mapping, genome1_col = NULL, genome2_col = NULL )TransferModuleGenome( modules, gene_mapping, genome1_col = NULL, genome2_col = NULL )
modules |
module table from GetModules function |
gene_mapping |
table that has the gene names for both genomes |
genome1_col |
the column in gene_mapping that has gene names for the genome currently present in modules |
genome2_col |
the column in gene_mapping that has gene names for the genome to transfer to |
TransferModuleGenomeTransferModuleGenome