| Title: | Time-course Differential Expression analysis of omics data |
|---|---|
| Description: | TiDEomics provides a comprehensive workflow for multi-group time-course omics data analysis, analysing time-dominant, group-dominant, and group-specific temporal effects through pairwise differential expression, variance decomposition, and co-expression module analysis (WGCNA). The package integrates quality control, data processing, functional enrichment, and extensive visualisation. It supports datasets with missing values (e.g., mass spectrometry-based proteomics), and operates on SummarizedExperiment objects to ensure compatibility with the Bioconductor ecosystem. |
| Authors: | Tianen He [aut, cre] (ORCID: <https://orcid.org/0000-0001-6864-0723>) |
| Maintainer: | Tianen He <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.99.5 |
| Built: | 2026-10-12 13:46:14 UTC |
| Source: | https://github.com/bioc/TiDEomics |
Calculate per-feature temporal properties for each group from the mean of replicates at each time point.
calc_feature_property(se_obj_merged_list, threshold = NULL)calc_feature_property(se_obj_merged_list, threshold = NULL)
se_obj_merged_list |
A list of SummarizedExperiment objects created
by |
threshold |
A numeric value to determine whether a feature is "expressed" in samples. (default is NULL, meaning any non-NA value is considered expressed). |
A list of SummarizedExperiment objects, each corresponding to one group, with updated rowData containing the following columns: Feature, Group, Exp_threshold, T_exp (number of time points with values > Exp_threshold), T_total (total number of time points), P_trend (p-value from Bartels' test for randomness against a trend), Max_FC (maximum fold change across time points), Max_FC_time (difference between the time points at which maximum and minimum expression occur; positive if max occurs after min, negative otherwise), Exp_ratio (T_exp / T_total), Rho_time (Spearman correlation with time; positive = up trend), Peak_ratio (number of local maxima / T_total; 0 = no peaks detected), Log2_CV (log2(1 + CV) of expression across time points), AUC (area under the time-0-normalised curve from assay 2; NA if assay 2 is not available).
data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged_list <- calc_feature_property(example_obj_merged_list, threshold = 0)data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged_list <- calc_feature_property(example_obj_merged_list, threshold = 0)
Calculate mean and standard deviation for each group and time point
calc_mean_sd(se_obj)calc_mean_sd(se_obj)
se_obj |
A SummarizedExperiment object with assays containing expression data. The first assay should be the original data, and the second (if present) should be normalized data. |
A list containing two data frames: one for original values and one for normalized values (if available). Each data frame includes columns for Mean, SD, Group, Time, and Feature.
data(example_obj) table_mean_sd_list <- calc_mean_sd(example_obj) table_mean_sd <- table_mean_sd_list$normdata(example_obj) table_mean_sd_list <- calc_mean_sd(example_obj) table_mean_sd <- table_mean_sd_list$norm
Check format of input data and sample annotation, create a SummarizedExperiment object
create_input( data, sample_ann, subject_col = NULL, replicate_col = NULL, batch_col = NULL )create_input( data, sample_ann, subject_col = NULL, replicate_col = NULL, batch_col = NULL )
data |
A data frame with rows as features (e.g., genes, proteins) and columns as samples. The first column should contain feature identifiers (e.g., gene symbols) and named as 'Feature'. The data should have been log transformed (and normalised if needed). Missing values are allowed in some of the downstream analyses. |
sample_ann |
A data frame containing sample annotations with required columns: 'Sample', 'Group', and 'Time'. 'Replicate' and 'Batch' are optional columns and will be auto-generated if not provided. 'Time', 'Replicate' and 'Batch' should be numeric. |
subject_col |
Optional: name of a column in |
replicate_col |
Optional: name of a column in |
batch_col |
Optional: name of a column in |
A SummarizedExperiment object containing the input data and sample annotations.
data <- data.frame(Feature = c("Gene1", "Gene2"), Sample1 = c(1, 2), Sample2 = c(3, 4)) sample_ann <- data.frame( Sample = c("Sample1", "Sample2"), Group = c("A", "A"), Time = c(0, 1), Rep = c(1, 1), BatchID = c(1, 1) ) se_obj <- create_input(data, sample_ann, replicate_col = "Rep", batch_col = "BatchID")data <- data.frame(Feature = c("Gene1", "Gene2"), Sample1 = c(1, 2), Sample2 = c(3, 4)) sample_ann <- data.frame( Sample = c("Sample1", "Sample2"), Group = c("A", "A"), Time = c(0, 1), Rep = c(1, 1), BatchID = c(1, 1) ) se_obj <- create_input(data, sample_ann, replicate_col = "Rep", batch_col = "BatchID")
Differential expression analysis between groups at each time
point by limma. The function compares each pair of groups at each time
point, and returns a nested list of DE analysis results for each pair of
groups and each time point including all features, as well as a list of
filtered DE results for each pair of groups based on the specified
thresholds including only significant features. Use
plot_DE_between_group() to visualise the number of DE features between
groups over time.
DE_between_group( se_obj, group = NULL, filter = NULL, assay, adjP_thres = 0.05, logFC_thres = 1, trend = FALSE )DE_between_group( se_obj, group = NULL, filter = NULL, assay, adjP_thres = 0.05, logFC_thres = 1, trend = FALSE )
se_obj |
A SummarizedExperiment object |
group |
A character vector specifying which group to be compared to. If NULL, all groups in the 'Group' column will be compared to. (default is NULL) |
filter |
Minimum number of replicates required in both conditions for a feature to be tested. If NULL, the minimum number of replicates across all groups and time points will be used. (default is NULL) |
assay |
The assay to use in the SummarizedExperiment object: a numeric index or character name, e.g. 1 or "orig" for original data, 2 or "norm" for time 0 normalised data. (Required, no default.) The selected assay should contain log-transformed, normalised values (e.g. log2-CPM for RNA-seq, log2-intensity for proteomics). A warning is issued if the data appears to be un-logged raw counts. |
adjP_thres |
Threshold for adjusted p-value to consider a feature as differentially expressed (default is 0.05) |
logFC_thres |
Threshold for log2 fold change to consider a feature as differentially expressed (default is 1) |
trend |
Logical, passed to |
Only time points present in both groups are compared. No multiple-testing
correction is applied across the pairwise group-by-time comparisons; each
comparison is independent. Apply your own correction (e.g.,
stats::p.adjust()) across combined results if needed.
A list with: all_list (nested list of DE results per group
pair and time point, all features); de_list (significant features
only); fit_list (nested list of limma MArrayLM fit objects,
for use with limma::plotSA()); ref_groups (group to be compared to);
all_groups (all groups). The output can be passed to
plot_DE_between_group() for visualisation.
data(example_obj) example_obj <- normalise_to_start(example_obj) DE_between_group_out <- DE_between_group(example_obj, assay = 2)data(example_obj) example_obj <- normalise_to_start(example_obj) DE_between_group_out <- DE_between_group(example_obj, assay = 2)
Differential expression analysis between time points within each group by limma
DE_between_time( se_obj, group = NULL, filter = NULL, assay, adjP_thres = 0.05, logFC_thres = 1, trend = FALSE )DE_between_time( se_obj, group = NULL, filter = NULL, assay, adjP_thres = 0.05, logFC_thres = 1, trend = FALSE )
se_obj |
A SummarizedExperiment object created by |
group |
A character vector specifying which groups to analyse. If NULL, all groups in the 'Group' column will be used. (default is NULL) |
filter |
Minimum number of replicates required in both conditions for a feature to be tested. If NULL, the minimum number of replicates across all groups and time points will be used. (default is NULL) |
assay |
The assay to use in the SummarizedExperiment object: a numeric index or character name, e.g. 1 or "orig" for original data, 2 or "norm" for time 0 normalised data. (Required, no default.) The selected assay should contain log-transformed, normalised values (e.g. log2-CPM for RNA-seq, log2-intensity for proteomics). A warning is issued if the data appears to be un-logged raw counts. |
adjP_thres |
Threshold for adjusted p-value to consider a feature as differentially expressed (default is 0.05) |
logFC_thres |
Threshold for log2 fold change to consider a feature as differentially expressed (default is 1) |
trend |
Logical, passed to |
A list with: all_list (nested list of DE results per group
and time comparison, all features); de_list (nested list of
significant features only); fit_list (nested list of limma
MArrayLM fit objects, for use with limma::plotSA());
time_series (vector of all available time points). The output
can be passed to plot_DE_between_time() for visualisation.
data(example_obj) example_obj <- normalise_to_start(example_obj) DE_between_time_out <- DE_between_time(example_obj, assay = 1)data(example_obj) example_obj <- normalise_to_start(example_obj) DE_between_time_out <- DE_between_time(example_obj, assay = 1)
Variance decomposition by linear mixed models (LMM), to estimate
the contribution of Group and Time to the variance of each feature.
Modified from PALMO::lmeVariance() function.
Group and Time are always included as random effects. The formula is extended automatically based on colData:
Subject column present: adds (1|Subject) to model between-subject
differences
interaction = TRUE: adds (1|Group:Time) (or (1|Subject:Time)
when Subject present) to capture interaction variance. Requires >= 2
replicates per combination. Default: FALSE.
Output always includes: Group, Time, Residual. Subject is included when present. All values are percentages of total variance.
Allow using original data or data normalised to time point 0.
decomp_variance( se_obj, features = NULL, fixed_effect_var = NULL, interaction = FALSE, assay, core = 1 )decomp_variance( se_obj, features = NULL, fixed_effect_var = NULL, interaction = FALSE, assay, core = 1 )
se_obj |
A SummarizedExperiment object created by |
features |
A vector of features to include. If NULL, all features. |
fixed_effect_var |
Column names to include as fixed effects
(regressed out, not appearing as variance components). Default is
|
interaction |
Logical. If TRUE, adds |
assay |
The assay to use in the SummarizedExperiment object: a numeric index or character name, e.g. 1 or "orig" for original data, 2 or "norm" for time 0 normalised data. (Required, no default.) |
core |
Number of cores for parallel processing (default: 1) |
A data frame with variance decomposition results (percentages).
https://github.com/aifimmunology/PALMO/blob/main/R/lmeVariance.R
data(example_obj) example_obj <- normalise_to_start(example_obj) var_decomp <- decomp_variance(example_obj, assay = 1)data(example_obj) example_obj <- normalise_to_start(example_obj) var_decomp <- decomp_variance(example_obj, assay = 1)
Enrichment analysis against MSigDB gene sets via
hypergeometric test. Supports MSigDB categories, subcategories,
and specified gene sets. Requires the msigdbr package.
Use cases:
Drug perturbations: category = "C2", subcategory = "CGP"
(chemical and genetic perturbations)
TF targets: category = "C3", subcategory = "TFT:GTRD"
Hallmarks: category = "H", subcategory = NULL (no subcategory)
GO: category = "C5", subcategory = "BP" (GO biological process)
Multiple testing: P-values are adjusted (Benjamini-Hochberg) per module across the gene-set tests within that module.
enrich_msigdb( gene_list, universe, category = NULL, subcategory = NULL, gene_sets = NULL, species = "Homo sapiens", db_species = "HS", name = NULL, pvalueCutoff = 0.05, pAdjustMethod = "BH", minGSSize = 10, maxGSSize = 500 )enrich_msigdb( gene_list, universe, category = NULL, subcategory = NULL, gene_sets = NULL, species = "Homo sapiens", db_species = "HS", name = NULL, pvalueCutoff = 0.05, pAdjustMethod = "BH", minGSSize = 10, maxGSSize = 500 )
gene_list |
A named list of gene vectors, or a data.frame
with |
universe |
Background genes (required). |
category |
MSigDB category (default: |
subcategory |
MSigDB subcategory (default: |
gene_sets |
Optional character vector of specific MSigDB gene set
names to include (e.g., |
species |
Species of input genes (default: |
db_species |
Species of MSigDB genesets (default: |
name |
Name for the output list element. If NULL, auto-derived
from |
pvalueCutoff |
Adjusted p-value cutoff (default: 0.05). |
pAdjustMethod |
P-value adjustment method (default: |
minGSSize |
Minimum gene set size (default: 10). |
maxGSSize |
Maximum gene set size (default: 500). |
A named list with one element: a data.frame with columns
Cluster, ID, Description, GeneRatio, BgRatio, pvalue,
p.adjust, Count, geneID.
if (requireNamespace("msigdbr", quietly = TRUE)) { data(example_net) example_module <- WGCNA_module(example_net) |> dplyr::filter(Module %in% c("1", "2")) hallmark_msigdb <- enrich_msigdb(example_module, category = "MH", species = "Mus musculus", db_species = "MM", minGSSize = 1, pvalueCutoff = 0.9, universe = WGCNA_module(example_net, exclude_grey = FALSE)$Feature) }if (requireNamespace("msigdbr", quietly = TRUE)) { data(example_net) example_module <- WGCNA_module(example_net) |> dplyr::filter(Module %in% c("1", "2")) hallmark_msigdb <- enrich_msigdb(example_module, category = "MH", species = "Mus musculus", db_species = "MM", minGSSize = 1, pvalueCutoff = 0.9, universe = WGCNA_module(example_net, exclude_grey = FALSE)$Feature) }
Gene ontology enrichment analysis of multiple gene sets with clusterProfiler, allowing for using different or same background genes for each gene set
enrichGO_list( gene_list, keyType = "SYMBOL", OrgDb, universe = NULL, universe_list = NULL, pAdjustMethod = "BH", pvalueCutoff = 0.05, qvalueCutoff = 0.05, category = NULL, simplify = FALSE, simplify_cutoff = 0.7, simplify_by = "p.adjust", simplify_select_fun = min, simplify_measure = "Wang", ... )enrichGO_list( gene_list, keyType = "SYMBOL", OrgDb, universe = NULL, universe_list = NULL, pAdjustMethod = "BH", pvalueCutoff = 0.05, qvalueCutoff = 0.05, category = NULL, simplify = FALSE, simplify_cutoff = 0.7, simplify_by = "p.adjust", simplify_select_fun = min, simplify_measure = "Wang", ... )
gene_list |
A named list of gene vectors, or a data.frame
with |
keyType |
Available options are
|
OrgDb |
Organism database, e.g. org.Hs.eg.db, org.Mm.eg.db |
universe |
Background genes for all input gene sets,
used if |
universe_list |
Background genes for each input gene set,
a list of gene vectors with the same names as |
pAdjustMethod |
Parameter of |
pvalueCutoff |
Parameter of |
qvalueCutoff |
Parameter of |
category |
GO category to analyze (default is all three of BP, MF, CC) |
simplify |
Whether to simplify the GO terms by removing
redundant terms with |
simplify_cutoff |
Parameter of |
simplify_by |
Parameter of |
simplify_select_fun |
Parameter of
|
simplify_measure |
Parameter of
|
... |
additional arguments passed to |
A nested list of GO enrichment results with sublists:
'all' and 'simplified' (if simplify = TRUE)
containing merged results of all or simplified terms across gene sets
for each GO category;
'unmerged_all' and 'unmerged_simplified' (if simplify = TRUE) including
all or simplified terms for each gene set and GO category.
if (requireNamespace("org.Mm.eg.db", quietly = TRUE)) { library(org.Mm.eg.db) library(clusterProfiler) data(example_net) # select two modules for demonstration example_module <- WGCNA_module(example_net) |> dplyr::filter(Module %in% c("1", "2")) # set cutoff to 1 to show all results for demonstration example_go_list = enrichGO_list(example_module, OrgDb = org.Mm.eg.db, universe = WGCNA_module(example_net, exclude_grey = FALSE)$Feature, pvalueCutoff = 1, qvalueCutoff = 1, category = "BP", simplify = FALSE) }if (requireNamespace("org.Mm.eg.db", quietly = TRUE)) { library(org.Mm.eg.db) library(clusterProfiler) data(example_net) # select two modules for demonstration example_module <- WGCNA_module(example_net) |> dplyr::filter(Module %in% c("1", "2")) # set cutoff to 1 to show all results for demonstration example_go_list = enrichGO_list(example_module, OrgDb = org.Mm.eg.db, universe = WGCNA_module(example_net, exclude_grey = FALSE)$Feature, pvalueCutoff = 1, qvalueCutoff = 1, category = "BP", simplify = FALSE) }
Gene ontology enrichment analysis of a ranked gene list with clusterProfiler. Genes can be ranked by variance decomposition results.
enrichGO_rank( rank_table, gene_rank_by, OrgDb, keyType = "SYMBOL", go_rank_by = "p.adjust", category = NULL, pvalueCutoff = 0.05, pAdjustMethod = "BH", ... )enrichGO_rank( rank_table, gene_rank_by, OrgDb, keyType = "SYMBOL", go_rank_by = "p.adjust", category = NULL, pvalueCutoff = 0.05, pAdjustMethod = "BH", ... )
rank_table |
A data frame with at least two columns: 'Feature' for gene
names and one or more columns of variables for ranking the genes,
e.g. output of |
gene_rank_by |
Variable in |
OrgDb |
Organism database, e.g. org.Hs.eg.db, org.Mm.eg.db |
keyType |
Available options are
|
go_rank_by |
Variable in the GO enrichment result to rank the GO terms by (default is "p.adjust", other options include "pvalue", "qvalue", "NES", "setSize", "enrichmentScore", etc.) |
category |
GO category to analyze (default is all three of BP, MF, CC) |
pvalueCutoff |
Parameter of |
pAdjustMethod |
Parameter of |
... |
additional arguments passed to |
A list of gseaResult objects containing the GSEA results
if (requireNamespace("org.Mm.eg.db", quietly = TRUE)) { library(org.Mm.eg.db) data(example_obj) example_obj <- normalise_to_start(example_obj) var_decomp <- decomp_variance(example_obj, features = rownames(example_obj)[1:100], assay = 1) example_go_rank <- enrichGO_rank(var_decomp, gene_rank_by = "Time", OrgDb = org.Mm.eg.db, keyType = "SYMBOL", category = "BP") }if (requireNamespace("org.Mm.eg.db", quietly = TRUE)) { library(org.Mm.eg.db) data(example_obj) example_obj <- normalise_to_start(example_obj) var_decomp <- decomp_variance(example_obj, features = rownames(example_obj)[1:100], assay = 1) example_go_rank <- enrichGO_rank(var_decomp, gene_rank_by = "Time", OrgDb = org.Mm.eg.db, keyType = "SYMBOL", category = "BP") }
Enrichment analysis of multiple gene sets against databases from enrichR (e.g. DSigDB for drug signatures, ChEA for TF targets, KEGG for pathways, DrugBank for drug targets).
enrichR_list( gene_list, databases = c("DSigDB", "DrugMatrix"), site = "Enrichr", universe = NULL, universe_list = NULL, pvalueCutoff = 0.05, include_overlap = FALSE )enrichR_list( gene_list, databases = c("DSigDB", "DrugMatrix"), site = "Enrichr", universe = NULL, universe_list = NULL, pvalueCutoff = 0.05, include_overlap = FALSE )
gene_list |
A named list of gene vectors, or a data.frame
with |
databases |
Character vector of enrichR database names to query.
Available databases can be checked with |
site |
enrichR site to query. See |
universe |
Background genes for all input gene sets,
used if |
universe_list |
Background genes for each input gene set,
a list of gene vectors with the same names as |
pvalueCutoff |
Adjusted p-value cutoff for filtering enriched terms (default: 0.05) |
include_overlap |
Parameter passed to |
Multiple testing: P-values are adjusted (Benjamini–Hochberg) independently for each module within each database. No correction is applied across databases or across modules.
Requires an internet connection.
A named list of data.frames, one per database. Each data.frame
has columns Cluster, Description, p.adjust
(Adjusted.P.value from enrichR output),
Combined.Score, Genes, and any additional
columns returned by the enrichR API. Compatible with
plot_modules_h(enrich_list = result, enrich_category = "DSigDB").
data(example_net) library(dplyr) example_module <- WGCNA_module(example_net) |> dplyr::filter(Module %in% c("1", "2")) # Use high pvalueCutoff for demonstration # enrichr_out <- enrichR_list(example_module, # databases = c("KEGG_2019_Mouse"), # universe = WGCNA_module(example_net, exclude_grey = FALSE)$Feature, # pvalueCutoff = 0.5)data(example_net) library(dplyr) example_module <- WGCNA_module(example_net) |> dplyr::filter(Module %in% c("1", "2")) # Use high pvalueCutoff for demonstration # enrichr_out <- enrichR_list(example_module, # databases = c("KEGG_2019_Mouse"), # universe = WGCNA_module(example_net, exclude_grey = FALSE)$Feature, # pvalueCutoff = 0.5)
enrichGO_list() output object for runnable examplesCode for producing the data is in inst/script/generate_example_go.R
data(example_go)data(example_go)
A nested list with GO enrichment results for modules "1" and "2" from 'example_net', containing categories "BP" and "CC", with simplify = TRUE applied:
Merged results across gene sets for each GO category
Simplified merged results
Per-gene-set results for each category
Simplified per-gene-set results
GSE263759
run_WGCNA() output object for runnable examplesCode for producing the data is in inst/script/generate_example_net.R
data(example_net)data(example_net)
A list including WGCNA module assignments, module eigengenes, dendrogram, input data, sample information, and parameters used
GSE263759
A subset of data_obj <- create_input(data = tutorial_data, sample_ann = tutorial_sample_info) for use in runnable examples
in function documentation.
data(example_obj)data(example_obj)
A SummarizedExperiment object with assays of 100 rows and 40 columns, colData of 40 rows and 5 columns:
tutorial_sample_info
tutorial_data first 100 rows, "Feature" column as rownames
Code for preparing the data is available in inst/script/tutorial_input.R
GSE263759
run_Trendy output object for runnable examplesCode for preparing the data is in inst/script/generate_example_res_list.R
data(example_res_list)data(example_res_list)
A nested list, each element is a list with Trendy results for one group
GSE263759
Identifies hub features within each module using module membership
(kME).
For unsigned networks, absolute kME values are used to reproduce the
behaviour of WGCNA::blockwiseModules(). For signed and signed
hybrid networks, signed kME values are retained.
extract_hubs(net, top_n = 3, exclude_grey = TRUE)extract_hubs(net, top_n = 3, exclude_grey = TRUE)
net |
An output object from |
top_n |
Number of hub features to return per module. Default: 3. |
exclude_grey |
Logical; if |
A character vector containing the top top_n features
from each module concatenated together.
data(example_net) hubs <- extract_hubs(example_net, top_n = 3)data(example_net) hubs <- extract_hubs(example_net, top_n = 3)
Extract features with different segment trends from trendy segmented regression results summary
extract_segment_trends(trendy.summary)extract_segment_trends(trendy.summary)
trendy.summary |
A data frame, output of |
A nested list of features grouped by their segment trend patterns within each group.
data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged_list <- calc_feature_property(example_obj_merged_list, threshold = 0) # no missing value in the example dataset, so imputation is not necessary example_obj_merged_imp_list <- impute_groups(example_obj_merged_list) data("example_res_list") trendy_summary <- summarise_Trendy(example_res_list) trendy_list <- extract_segment_trends(trendy_summary)data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged_list <- calc_feature_property(example_obj_merged_list, threshold = 0) # no missing value in the example dataset, so imputation is not necessary example_obj_merged_imp_list <- impute_groups(example_obj_merged_list) data("example_res_list") trendy_summary <- summarise_Trendy(example_res_list) trendy_list <- extract_segment_trends(trendy_summary)
Flattens the nested DE result structure returned by
DE_between_group() or DE_between_time() into a named list of
data frames, one entry per contrast-time combination.
This is useful for exporting results to other tools such as
DeeDeeExperiment.
flatten_DE(de_list)flatten_DE(de_list)
de_list |
A list of DE results. Accepts individual output of
|
A named list of data frames with columns renamed for
DeeDeeExperiment compatibility (log2FoldChange, pvalue, padj).
Returns an empty list if de_list is empty.
data(tutorial_data) data(tutorial_sample_info) tide <- prepare_tide(tutorial_data, tutorial_sample_info, keep = "threshold", residual_threshold = 100) tide$DE <- DE_between_group(tide$se, assay = "norm", filter = 1, trend = TRUE) de_flat <- flatten_DE(tide$DE) str(de_flat, max.level = 1)data(tutorial_data) data(tutorial_sample_info) tide <- prepare_tide(tutorial_data, tutorial_sample_info, keep = "threshold", residual_threshold = 100) tide$DE <- DE_between_group(tide$se, assay = "norm", filter = 1, trend = TRUE) de_flat <- flatten_DE(tide$DE) str(de_flat, max.level = 1)
Flattens the nested enrichment result structure returned by
enrichGO_list(), enrichR_list(), or enrich_msigdb() into a
flat named list of data frames or enrichResult objects.
This is useful for exporting results to other tools such as
DeeDeeExperiment.
flatten_enrich(enrich_list)flatten_enrich(enrich_list)
enrich_list |
Output of |
A flat named list of data frames or enrichResult objects
with DeeDeeExperiment-compatible names and columns
(e.g. "clusterProfiler_BP_1", "enrichr_DSigDB").
Returns an empty list if enrich_list is empty.
data(example_go) enrich_flat <- flatten_enrich(example_go) str(enrich_flat, max.level = 1)data(example_go) enrich_flat <- flatten_enrich(example_go) str(enrich_flat, max.level = 1)
Get the custom color palette set by set_custom_palette.
If no custom palette has been set, the function will return a default
color palette based on the number of groups specified in the
groups argument.
get_custom_palette(groups)get_custom_palette(groups)
groups |
A character vector of group names for which to retrieve the colors from the custom palette. |
A named vector of colors corresponding to the specified group names.
get_custom_palette(c("untreated", "IFNbeta"))get_custom_palette(c("untreated", "IFNbeta"))
Identify features that are unique to selected groups (present
in those groups but not in any others) and annotate them with gene names
using the clusterProfiler::bitr() function. The function also provides an
option to perform Gene Ontology (GO) enrichment analysis on the identified
unique features using the enrichGO_list() function and visualize the
results with a dot plot.
group_specific_features( property_random_fc, groups = NULL, filter_ratio = 0.5, group_pct = 1, genename = TRUE, GO = TRUE, OrgDb = NULL, keytype = NULL, ... )group_specific_features( property_random_fc, groups = NULL, filter_ratio = 0.5, group_pct = 1, genename = TRUE, GO = TRUE, OrgDb = NULL, keytype = NULL, ... )
property_random_fc |
A data frame containing the results of the
|
groups |
A character vector of group names to be compared. If NULL, all groups in the input data will be used (default is NULL). |
filter_ratio |
A numeric value between 0 and 1 specifying the minimum proportion of expressed time points (minimum Exp_ratio) for a feature to be considered present (default is 0.5, meaning that a feature must have >=50% values > threshold in a group (>= 0.5 Exp_ratio) to be considered present in that group). |
group_pct |
A numeric value between 0 and 1 specifying the percentage of groups in which a feature must be present. (default is 1, meaning that a feature must be present in all specified groups). |
genename |
A logical value indicating whether to output a table of
gene names. If TRUE, the function will use the |
GO |
A logical value indicating whether to perform Gene Ontology
(GO) enrichment analysis on the identified unique features. If TRUE, the
function will use the |
OrgDb |
An OrgDb object from the |
keytype |
A character string specifying the type of gene identifiers
used in the row names of the assay data (e.g., "SYMBOL", "ENTREZID",
"ENSEMBL"). This will be used for gene annotation with the
|
... |
Additional arguments to be passed to the |
A named list with element features (character vector of features
identified as unique to the specified groups based on the filtering
criteria). If genename is TRUE, element genename contains a data.frame
of gene annotations. If GO is TRUE and enrichment succeeds, element GO
contains a dot plot of GO enrichment results. Returns NULL if no unique
features pass the filter.
data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged_list <- calc_feature_property(example_obj_merged_list, threshold = 0) property_random_fc <- summarise_feature_property(example_obj_merged_list) group_specific_features(property_random_fc, groups = c("untreated"), genename = FALSE, GO = FALSE)data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged_list <- calc_feature_property(example_obj_merged_list, threshold = 0) property_random_fc <- summarise_feature_property(example_obj_merged_list) group_specific_features(property_random_fc, groups = c("untreated"), genename = FALSE, GO = FALSE)
Impute missing values for each group of samples in a list of SummarizedExperiment objects. By default, replaces NA with the minimum non-NA value per group / subject. A custom function can be supplied for other strategies.
The input samples can contain replicates, or merged replicates (mean of replicates).
impute_groups(se_obj_list, fun = min, impute_by = c("group", "subject"))impute_groups(se_obj_list, fun = min, impute_by = c("group", "subject"))
se_obj_list |
A list of SummarizedExperiment objects, created by
|
fun |
Function applied to the non-NA values to generate the
replacement value. Default: |
impute_by |
|
A list of SummarizedExperiment objects with missing values imputed. Each object corresponds to one group of samples.
data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged_imp_list <- impute_groups(example_obj_merged_list)data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged_imp_list <- impute_groups(example_obj_merged_list)
Merge SummarizedExperiment object of different groups into one
merge_groups(se_obj_list)merge_groups(se_obj_list)
se_obj_list |
A list of SummarizedExperiment objects, such as output of
|
A SummarizedExperiment object containing all samples from the input list. The 'Group' column in the colData will indicate the group of each sample. New sample names will be prefixed with the group name.
data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged <- merge_groups(example_obj_merged_list)data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged <- merge_groups(example_obj_merged_list)
Calculate mean of replicates for each feature at each time point for each group.
When a Subject column is present, merging is done in two stages:
Average replicates within each Group-Subject-Time combination.
Average across subjects within each Group-Time combination. This gives equal weight to each subject regardless of replicate count.
Without a Subject column, all samples at the same Group-Time are averaged together in a single step.
merge_replicates(se_obj_list)merge_replicates(se_obj_list)
se_obj_list |
A list of SummarizedExperiment objects created by
|
A list of SummarizedExperiment objects containing the mean of replicates for each feature at each time point for each group. Each object in the list corresponds to one group of samples.
data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list)data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list)
Normalise to starting time point, to make the mean of starting time point samples 0.
Two modes are available:
by_subject = FALSE (default): computes the group-level mean at the
first non-NA time point per feature and subtracts it. All samples within
a group share the same baseline.
by_subject = TRUE: computes each subject's value at the first non-NA
time point per feature and subtracts that subject-specific baseline.
Removes between-subject baseline differences. Use when each subject has
their own initial condition. Requires a Subject column in colData.
normalise_to_start(se_obj, by_subject = FALSE)normalise_to_start(se_obj, by_subject = FALSE)
se_obj |
A SummarizedExperiment object created by |
by_subject |
If FALSE (default), use group-level baseline. If TRUE, use subject-level baseline (requires Subject column in colData). |
A SummarizedExperiment object with normalised data in the second assay slot.
data(example_obj) example_obj <- normalise_to_start(example_obj)data(example_obj) example_obj <- normalise_to_start(example_obj)
Plot breakpoint distribution among time points for each group
plot_breakpoints(res_list, group = NULL, fontsize = 8, ...)plot_breakpoints(res_list, group = NULL, fontsize = 8, ...)
res_list |
A list of the Trendy analysis results, output of
|
group |
A character vector of group names to be plotted. If NULL, all groups in the input list will be used (default is NULL) |
fontsize |
Font size for the plot (default is 8) |
... |
Additional arguments to be passed to |
A plot showing the distribution of breakpoints over time for each specified group
data("example_res_list") plot_breakpoints(example_res_list)data("example_res_list") plot_breakpoints(example_res_list)
Plot correlation matrix between samples as a heatmap
plot_cor_matrix( se_obj, assay = 1, use = "pairwise.complete.obs", method = c("spearman", "pearson", "kendall"), label_group = TRUE, label_time = TRUE, label_rep = TRUE, label_batch = TRUE, show_rownames = FALSE, show_colnames = FALSE, fontsize = 8, cellwidth = 1, cellheight = 1, title = NULL, ... )plot_cor_matrix( se_obj, assay = 1, use = "pairwise.complete.obs", method = c("spearman", "pearson", "kendall"), label_group = TRUE, label_time = TRUE, label_rep = TRUE, label_batch = TRUE, show_rownames = FALSE, show_colnames = FALSE, fontsize = 8, cellwidth = 1, cellheight = 1, title = NULL, ... )
se_obj |
A SummarizedExperiment object created by |
assay |
The assay to use in the SummarizedExperiment object: a numeric index or character name, e.g. 1 or "orig" for original data, 2 or "norm" for time 0 normalised data. (Default: 1.) |
use |
Parameter of |
method |
Parameter of |
label_group |
Whether to label Group (default is TRUE) |
label_time |
Whether to label Time (default is TRUE) |
label_rep |
Whether to label Replicate (default is TRUE) |
label_batch |
Whether to label Batch (default is TRUE) |
show_rownames |
Whether to show row names in the heatmap (default is FALSE) |
show_colnames |
Whether to show column names in the heatmap (default is FALSE) |
fontsize |
Font size for the plot (default is 8) |
cellwidth |
Cell width for the heatmap (default is 1) |
cellheight |
Cell height for the heatmap (default is 1) |
title |
Title of the heatmap. If NULL, auto-generated as
"Sample correlation ( |
... |
Additional arguments to be passed to |
A heatmap showing the correlation between samples.
data(example_obj) plot_cor_matrix(example_obj)data(example_obj) plot_cor_matrix(example_obj)
Plot the distribution of coefficient of variation (CV) for each feature with replicates. The CV is calculated as the standard deviation divided by the mean of the abundance values.
Note: CV is only meaningful for positive-valued data.
plot_cv(se_obj, fontsize = 8)plot_cv(se_obj, fontsize = 8)
se_obj |
A SummarizedExperiment object, produced by |
fontsize |
Font size for the plot (default is 8) (default is 8). |
A plot showing the distribution of coefficient of variation (CV) for each feature, grouped by Time and Group. If there are no replicates, a message will be printed indicating that CV cannot be calculated.
data(example_obj) plot_cv(example_obj)data(example_obj) plot_cv(example_obj)
Plot the number of differentially expressed features between
groups over time, using the output of DE_between_group().
DE features were pre-filtered with DE_between_group(), but by specifying
adjP_thres and logFC_thres, users can re-filter the DE features for
plotting.
plot_DE_between_group( DE_between_group_out, group = NULL, fontsize = 8, adjP_thres = NULL, logFC_thres = NULL )plot_DE_between_group( DE_between_group_out, group = NULL, fontsize = 8, adjP_thres = NULL, logFC_thres = NULL )
DE_between_group_out |
Output of |
group |
A character vector specifying which groups to use as the reference (Cond1) for plotting. If NULL, all groups in the output will be plotted. (default is NULL) |
fontsize |
Font size for the plot (default is 8) |
adjP_thres |
Threshold for adjusted p-value to consider a feature as differentially expressed, for re-filtering the DE features. (default is NULL, no re-filtering) |
logFC_thres |
Threshold for log2 fold change to consider a feature as differentially expressed, for re-filtering the DE features. (default is NULL, no re-filtering) |
A series of line plots showing the number of DE features over time for each group comparison.
data(example_obj) example_obj <- normalise_to_start(example_obj) DE_between_group_out <- DE_between_group(example_obj, assay = 2) plot_DE_between_group(DE_between_group_out, fontsize = 8)data(example_obj) example_obj <- normalise_to_start(example_obj) DE_between_group_out <- DE_between_group(example_obj, assay = 2) plot_DE_between_group(DE_between_group_out, fontsize = 8)
Plot the number of differentially expressed features between time points within each group with heatmaps
DE features were pre-filtered with DE_between_time(), but by specifying
adjP_thres and logFC_thres, users can re-filter the DE features for
plotting.
plot_DE_between_time( DE_between_time_out, value = TRUE, fontsize = 8, nrow = 1, heatmap_width = 4, heatmap_unit = "cm", adjP_thres = NULL, logFC_thres = NULL )plot_DE_between_time( DE_between_time_out, value = TRUE, fontsize = 8, nrow = 1, heatmap_width = 4, heatmap_unit = "cm", adjP_thres = NULL, logFC_thres = NULL )
DE_between_time_out |
Output of |
value |
Whether to display the actual number of DE features in each heatmap cell (default is TRUE) |
fontsize |
Font size for the plot (default is 8) |
nrow |
Number of rows for arranging the heatmaps (default is 1) |
heatmap_width |
Width of each heatmap (default is 4) |
heatmap_unit |
Unit for the heatmap width (default is "cm") |
adjP_thres |
Threshold for adjusted p-value to consider a feature as differentially expressed, for re-filtering the DE features. (default is NULL, no re-filtering) |
logFC_thres |
Threshold for log2 fold change to consider a feature as differentially expressed, for re-filtering the DE features. (default is NULL, no re-filtering) |
One heatmap per group showing the number of DE features between time points for each group, with the same scale across groups for easy comparison. The heatmap cells are optionally annotated with the number of DE features.
data(example_obj) example_obj <- normalise_to_start(example_obj) DE_between_time_out <- DE_between_time(example_obj, assay = 1) plot_DE_between_time(DE_between_time_out, fontsize = 8, value = TRUE, nrow = 1, heatmap_width = 3)data(example_obj) example_obj <- normalise_to_start(example_obj) DE_between_time_out <- DE_between_time(example_obj, assay = 1) plot_DE_between_time(DE_between_time_out, fontsize = 8, value = TRUE, nrow = 1, heatmap_width = 3)
This function generates density plots to visualise the distribution of abundance values across samples. The user can choose to facet the plot by "Group", "Time", or "Sample" to compare distributions across different conditions or samples. If no faceting variable is specified, a single density plot will be generated for all samples combined.
plot_distribution(se_obj, facet_by = NULL, fontsize = 8)plot_distribution(se_obj, facet_by = NULL, fontsize = 8)
se_obj |
A SummarizedExperiment object, produced by |
facet_by |
A character string specifying the variable to facet the plot by. It can be one of "Group", "Time", or "Sample". If NULL, no faceting will be applied and a single density plot will be generated for all samples (default is NULL). |
fontsize |
Font size for the plot (default is 8) (default is 8). |
A plot showing the density distribution of abundance values, optionally faceted by the specified variable.
data(example_obj) plot_distribution(example_obj) plot_distribution(example_obj, facet_by = "Group")data(example_obj) plot_distribution(example_obj) plot_distribution(example_obj, facet_by = "Group")
Visualization of GO enrichment analysis with dotplot, cnetplot, or emapplot in clusterProfiler
plot_GO( go_list, plot_dotplot = TRUE, plot_cnetplot = FALSE, plot_emapplot = FALSE, showCategory_dotplot = 5, showCategory_cnetplot = 5, showCategory_emapplot = 5, fontsize = 8, label = "genes", ... )plot_GO( go_list, plot_dotplot = TRUE, plot_cnetplot = FALSE, plot_emapplot = FALSE, showCategory_dotplot = 5, showCategory_cnetplot = 5, showCategory_emapplot = 5, fontsize = 8, label = "genes", ... )
go_list |
A list of enriched GO results, output from |
plot_dotplot |
Whether to plot dotplot (default is TRUE) |
plot_cnetplot |
Whether to plot cnetplot (default is FALSE) |
plot_emapplot |
Whether to plot emapplot (default is FALSE) |
showCategory_dotplot |
showCategory parameter of
|
showCategory_cnetplot |
showCategory parameter of
|
showCategory_emapplot |
showCategory parameter of
|
fontsize |
Font size for the plots (default is 8) |
label |
Title for the plots (default is "genes") |
... |
Additional parameters to pass to the plotting functions
|
A list of plots visualizing the GO enrichment results.
data(example_go) plot_GO(example_go$all, plot_dotplot = TRUE, plot_emapplot = FALSE, plot_cnetplot = FALSE)data(example_go) plot_GO(example_go$all, plot_dotplot = TRUE, plot_emapplot = FALSE, plot_cnetplot = FALSE)
Plot the number of identified features (i.e., features with non-missing values) for each sample
plot_ID(se_obj, fontsize = 8, signif = FALSE, ...)plot_ID(se_obj, fontsize = 8, signif = FALSE, ...)
se_obj |
A SummarizedExperiment object, produced by |
fontsize |
Font size for the plot (default is 8) (default is 8). |
signif |
A logical value indicating whether to perform significance testing between groups and add significance annotations to the plot (default is FALSE). |
... |
Additional arguments to be passed to
|
A plot showing the ID number for each sample, with a dashed line indicating the average number across all samples. And a boxplot comparing the ID number between groups, with optional significance annotations.
# simulate data with random missing values na_data <- matrix(rnorm(1500), nrow = 100, ncol = 150) na_data[sample(length(na_data), size = 2000)] <- NA na_data <- data.frame(Feature = paste0("Feature", 1:100), na_data) colnames(na_data)[-1] <- paste0("Sample", 1:150) na_obj <- create_input(na_data, data.frame(Sample = paste0("Sample", 1:150), Time = rep(rep(1:10, each = 5), 3), Group = rep(c("A", "B", "C"), each = 50), Replicate = rep(1:5, 30))) plot_ID(na_obj, signif = TRUE)# simulate data with random missing values na_data <- matrix(rnorm(1500), nrow = 100, ncol = 150) na_data[sample(length(na_data), size = 2000)] <- NA na_data <- data.frame(Feature = paste0("Feature", 1:100), na_data) colnames(na_data)[-1] <- paste0("Sample", 1:150) na_obj <- create_input(na_data, data.frame(Sample = paste0("Sample", 1:150), Time = rep(rep(1:10, each = 5), 3), Group = rep(c("A", "B", "C"), each = 50), Replicate = rep(1:5, 30))) plot_ID(na_obj, signif = TRUE)
Plot the ratio of missing values for each sample
plot_missing(se_obj, fontsize = 8, signif = FALSE, ...)plot_missing(se_obj, fontsize = 8, signif = FALSE, ...)
se_obj |
A SummarizedExperiment object, produced by |
fontsize |
Font size for the plot (default is 8) (default is 8). |
signif |
A logical value indicating whether to perform significance testing between groups and add significance annotations to the plot (default is FALSE). |
... |
Additional arguments to be passed to
|
A plot showing the missing value ratio for each sample, with a dashed line indicating the global missing value ratio across all samples. And a boxplot comparing the missing value ratio between groups, with optional significance annotations.
# simulate data with random missing values na_data <- matrix(rnorm(1500), nrow = 100, ncol = 150) na_data[sample(length(na_data), size = 2000)] <- NA na_data <- data.frame(Feature = paste0("Feature", 1:100), na_data) colnames(na_data)[-1] <- paste0("Sample", 1:150) na_obj <- create_input(na_data, data.frame(Sample = paste0("Sample", 1:150), Time = rep(rep(1:10, each = 5), 3), Group = rep(c("A", "B", "C"), each = 50), Replicate = rep(1:5, 30))) plot_missing(na_obj, signif = TRUE)# simulate data with random missing values na_data <- matrix(rnorm(1500), nrow = 100, ncol = 150) na_data[sample(length(na_data), size = 2000)] <- NA na_data <- data.frame(Feature = paste0("Feature", 1:100), na_data) colnames(na_data)[-1] <- paste0("Sample", 1:150) na_obj <- create_input(na_data, data.frame(Sample = paste0("Sample", 1:150), Time = rep(rep(1:10, each = 5), 3), Group = rep(c("A", "B", "C"), each = 50), Replicate = rep(1:5, 30))) plot_missing(na_obj, signif = TRUE)
Plot WGCNA modules' heatmaps, mean expression profiles, and enrichment terms, aligned horizontally.
Different from running WGCNA, the input data should have the replicates merged, instead of having multiple samples per group, time and feature (gene).
If certain time points are missing in some groups, NA values are added.
plot_modules_h( module, se_obj_merged, scale = TRUE, assay, ylabel = "Log2 abundance", profile_width = 3, profile_link_width = 1, enrich_list = NULL, enrich_category = "BP", enrich_rank_by = "p.adjust", enrich_top_n = 3, enrich_threshold = 0.05, fontsize = 8, heatmap_width = 8, heatmap_height = 8, mark_features = NULL, width = 16, height = 12, res = 300, suffix = "", device = "png", save = NULL )plot_modules_h( module, se_obj_merged, scale = TRUE, assay, ylabel = "Log2 abundance", profile_width = 3, profile_link_width = 1, enrich_list = NULL, enrich_category = "BP", enrich_rank_by = "p.adjust", enrich_top_n = 3, enrich_threshold = 0.05, fontsize = 8, heatmap_width = 8, heatmap_height = 8, mark_features = NULL, width = 16, height = 12, res = 300, suffix = "", device = "png", save = NULL )
module |
A data frame with columns "Feature" and "Module" |
se_obj_merged |
A SummarizedExperiment object, with one value for each
feature at each time point in each group (replicates merged). The colData of
the object should contain columns "Sample", "Group", and "Time". The object
can be produced by |
scale |
Whether to scale the data (z-score) across samples for each feature (default is TRUE) |
assay |
The assay to use in the SummarizedExperiment object: a numeric index or character name, e.g. 1 or "orig" for original data, 2 or "norm" for time 0 normalised data. (Required, no default.) |
ylabel |
Y axis label prefix (default is "Log2 abundance") |
profile_width |
Width of the mean expression profile panels in cm (default: 3) |
profile_link_width |
Width of the link between heatmap and mean expression profile panels in cm (default: 1) |
enrich_list |
A named enrichment list for modules,
as produced by |
enrich_category |
Category name(s) of enrichment to display:
a single string (e.g. |
enrich_rank_by |
Numeric column used to rank enrichment terms within
each module. A single string (default: |
enrich_top_n |
Top N enrichment terms per module. A single integer
(default: 3) is recycled for all categories in |
enrich_threshold |
P-value / adjusted p-value threshold for
colour-coding enrichment terms. A single value (default: 0.05) is
recycled for all categories; supply a vector of matching length for
per-category control. Terms below threshold are drawn in black,
terms above in grey70. Set to |
fontsize |
Base font size (default: 8) |
heatmap_width |
Width of the heatmap body in cm (default: 8) |
heatmap_height |
Height of the heatmap body in cm (default: 8).
Set to |
mark_features |
Features to label. Accepts two forms:
|
width |
Width of the saved image (default is 16 (cm)) |
height |
Height of the saved image (default is 12 (cm)) |
res |
Resolution of the saved image (except pdf format) (default: 300 (ppi)) |
suffix |
Suffix for the saved image file name (default: "") |
device |
Image file format(s) for saving. Can be a character
vector with one or more of |
save |
Directory to save the plot, no saving if is NULL (default is NULL) |
A combined plot of heatmap, mean expression profile, and enrichment terms for each WGCNA module
https://github.com/junjunlab/ClusterGVis
data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged <- merge_groups(example_obj_merged_list) data(example_net) # select two modules for demonstration example_module <- WGCNA_module(example_net) |> dplyr::filter(Module %in% c("1", "2")) data(example_go) plot_modules_h(example_module |> dplyr::filter(Module != '0'), example_obj_merged, assay = 2, scale = TRUE, ylabel = "Z-score of log2 expression", enrich_list = example_go$all, enrich_category = "BP", heatmap_width = 6, heatmap_height = 4)data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged <- merge_groups(example_obj_merged_list) data(example_net) # select two modules for demonstration example_module <- WGCNA_module(example_net) |> dplyr::filter(Module %in% c("1", "2")) data(example_go) plot_modules_h(example_module |> dplyr::filter(Module != '0'), example_obj_merged, assay = 2, scale = TRUE, ylabel = "Z-score of log2 expression", enrich_list = example_go$all, enrich_category = "BP", heatmap_width = 6, heatmap_height = 4)
Plot WGCNA modules' mean expression profiles and heatmaps, align vertically.
Different from running WGCNA, the input data should have the replicates merged, instead of having multiple samples per group, time and feature (gene).
If certain time points are missing in some groups, NA values are added.
plot_modules_v( module, se_obj_merged, scale = TRUE, assay, ylabel = "Log2 abundance", suffix = "", device = "png", save = NULL, width = 12, height = 8, height_ratio = 2, fontsize = 8, res = 300 )plot_modules_v( module, se_obj_merged, scale = TRUE, assay, ylabel = "Log2 abundance", suffix = "", device = "png", save = NULL, width = 12, height = 8, height_ratio = 2, fontsize = 8, res = 300 )
module |
A data frame with columns "Feature" and "Module" |
se_obj_merged |
A SummarizedExperiment object, with one value for each
feature at each time point in each group (replicates merged). The colData of
the object should contain columns "Sample", "Group", and "Time". The object
can be produced by |
scale |
Whether to scale the data (z-score) across samples for each feature (default is TRUE) |
assay |
The assay to use in the SummarizedExperiment object: a numeric index or character name, e.g. 1 or "orig" for original data, 2 or "norm" for time 0 normalised data. (Required, no default.) |
ylabel |
Y axis label prefix (default is "Log2 abundance") |
suffix |
Suffix for the saved image file name (default is an empty string) |
device |
Image file format(s) for saving. Can be a character
vector, e.g. |
save |
Directory to save the plot, no saving if is NULL (default is NULL) |
width |
Width of the saved image (default is 12 (cm)) |
height |
Height of the saved image (default is 8 (cm)) |
height_ratio |
Ratio of height of heatmap to the line plot (default is 2) |
fontsize |
Font size for the plot (default is 8) |
res |
Resolution of the saved image (except pdf format) (default is 300 (ppi)) |
Two plots aligned vertically by groups: the top one is a line plot of module feature mean expression profiles, the bottom one is a heatmap of feature expression across time points.
data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged <- merge_groups(example_obj_merged_list) data(example_net) example_module <- WGCNA_module(example_net) plot_modules_v(example_module |> dplyr::filter(Module != '0'), example_obj_merged, assay = 2, scale = TRUE, ylabel = "Z-score of log2 (expression)", height_ratio = 2, fontsize = 6)data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged <- merge_groups(example_obj_merged_list) data(example_net) example_module <- WGCNA_module(example_net) plot_modules_v(example_module |> dplyr::filter(Module != '0'), example_obj_merged, assay = 2, scale = TRUE, ylabel = "Z-score of log2 (expression)", height_ratio = 2, fontsize = 6)
Plot principal component analysis (PCA), using features without missing values
The samples are coloured by Group and sized by Time. Ellipses are drawn for each Group.
plot_pca( se_obj, plot_screeplot = TRUE, plot_loadings = TRUE, plot_morepc = TRUE, morepc = seq(1, 5), pc1 = 1, pc2 = 2, circle = FALSE, xlim_min = NULL, xlim_max = NULL, ylim_min = NULL, ylim_max = NULL, fontsize = 8, assay = 1 )plot_pca( se_obj, plot_screeplot = TRUE, plot_loadings = TRUE, plot_morepc = TRUE, morepc = seq(1, 5), pc1 = 1, pc2 = 2, circle = FALSE, xlim_min = NULL, xlim_max = NULL, ylim_min = NULL, ylim_max = NULL, fontsize = 8, assay = 1 )
se_obj |
A SummarizedExperiment object created by |
plot_screeplot |
Logical, whether to plot screeplot with
|
plot_loadings |
Logical, whether to plot loadings with
|
plot_morepc |
Logical, whether to plot pairs of more PCs with
|
morepc |
A numeric vector of PCs to plot in the pairs plot (default is 1:5) |
pc1 |
Numeric, which PC to use for the x-axis (default is 1) |
pc2 |
Numeric, which PC to use for the y-axis (default is 2) |
circle |
Logical, whether to draw circles (ellipses) around samples of each group (default is FALSE) |
xlim_min |
Minimum x-axis limit when drawing ellipses (default: NULL, auto-computed with 0.35x padding around the PC1 range) |
xlim_max |
Maximum x-axis limit when drawing ellipses (default: NULL, auto-computed with 0.35x padding around the PC1 range) |
ylim_min |
Minimum y-axis limit when drawing ellipses (default: NULL, auto-computed with 0.35x padding around the PC2 range) |
ylim_max |
Maximum y-axis limit when drawing ellipses (default: NULL, auto-computed with 0.35x padding around the PC2 range) |
fontsize |
Font size for the PCA plot (default is 8) |
assay |
The assay to use in the SummarizedExperiment object: a numeric index or character name, e.g. 1 or "orig" for original data, 2 or "norm" for time 0 normalised data. (Default: 1.) |
A PCA plot showing the distribution of samples, other plots provided by PCAtools package, and PCAtools output object for custom plotting.
data(example_obj) PC = plot_pca(example_obj, morepc = seq(1, 3))data(example_obj) PC = plot_pca(example_obj, morepc = seq(1, 3))
Plot principal component analysis (PCA) results in 3D. This
function takes the output PCA object of the plot_pca function and
visualizes the samples in a 3D space defined by the specified principal
components.
The samples are coloured by Group and sized by Time.
plot_pca_3D(pca, pcs = seq(1, 3))plot_pca_3D(pca, pcs = seq(1, 3))
pca |
A PCA object returned by the |
pcs |
A numeric vector specifying which three principal components to plot (default is 1:3) |
An interactive 3D PCA plot showing the distribution of samples in the space defined by the specified principal components. The samples are coloured by Group and sized by Time.
data(example_obj) PC = plot_pca(example_obj, morepc = seq(1, 3)) if (requireNamespace("plotly", quietly = TRUE)) { plot_pca_3D(PC$pca, pcs = seq(1, 3)) }data(example_obj) PC = plot_pca(example_obj, morepc = seq(1, 3)) if (requireNamespace("plotly", quietly = TRUE)) { plot_pca_3D(PC$pca, pcs = seq(1, 3)) }
Plot PCA with arrows indicating trajectory over time, for a single group.
plot_pca_arrows( se_obj, circle = TRUE, arrow = TRUE, pc1 = 1, pc2 = 2, fontsize = 8, assay = 1 )plot_pca_arrows( se_obj, circle = TRUE, arrow = TRUE, pc1 = 1, pc2 = 2, fontsize = 8, assay = 1 )
se_obj |
A SummarizedExperiment object (single group). |
circle |
Logical, whether to draw ellipses around samples of each time point (default: TRUE). |
arrow |
Logical, whether to draw arrows indicating the trajectory over time (default: TRUE). |
pc1 |
Principal component for the x-axis (default: 1). |
pc2 |
Principal component for the y-axis (default: 2). |
fontsize |
Font size for the plot (default is 8) |
assay |
The assay to use in the SummarizedExperiment object: a numeric index or character name, e.g. 1 or "orig" for original data, 2 or "norm" for time 0 normalised data. (Default: 1.) |
A PCA plot coloured by Time, with optional ellipses and trajectory arrows.
data(example_obj) plot_pca_arrows(example_obj[, example_obj$Group == "IFNbeta"])data(example_obj) plot_pca_arrows(example_obj[, example_obj$Group == "IFNbeta"])
Plot PCA for each group separately, with optional circles
around time points and arrows indicating trajectory over time. Accepts
either a SummarizedExperiment object or a list of them (from
split_groups()).
plot_pca_by_group( se_obj, circle = TRUE, arrow = TRUE, pc1 = 1, pc2 = 2, nrow = 1, fontsize = 8, assay = 1, legend_pos = "right" )plot_pca_by_group( se_obj, circle = TRUE, arrow = TRUE, pc1 = 1, pc2 = 2, nrow = 1, fontsize = 8, assay = 1, legend_pos = "right" )
se_obj |
A SummarizedExperiment object, or a named list of them
(e.g. from |
circle |
Logical, whether to draw ellipses around samples of each time point (default: TRUE). |
arrow |
Logical, whether to draw arrows indicating the trajectory over time (default: TRUE). |
pc1 |
Principal component for the x-axis (default: 1). |
pc2 |
Principal component for the y-axis (default: 2). |
nrow |
Number of rows for arranging the plots (default: 1). |
fontsize |
Font size for the plot (default is 8) |
assay |
The assay to use in the SummarizedExperiment object: a numeric index or character name, e.g. 1 or "orig" for original data, 2 or "norm" for time 0 normalised data. (Default: 1.) |
legend_pos |
Legend position (default: "right"). |
A series of PCA plots showing the distribution of samples in each group, coloured by Time.
data(example_obj) plot_pca_by_group(example_obj, circle = TRUE, arrow = TRUE) # Also accepts a list from split_groups() example_obj_list <- split_groups(example_obj) plot_pca_by_group(example_obj_list)data(example_obj) plot_pca_by_group(example_obj, circle = TRUE, arrow = TRUE) # Also accepts a list from split_groups() example_obj_list <- split_groups(example_obj) plot_pca_by_group(example_obj_list)
Plot segmented regression results for specified features
in each group, using the Trendy::plotFeature() function. The input is
a list of SummarizedExperiment objects with no missing values and a list
of Trendy analysis results for each group.
plot_segments( se_obj_imp_list, res_list, feature, group = NULL, nrow = NULL, ... )plot_segments( se_obj_imp_list, res_list, feature, group = NULL, nrow = NULL, ... )
se_obj_imp_list |
A list of SummarizedExperiment objects with no missing values |
res_list |
A list of the Trendy analysis results, output of
|
feature |
A character vector of feature names to be plotted |
group |
A character vector of group names to be analysed. If NULL, all groups in the input list will be used (default is NULL) |
nrow |
Number of rows in the plot layout. If NULL and multiple features are provided, it will be set to half the number of features (rounded up) (default is NULL) |
... |
Additional arguments to be passed to the |
Plots of the segmented regression fits for the specified features in each group.
data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged_list <- calc_feature_property(example_obj_merged_list, threshold = 0) # no missing value in the example dataset, so imputation is not necessary example_obj_merged_imp_list <- impute_groups(example_obj_merged_list) data("example_res_list") plot_segments(example_obj_merged_imp_list, example_res_list, feature = c("Kif3a"))data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged_list <- calc_feature_property(example_obj_merged_list, threshold = 0) # no missing value in the example dataset, so imputation is not necessary example_obj_merged_imp_list <- impute_groups(example_obj_merged_list) data("example_res_list") plot_segments(example_obj_merged_imp_list, example_res_list, feature = c("Kif3a"))
Plot trend of feature abundances / expression over time by
mean and standard deviation (SD) for each group. Accepts either a
SummarizedExperiment object (computing mean/SD internally via
calc_mean_sd()) or a pre-computed table from
calc_mean_sd().
plot_trend( se_obj, assay = 1, groups = NULL, features, title = NULL, ylabel = "Log2 abundance", errorbar = TRUE, fontsize = 8 )plot_trend( se_obj, assay = 1, groups = NULL, features, title = NULL, ylabel = "Log2 abundance", errorbar = TRUE, fontsize = 8 )
se_obj |
A SummarizedExperiment object, or a data.frame from
|
assay |
The assay to use in the SummarizedExperiment object: a numeric index or character name, e.g. 1 or "orig" for original data, 2 or "norm" for time 0 normalised data. (Default: 1.) |
groups |
Groups to be plotted, if NULL, all groups will be used (default is NULL) |
features |
Features to be plotted, if NULL, an error will be raised |
title |
Title of the plot. "Feature" if NULL (default). |
ylabel |
Y axis label of the plot (default is "Log2 abundance") |
errorbar |
Whether to plot error bars (default is TRUE) |
fontsize |
Font size for the plot (default is 8) |
Plot of feature abundances over time by mean and SD
data(example_obj) plot_trend(example_obj, features = sample(rownames(example_obj), 4))data(example_obj) plot_trend(example_obj, features = sample(rownames(example_obj), 4))
Plot UMAP of samples, using features without missing values
The UMAP plots are labelled by Group, Time, Replicate (if more than 1), Batch (if more than 1), and number of identified features (non-missing values).
plot_umap( se_obj, seed = 1234, plot_ID = FALSE, circle = FALSE, xlim_min = NULL, xlim_max = NULL, ylim_min = NULL, ylim_max = NULL, umap_neighbors = NULL, fontsize = 8, assay = 1 )plot_umap( se_obj, seed = 1234, plot_ID = FALSE, circle = FALSE, xlim_min = NULL, xlim_max = NULL, ylim_min = NULL, ylim_max = NULL, umap_neighbors = NULL, fontsize = 8, assay = 1 )
se_obj |
A SummarizedExperiment object created by |
seed |
Random seed for UMAP (default is 1234) |
plot_ID |
Whether to include a UMAP plot coloured by number of identified features (default is FALSE) |
circle |
Logical, whether to draw circles (ellipses) around samples of each group (default is FALSE) |
xlim_min |
Minimum x-axis limit when drawing ellipses (default: NULL, auto-computed with 0.35x padding around the UMAP x range) |
xlim_max |
Maximum x-axis limit when drawing ellipses (default: NULL, auto-computed with 0.35x padding around the UMAP x range) |
ylim_min |
Minimum y-axis limit when drawing ellipses (default: NULL, auto-computed with 0.35x padding around the UMAP y range) |
ylim_max |
Maximum y-axis limit when drawing ellipses (default: NULL, auto-computed with 0.35x padding around the UMAP y range) |
umap_neighbors |
UMAP n_neighbors parameter (default is selected by
|
fontsize |
Font size for the plot (default is 8) |
assay |
The assay to use in the SummarizedExperiment object: a numeric index or character name, e.g. 1 or "orig" for original data, 2 or "norm" for time 0 normalised data. (Default: 1.) |
A list of UMAP plots showing the distribution of samples. And a data frame containing UMAP coordinates and sample annotations for custom plotting.
data(example_obj) umap_layout <- plot_umap(example_obj)data(example_obj) umap_layout <- plot_umap(example_obj)
Plot UMAP for each group separately. Accepts either a
SummarizedExperiment object or a named list of them (from
split_groups()).
plot_umap_by_group( se_obj, seed = 1234, nrow = 1, umap_neighbors = NULL, fontsize = 8, assay = 1, legend_pos = "right" )plot_umap_by_group( se_obj, seed = 1234, nrow = 1, umap_neighbors = NULL, fontsize = 8, assay = 1, legend_pos = "right" )
se_obj |
A SummarizedExperiment object, or a named list of them
(e.g. from |
seed |
Random seed for UMAP (default: 1234). |
nrow |
Number of rows for arranging the plots (default: 1). |
umap_neighbors |
UMAP n_neighbors parameter (default: auto-selected based on sample count). |
fontsize |
Base font size (default: 8). |
assay |
The assay to use in the SummarizedExperiment object: a numeric index or character name, e.g. 1 or "orig" for original data, 2 or "norm" for time 0 normalised data. (Default: 1.) |
legend_pos |
Legend position (default: "right"). |
A series of UMAP plots showing the distribution of samples in each group, coloured by Time.
data(example_obj) plot_umap_by_group(example_obj) # Also accepts a list from split_groups() example_obj_list <- split_groups(example_obj) plot_umap_by_group(example_obj_list)data(example_obj) plot_umap_by_group(example_obj) # Also accepts a list from split_groups() example_obj_list <- split_groups(example_obj) plot_umap_by_group(example_obj_list)
Based on PALMO::variancefeaturePlot() function
plot_variance( var_decomp, rank = "Group", features = NULL, top_n = 20, show_ylab = TRUE, fontsize = 8 )plot_variance( var_decomp, rank = "Group", features = NULL, top_n = 20, show_ylab = TRUE, fontsize = 8 )
var_decomp |
A data frame output from |
rank |
Rank the plot by selected variable (default is "Group") |
features |
Features to be plotted (default is NULL) |
top_n |
Top n features ranked by |
show_ylab |
Whether to show y axis text (default is TRUE) |
fontsize |
Font size for the plot (default is 8) |
A stacked bar plot showing the percentage of variance explained
by each model component (Group, Time, Residual, plus Subject and
interaction terms when present). Features
are ranked by the specified rank variable (Group or Time) and only the
top n features are plotted if features is not specified.
data(example_obj) example_obj <- normalise_to_start(example_obj) var_decomp <- decomp_variance(example_obj, assay = 1) plot_variance(var_decomp, rank = "Time", top_n = 20)data(example_obj) example_obj <- normalise_to_start(example_obj) var_decomp <- decomp_variance(example_obj, assay = 1) plot_variance(var_decomp, rank = "Time", top_n = 20)
This function creates a volcano plot to visualize
the results of differential expression (DE) analysis performed by
DE_between_group() or DE_between_time(). The plot displays
log2 fold change on the x-axis and -log10 adjusted p-value on the
y-axis, with DE features highlighted based on specified thresholds.
If no thresholds are provided, the function will use the thresholds that
were applied when running DE_between_group() or DE_between_time().
plot_volcano( DE_out, group1, group2, time, group, time1, time2, logFC_thres = NULL, adjP_thres = NULL, label = FALSE, fontsize = 8, ... )plot_volcano( DE_out, group1, group2, time, group, time1, time2, logFC_thres = NULL, adjP_thres = NULL, label = FALSE, fontsize = 8, ... )
DE_out |
Output from |
group1 |
(Required for |
group2 |
(Required for |
time |
(Required for |
group |
(Required for |
time1 |
(Required for |
time2 |
(Required for |
logFC_thres |
Log2 fold change threshold for
highlighting DE features, default is NULL (using threshold when
|
adjP_thres |
Adjusted p-value threshold for
highlighting DE features, default is NULL (using threshold when
|
label |
Whether to label names of DE features on the plot (default is FALSE) |
fontsize |
Font size for the plot (default is 8) |
... |
Additional arguments for ggrepel::geom_text_repel() when label = TRUE |
A volcano plot of DE results
data(example_obj) example_obj <- normalise_to_start(example_obj) DE_between_group_out <- DE_between_group(example_obj, assay = 2) plot_volcano(DE_between_group_out, group1 = "untreated", group2 = "IFNbeta", time = 24, logFC_thres = 0.5, adjP_thres = 0.05, label = TRUE)data(example_obj) example_obj <- normalise_to_start(example_obj) DE_between_group_out <- DE_between_group(example_obj, assay = 2) plot_volcano(DE_between_group_out, group1 = "untreated", group2 = "IFNbeta", time = 24, logFC_thres = 0.5, adjP_thres = 0.05, label = TRUE)
Plot WGCNA module eigengenes and module-group/time correlations
based on output of run_WGCNA()
plot_WGCNA(net, fontsize = 8)plot_WGCNA(net, fontsize = 8)
net |
WGCNA network object output by |
fontsize |
Font size for plots (default is 8) |
Plots of WGCNA module dendrogram, module eigengenes, pairwise scatterplots of eigengenes, clustering of module eigengenes, and module-trait correlation heatmap
https://github.com/edo98811/WGCNA_official_documentation/blob/main/FemaleLiver-03-relateModsToExt.R
data(example_obj) example_obj <- normalise_to_start(example_obj) data("example_net") plot_WGCNA(example_net, fontsize = 8)data(example_obj) example_obj <- normalise_to_start(example_obj) data("example_net") plot_WGCNA(example_net, fontsize = 8)
One-step data preparation wrapper for TiDEomics: creates the SummarizedExperiment object, normalises to starting time point, filters out group-specific features, runs variance decomposition, and filters out noisy features with high residual variance. Returns both unmerged and merged (mean of replicates) outputs, with all-feature and filtered versions of each, ready for downstream analysis.
prepare_tide( data, sample_ann, subject_col = NULL, replicate_col = NULL, batch_col = NULL, feature_threshold = 0, filter_ratio = 0.5, min_groups = 2, keep = c("below_quantile", "top_n", "threshold"), residual_threshold = NULL, n_keep = 5000, interaction = FALSE, n_cores = 1 )prepare_tide( data, sample_ann, subject_col = NULL, replicate_col = NULL, batch_col = NULL, feature_threshold = 0, filter_ratio = 0.5, min_groups = 2, keep = c("below_quantile", "top_n", "threshold"), residual_threshold = NULL, n_keep = 5000, interaction = FALSE, n_cores = 1 )
data |
A data frame with rows as features (e.g., genes, proteins) and columns as samples. The first column should contain feature identifiers (e.g., gene symbols) and be named 'Feature'. The data should have been normalised and log transformed. Missing values are allowed. |
sample_ann |
A data frame containing sample annotations with required columns: 'Sample', 'Group', and 'Time'. 'Replicate' and 'Batch' are optional columns and will be auto-generated if not provided. 'Time', 'Replicate' and 'Batch' should be numeric. |
subject_col |
Optional: name of a column in |
replicate_col |
Optional: name of a column in |
batch_col |
Optional: name of a column in |
feature_threshold |
Threshold for |
filter_ratio |
Minimum ratio of time points a feature must be expressed
in, to be considered expressed in a group (default: 0.5, meaning that a
feature must be > feature_threshold in >=50% time points in a group to be
considered expressed). Passed to |
min_groups |
Minimum number of groups a feature must be expressed in,
with the above filter_ratio, to pass the cross group filter
(default: 2). Passed to |
keep |
How to select features after variance decomposition:
|
residual_threshold |
Numeric: when |
n_keep |
Number of features to keep when |
interaction |
Passed to |
n_cores |
Number of cores for variance decomposition (default: 1). |
The pipeline:
create_input(): validate and build SE
normalise_to_start(): add time-0-normalised assay
split_groups() -> merge_replicates() -> calc_feature_property()
-> summarise_feature_property(): per-feature expression statistics
group_specific_features(): filter out group-specific features
decomp_variance() : LMM variance decomposition on both "orig"
and "norm" assays
Residual filter: filter out features with high residual
variance, calculated from decomp_variance() on each assay
Produce filtered-unmerged and filtered-merged SEs for each assay
A named list with elements. The elements suffixed with "_filtered" have passed both the cross-group and residual filters, and are split into $orig and $norm sub-lists, with variance decomposition and residual filtering done per assay.
se (SE with replicates, all features, both assays);
se_filtered (a list of two SEs with replicates,
filtered features by orig / norm, use for WGCNA);
merged_list (per-group merged SEs, all features, use for Trendy);
merged_list_filtered (a list of two per-group merged SEs,
filtered features by orig / norm);
merged_se (single merged SE, all groups combined, all features,
use for plot_modules_v/h);
merged_se_filtered (a list of two single merged SEs, filtered features
by orig / norm, use for plot_modules_v/h);
variance (a list of two variance decomposition data.frames,
computed from orig / norm assay);
feature_property (feature property summary, all features);
filter_summary (per-stage filtering statistics);
group_specific_filter (a vector of group-specific features,
removed by the cross-group filter);
11-13. DE, enrichment, WGCNA (empty on initialization).
data(tutorial_data) data(tutorial_sample_info) tide <- prepare_tide(tutorial_data, tutorial_sample_info, keep = "threshold", residual_threshold = 100) tide$filter_summarydata(tutorial_data) data(tutorial_sample_info) tide <- prepare_tide(tutorial_data, tutorial_sample_info, keep = "threshold", residual_threshold = 100) tide$filter_summary
Prepare input data for WGCNA (format, QC), then choose the appropriate soft thresholding power for network construction, by analysing scale free topology with different soft thresholding powers.
prepare_WGCNA( se_obj, assay, networkType = "signed", RsquaredCut = 0.8, MeanConnectivity = 100, powers = NULL, fontsize = 8, ... )prepare_WGCNA( se_obj, assay, networkType = "signed", RsquaredCut = 0.8, MeanConnectivity = 100, powers = NULL, fontsize = 8, ... )
se_obj |
A SummarizedExperiment object. Data
normalised to time point 0 can be in the second assay slot, created by
|
assay |
The assay to use in the SummarizedExperiment object: a numeric index or character name, e.g. 1 or "orig" for original data, 2 or "norm" for time 0 normalised data. (Required, no default.) |
networkType |
Parameter of |
RsquaredCut |
Parameter of |
MeanConnectivity |
Line of mean connectivity (default is 100) |
powers |
Parameter of |
fontsize |
Font size for the plot (default is 8) |
... |
Additional parameters to be passed to |
A list containing results of the scale-free topology
fit indices with different powers, suggested power, network type and prepared
input data used for reuse in run_WGCNA()
https://github.com/edo98811/WGCNA_official_documentation/
data(example_obj) example_obj <- normalise_to_start(example_obj) wgcna_input <- prepare_WGCNA(example_obj, assay = 2, powers = seq(1, 30), networkType = "signed", RsquaredCut = 0.8) wgcna_input$fitIndices picked_power <- wgcna_input$powerEstimatedata(example_obj) example_obj <- normalise_to_start(example_obj) wgcna_input <- prepare_WGCNA(example_obj, assay = 2, powers = seq(1, 30), networkType = "signed", RsquaredCut = 0.8) wgcna_input$fitIndices picked_power <- wgcna_input$powerEstimate
Run segmented regression analysis with Trendy on imputed data for multiple groups of samples in a list of SummarizedExperiment objects. The results will be returned in a list format. Each element in the list corresponds to one group of samples and contains the Trendy analysis results for that group.
If the feature parameter is not specified, all features expressed in at
least minExp time points in each group will be included in the analysis
for the
group. calc_feature_property() should be run before imputation to
calculate the expression ratio for each feature in each group.
Missing values can be
imputed after calc_feature_property() using the impute_groups() function.
If a group has less than 4 time points are available, Trendy analysis cannot be performed and NULL will be returned for the group.
run_Trendy( se_obj_imp_list, group = NULL, feature = NULL, minExp = 0.5, maxK = 1, meanCut = 0, minNumInSeg = 3, NCores = 1, ... )run_Trendy( se_obj_imp_list, group = NULL, feature = NULL, minExp = 0.5, maxK = 1, meanCut = 0, minNumInSeg = 3, NCores = 1, ... )
se_obj_imp_list |
A list of SummarizedExperiment objects with no missing values |
group |
A character vector of group names to be analysed. If NULL, all groups in the input list will be used (default is NULL) |
feature |
A character vector of feature names to be included in the
analysis. If NULL, all features with expression ratio (Exp_ratio) >= minExp
will be
used, based on results of |
minExp |
Minimum expression ratio for a feature to be included in the analysis (default is 0.5) |
maxK |
Parameter of |
meanCut |
Parameter of |
minNumInSeg |
Parameter of |
NCores |
Number of cores to use for parallel processing (default is 1) |
... |
Additional arguments to be passed to the |
A list of Trendy analysis results, including the fitted model parameters and statistics for each feature in each group.
data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged_list <- calc_feature_property(example_obj_merged_list, threshold = 0) # no missing value in the example dataset, so imputation is not necessary example_obj_merged_imp_list <- impute_groups(example_obj_merged_list) # "untreated" group has only 3 time points, so Trendy analysis will not be # performed for this group example_res_list <- run_Trendy(example_obj_merged_imp_list, maxK = 1, minNumInSeg = 2, meanCut = 0, feature = rownames(example_obj_merged_imp_list[[1]])[1:10])data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged_list <- calc_feature_property(example_obj_merged_list, threshold = 0) # no missing value in the example dataset, so imputation is not necessary example_obj_merged_imp_list <- impute_groups(example_obj_merged_list) # "untreated" group has only 3 time points, so Trendy analysis will not be # performed for this group example_res_list <- run_Trendy(example_obj_merged_imp_list, maxK = 1, minNumInSeg = 2, meanCut = 0, feature = rownames(example_obj_merged_imp_list[[1]])[1:10])
Run WGCNA based on output of prepare_WGCNA(), to
identify co-expression modules of features with WGCNA::blockwiseModules()
run_WGCNA(wgcna_input, power, numericLabels = TRUE, ...)run_WGCNA(wgcna_input, power, numericLabels = TRUE, ...)
wgcna_input |
A list output by |
power |
Soft-thresholding power to be used in
|
numericLabels |
Whether to use numeric labels for modules in the output (default is TRUE) |
... |
Additional parameters to be passed to |
The built network and parameters of WGCNA::blockwiseModules(),
and the input data and sample information for use in plot_WGCNA().
https://github.com/edo98811/WGCNA_official_documentation/blob/main/FemaleLiver-03-relateModsToExt.R
data(example_obj) example_obj <- normalise_to_start(example_obj) wgcna_input <- prepare_WGCNA(example_obj, assay = 2, powers = seq(1, 30), networkType = "signed", RsquaredCut = 0.8) wgcna_input$fitIndices picked_power <- wgcna_input$powerEstimate example_net <- run_WGCNA(wgcna_input, power = picked_power, minModuleSize = 10, # only 100 genes in the example data numericLabels = TRUE)data(example_obj) example_obj <- normalise_to_start(example_obj) wgcna_input <- prepare_WGCNA(example_obj, assay = 2, powers = seq(1, 30), networkType = "signed", RsquaredCut = 0.8) wgcna_input$fitIndices picked_power <- wgcna_input$powerEstimate example_net <- run_WGCNA(wgcna_input, power = picked_power, minModuleSize = 10, # only 100 genes in the example data numericLabels = TRUE)
Set a custom color palette for groups to use in all subsequent plotting functions that support custom palettes.
set_custom_palette(palette)set_custom_palette(palette)
palette |
A named vector where names correspond to group names
and values are the corresponding colors (e.g., |
The function does not return a value but sets the custom palette as an option that can be accessed by other plotting functions. The palette will be stored in the R session options under the name "custom.palette".
custom_palette <- c("untreated" = "#1b9e77", "IFNbeta" = "#d95f02", "IFNgamma" = "#7570b3", "LPS" = "#e7298a") set_custom_palette(custom_palette)custom_palette <- c("untreated" = "#1b9e77", "IFNbeta" = "#d95f02", "IFNgamma" = "#7570b3", "LPS" = "#e7298a") set_custom_palette(custom_palette)
Split SummarizedExperiment object by groups
split_groups(se_obj)split_groups(se_obj)
se_obj |
A SummarizedExperiment object created by |
A list of SummarizedExperiment objects for each group in the input object. Each object in the list corresponds to one group of samples.
data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj)data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj)
This function takes a list of merged SummarizedExperiment
objects, which are the output of the calc_feature_property() function,
and summarizes the feature properties across all groups. It extracts the
row data from each SummarizedExperiment object, combines them into a
single data frame, and returns this summary data frame. Each row in the
resulting data frame represents a feature, and the columns contain the
properties of that feature for each group, including the feature name,
group name, proportion of NA values for that feature in that group,
randomness p-value, and maximum fold change over time.
summarise_feature_property(se_obj_merged_list)summarise_feature_property(se_obj_merged_list)
se_obj_merged_list |
A list of merged |
A data frame summarizing the feature properties across all groups, with each row representing a feature and columns containing the properties including the feature name, group name, and the proportion of NA values for that feature in that group, randomness p-value, and maximum fold change over time.
data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged_list <- calc_feature_property(example_obj_merged_list, threshold = 0) property_random_fc <- summarise_feature_property(example_obj_merged_list)data(example_obj) example_obj <- normalise_to_start(example_obj) example_obj_list <- split_groups(example_obj) example_obj_merged_list <- merge_replicates(example_obj_list) example_obj_merged_list <- calc_feature_property(example_obj_merged_list, threshold = 0) property_random_fc <- summarise_feature_property(example_obj_merged_list)
Computes per-module metrics for a WGCNA network: module size, proportion of features assigned, and module membership (kME). Unassigned module is excluded.
summarise_module_metrics(net)summarise_module_metrics(net)
net |
A WGCNA network object from |
MeanKME and MeanKME2 are the mean and mean squared module
membership (kME = cor(feature, module eigengene)).
MeanKME2 = mean(kME^2) is the average proportion
of per-feature variance explained by the module eigengene.
A data frame with columns: Module, Size,
Proportion, MeanKME, MeanKME2, MedianKME, SDKME,
MinKME, MaxKME.
data(example_net) summarise_module_metrics(example_net)data(example_net) summarise_module_metrics(example_net)
Summarise module patterns by integrating WGCNA output with Trendy results
summarise_module_pattern(module, trendy_summary)summarise_module_pattern(module, trendy_summary)
module |
A data frame with columns "Feature" and "Module" |
trendy_summary |
A data frame of trendy results, output of
|
A list of data frames, each data frame shows the pattern counts in a module
data("example_res_list") trendy_summary <- summarise_Trendy(example_res_list) data(example_net) example_module <- WGCNA_module(example_net) summarise_module_pattern(example_module, trendy_summary)data("example_res_list") trendy_summary <- summarise_Trendy(example_res_list) data(example_net) example_module <- WGCNA_module(example_net) summarise_module_pattern(example_module, trendy_summary)
Summarise Trendy results into data frame
summarise_Trendy(res_list, ...)summarise_Trendy(res_list, ...)
res_list |
A list of Trendy analysis results, output of |
... |
Additional arguments to be passed to the |
A data frame of summary results of Trendy, including breakpoints, segment slopes and p-values for each fitted feature in each group. A "Pattern" column is added to show the combination of segment trends (up, down, stable) for each feature.
data("example_res_list") trendy_summary <- summarise_Trendy(example_res_list)data("example_res_list") trendy_summary <- summarise_Trendy(example_res_list)
A minimal theme used by all TiDEomics plotting functions, built on
theme_minimal(). Exported so users can apply it to their own plots
for consistent styling.
theme_custom(base_size = 8, panel_border = FALSE, legend_position = "right")theme_custom(base_size = 8, panel_border = FALSE, legend_position = "right")
base_size |
Base font size (default: 8). |
panel_border |
Logical, whether to draw a border around the panel (default: FALSE). |
legend_position |
Legend position (default: "right"). |
A ggplot2 theme object.
library(ggplot2) ggplot(mtcars, aes(wt, mpg)) + geom_point() + theme_custom(base_size = 10)library(ggplot2) ggplot(mtcars, aes(wt, mpg)) + geom_point() + theme_custom(base_size = 10)
A subset of GSE263759 data set published in Integrated time-series analysis and high-content CRISPR screening delineate the dynamics of macrophage immune regulation
data(tutorial_data)data(tutorial_data)
A data.frame with 500 rows and 41 variables:
Feature ID, e.g. gene symbols
log2(CPM + 1) normalised expression values
Code for preparing the data is available in inst/script/tutorial_input.R
Ensembl IDs were mapped to symbols, genes with all zero counts were excluded.
Use time 0 untreated samples for other groups' time 0.
Include "untreated", "IFNbeta", "IFNgamma", "LPS" groups.
Sample 500 random genes.
Normalised to log2(CPM + 1).
GSE263759
A subset of GSE263759 data set published in Integrated time-series analysis and high-content CRISPR screening delineate the dynamics of macrophage immune regulation
data(tutorial_sample_info)data(tutorial_sample_info)
A data.frame with 40 rows and 5 variables:
Sample ID
Experimental group (untreated, different treatments)
Time point
Replicate ID for each group and time point
Batch information
Code for preparing the data is available in inst/script/tutorial_input.R
Ensembl IDs were mapped to symbols, genes with all zero counts were excluded.
Use time 0 untreated samples for other groups' time 0.
Include "untreated", "IFNbeta", "IFNgamma", "LPS" groups.
Sample 500 random genes.
GSE263759
Converts the module assignments from run_WGCNA() output
into two-column data.frame with Feature and Module columns,
expected by plot_modules_v(),
plot_modules_h(), summarise_module_pattern(), and all enrichment
functions.
WGCNA_module(net, exclude_grey = FALSE)WGCNA_module(net, exclude_grey = FALSE)
net |
The output of |
exclude_grey |
Logical. If |
A data.frame with columns Feature (character) and Module
(factor ordered by decreasing module size). When exclude_grey = TRUE,
grey/unassigned features are excluded.
data(example_net) module <- WGCNA_module(example_net)data(example_net) module <- WGCNA_module(example_net)