| Title: | Horizontal Integration and Analysis of Multiple Transcriptomics Datasets |
|---|---|
| Description: | Tools for the joint analysis of multiple transcriptomics datasets using a network-based integration approach. The package provides an S4 object model based on MultiAssayExperiment for reproducible analysis of single-layer and multi-layer studies. It includes workflows for clustering, module visualization, functional annotation, upstream inference, and longitudinal follow-up while retaining compatibility helpers for legacy hCoCena objects. |
| Authors: | Thomas Ulas [aut, cre] (ORCID: <https://orcid.org/0000-0002-9785-4197>), Waqar Hanif [ctb] |
| Maintainer: | Thomas Ulas <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.99.12 |
| Built: | 2026-10-04 00:56:38 UTC |
| Source: | https://github.com/BiocStaging/hcocena |
Creates an annotation column that combines donor meta-cluster assignment and
timepoint labels (e.g. MC1__24h). This column can be used as grouping_v
in hc_run_expression_analysis_2() to build a cluster heatmap by
meta-cluster x timepoint.
hc_add_meta_time_grouping( hc, donor_col = "Subject", time_col = "Time_token", grouping_col = "meta_cluster_time", slot_name = "longitudinal_endotypes", layer = "all", time_levels = NULL, meta_cluster_levels = NULL, separator = "__", append_layer_suffix = FALSE )hc_add_meta_time_grouping( hc, donor_col = "Subject", time_col = "Time_token", grouping_col = "meta_cluster_time", slot_name = "longitudinal_endotypes", layer = "all", time_levels = NULL, meta_cluster_levels = NULL, separator = "__", append_layer_suffix = FALSE )
hc |
A |
donor_col |
Annotation column containing donor IDs. |
time_col |
Annotation column containing timepoint labels. |
grouping_col |
Name of the new annotation column to create. |
slot_name |
Satellite slot holding longitudinal outputs. Must contain
|
layer |
Layer index, layer id/name, or |
time_levels |
Optional explicit timepoint order vector. |
meta_cluster_levels |
Optional explicit meta-cluster order vector. |
separator |
String between meta-cluster and timepoint labels. |
append_layer_suffix |
Logical. If |
Updated HCoCenaExperiment. The computed order is stored in
hc@satellite[[slot_name]]$meta_time_grouping and/or the resolved
per-layer step 2 slots.
hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) hc <- hc_add_meta_time_grouping(hc, donor_col = "donor", time_col = "timepoint")hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) hc <- hc_add_meta_time_grouping(hc, donor_col = "donor", time_col = "timepoint")
Alluvial comparison plots (S4 API)
hc_algo_alluvial(hc)hc_algo_alluvial(hc)
hc |
A |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_algo_alluvial(hc)hc <- hc_example_data("clustered") hc <- hc_algo_alluvial(hc)
Inverse of base::log() for an arbitrary base, i.e. hc_antilog(x, 2)
returns 2^x.
hc_antilog(lx, base)hc_antilog(lx, base)
lx |
Numeric vector, matrix or data frame of logged values. |
base |
The base the logarithm was taken to. |
The de-logged values, in the same shape as lx.
hc_antilog(c(1, 2, 3), base = 2)hc_antilog(c(1, 2, 3), base = 2)
Resolve and apply standard paths in one call
hc_auto_set_paths( hc, project_root_hint = NULL, local_count_subdir = "count_data", local_annotation_subdir = "annotation_data", local_reference_subdir = "reference_files", local_output_subdir = "output", docker_reference_dir = "/home/rstudio/reference_files", docker_count_dir = "/home/rstudio/count_data", docker_annotation_dir = "/home/rstudio/annotation_data", docker_output_dir = "/home/rstudio/output", create_docker_dirs = TRUE, fallback_count_data = "PATH_TO_FOLDER_THAT_HOLDS_YOUR_GENE_EXPRESSION_TABLES/", fallback_annotation = "PATH_TO_FOLDER_THAT_HOLDS_YOUR_ANNOTATION_TABLES/", fallback_reference_files = "PATH_TO_REFERENCE_FILES_FOLDER/", fallback_output = "PATH_TO_FOLDER_WHERE_HCOCENA_SHOULD_SAVE_ALL_ANALYSIS_OUTPUTS/", dir_count_data = NULL, dir_annotation = NULL, dir_reference_files = NULL, dir_output = NULL )hc_auto_set_paths( hc, project_root_hint = NULL, local_count_subdir = "count_data", local_annotation_subdir = "annotation_data", local_reference_subdir = "reference_files", local_output_subdir = "output", docker_reference_dir = "/home/rstudio/reference_files", docker_count_dir = "/home/rstudio/count_data", docker_annotation_dir = "/home/rstudio/annotation_data", docker_output_dir = "/home/rstudio/output", create_docker_dirs = TRUE, fallback_count_data = "PATH_TO_FOLDER_THAT_HOLDS_YOUR_GENE_EXPRESSION_TABLES/", fallback_annotation = "PATH_TO_FOLDER_THAT_HOLDS_YOUR_ANNOTATION_TABLES/", fallback_reference_files = "PATH_TO_REFERENCE_FILES_FOLDER/", fallback_output = "PATH_TO_FOLDER_WHERE_HCOCENA_SHOULD_SAVE_ALL_ANALYSIS_OUTPUTS/", dir_count_data = NULL, dir_annotation = NULL, dir_reference_files = NULL, dir_output = NULL )
hc |
A |
project_root_hint |
Optional local project root to prioritize if it exists. If missing or not found, the current working directory is used. |
local_count_subdir |
Local count-data subfolder below |
local_annotation_subdir |
Local annotation-data subfolder below |
local_reference_subdir |
Local reference-files subfolder below |
local_output_subdir |
Local output subfolder below |
docker_reference_dir |
Docker reference-files directory used to detect Docker mode. |
docker_count_dir |
Docker count-data directory. |
docker_annotation_dir |
Docker annotation-data directory. |
docker_output_dir |
Docker output directory. |
create_docker_dirs |
Boolean. If TRUE and Docker mode is detected, create the Docker directories when missing. |
fallback_count_data |
Fallback count-data directory string used outside Docker when no local folder was detected. |
fallback_annotation |
Fallback annotation directory string used outside Docker when no local folder was detected. |
fallback_reference_files |
Fallback reference-files directory string used outside Docker when no local folder was detected. |
fallback_output |
Fallback output directory string used outside Docker when no local folder was detected. |
dir_count_data |
Optional explicit override for count-data directory. |
dir_annotation |
Optional explicit override for annotation directory. |
dir_reference_files |
Optional explicit override for reference-files directory. |
dir_output |
Optional explicit override for output directory. |
Updated HCoCenaExperiment.
root <- file.path(tempdir(), "hcocena-auto-paths") dir.create(file.path(root, "reference_files"), recursive = TRUE, showWarnings = FALSE) dir.create(file.path(root, "output"), recursive = TRUE, showWarnings = FALSE) hc <- hc_init() hc <- hc_auto_set_paths( hc, project_root_hint = root, local_count_subdir = NULL, local_annotation_subdir = NULL ) as.data.frame(methods::slot(hc_config(hc), "paths"))root <- file.path(tempdir(), "hcocena-auto-paths") dir.create(file.path(root, "reference_files"), recursive = TRUE, showWarnings = FALSE) dir.create(file.path(root, "output"), recursive = TRUE, showWarnings = FALSE) hc <- hc_init() hc <- hc_auto_set_paths( hc, project_root_hint = root, local_count_subdir = NULL, local_annotation_subdir = NULL ) as.data.frame(methods::slot(hc_config(hc), "paths"))
hc_auto_tune() recommends and optionally applies:
Layer-wise cutoffs based on run_expression_analysis_1() output.
Clustering settings based on modularity across candidate algorithms.
hc_auto_tune( hc, tune_cutoff = TRUE, tune_clustering = TRUE, apply = TRUE, cluster_algorithms = c("auto", "cluster_leiden", "cluster_louvain"), resolution_grid = base::seq(0.05, 0.5, by = 0.05), no_of_iterations = 2, partition_type = "RBConfigurationVertexPartition", max_cluster_count_per_gene = 1, module_count_bounds = c(3, 60), prefer_resolution = 0.1, verbose = TRUE )hc_auto_tune( hc, tune_cutoff = TRUE, tune_clustering = TRUE, apply = TRUE, cluster_algorithms = c("auto", "cluster_leiden", "cluster_louvain"), resolution_grid = base::seq(0.05, 0.5, by = 0.05), no_of_iterations = 2, partition_type = "RBConfigurationVertexPartition", max_cluster_count_per_gene = 1, module_count_bounds = c(3, 60), prefer_resolution = 0.1, verbose = TRUE )
hc |
A |
tune_cutoff |
Logical; tune per-layer correlation cutoffs. |
tune_clustering |
Logical; tune clustering algorithm / resolution. |
apply |
Logical; if |
cluster_algorithms |
Character vector of candidate algorithms for
clustering tuning. Supported: |
resolution_grid |
Numeric vector of Leiden resolutions to evaluate for
|
no_of_iterations |
Passed to |
partition_type |
Passed to |
max_cluster_count_per_gene |
Passed to |
module_count_bounds |
Optional length-2 numeric vector
( |
prefer_resolution |
Tie-break preference for Leiden resolution. |
verbose |
Logical; print progress messages. |
The tuning report is stored in hc@satellite$auto_tune.
Updated HCoCenaExperiment with tuning report in
hc@satellite$auto_tune.
hc <- hc_example_data("after_part1") hc <- hc_auto_tune(hc, apply = FALSE)hc <- hc_example_data("after_part1") hc <- hc_auto_tune(hc, apply = FALSE)
Alternative cutoff tuning method that can be compared against the current simple cutoff recommendation.
hc_auto_tune_cutoff_tiered( hc, apply = FALSE, tier1_sft_min = 0.85, tier1_mean_k_min = 10, tier2_sft_min = 0.8, tier2_mean_k_min = 5, fallback_sft_min = 0.7, require_negative_slope = TRUE, max_no_networks = NULL, max_components = NULL, min_node_fraction = NULL, fallback_respect_base_filters = TRUE, verbose = TRUE )hc_auto_tune_cutoff_tiered( hc, apply = FALSE, tier1_sft_min = 0.85, tier1_mean_k_min = 10, tier2_sft_min = 0.8, tier2_mean_k_min = 5, fallback_sft_min = 0.7, require_negative_slope = TRUE, max_no_networks = NULL, max_components = NULL, min_node_fraction = NULL, fallback_respect_base_filters = TRUE, verbose = TRUE )
hc |
A |
apply |
Logical; if |
tier1_sft_min |
Numeric minimum SFT fit ( |
tier1_mean_k_min |
Numeric minimum mean connectivity ( |
tier2_sft_min |
Numeric minimum SFT fit ( |
tier2_mean_k_min |
Numeric minimum mean connectivity ( |
fallback_sft_min |
Numeric lower bound for |
require_negative_slope |
Logical; require a negative slope ( |
max_no_networks |
Optional numeric scalar. If set, only cutoffs with
|
max_components |
Deprecated alias for |
min_node_fraction |
Optional numeric in |
fallback_respect_base_filters |
Logical; if |
verbose |
Logical; print per-layer recommendation messages. |
For each layer, the function:
Summarizes cutoff statistics.
Computes additional diagnostics (slope, mean_k).
Applies a staged rule set (strict, relaxed, best_available).
Results are stored in hc@satellite$cutoff_tuning
(and mirrored to hc@satellite$auto_tune_cutoff_tiered for compatibility).
Updated HCoCenaExperiment with a report in
hc@satellite$cutoff_tuning.
hc <- hc_example_data("after_part1") hc <- hc_auto_tune_cutoff_tiered(hc, apply = FALSE, verbose = FALSE)hc <- hc_example_data("after_part1") hc <- hc_auto_tune_cutoff_tiered(hc, apply = FALSE, verbose = FALSE)
The previously constructed layer-specific networks are being integrated.
hc_build_integrated_network( hc, mode = "u", with = NULL, multi_edges = "min", GFC_when_missing = NULL )hc_build_integrated_network( hc, mode = "u", with = NULL, multi_edges = "min", GFC_when_missing = NULL )
hc |
A |
mode |
A string, either "u", if network integration is to be done by union (default), or "i", if integration is to be done by intersection. For details please refer to the information pages provided in the repository's Wiki. |
with |
Either an integer giving the number of the dataset to be used as reference (e.g., 1) or the name given to the layer. Can be ignored when integration is done by union. |
multi_edges |
One of "min", "mean" or "max" resulting in the simplification of the multigraph by using the minimum, the mean or the maximum edge weight among the multiple edges, respectively. Multiple edges occur when the edge was present in more than one datset. |
GFC_when_missing |
The value to substitute missing data in the case where some genes were not measured in all but only some of the datasets. |
Updated HCoCenaExperiment.
hc <- hc_example_data("after_part2") hc <- hc_build_integrated_network(hc, mode = "u")hc <- hc_example_data("after_part2") hc <- hc_build_integrated_network(hc, mode = "u")
Module cell-type activity from Enrichr markers via decoupleR (S4 API)
hc_celltype_activity_decoupler( hc, databases = c("Descartes_Cell_Types_and_Tissue_2021", "Human_Gene_Atlas"), custom_gmt_files = NULL, clusters = c("all"), mode = c("coarse", "fine"), top = 3, qval = 0.1, padj = "BH", activity_input = c("gfc", "fc", "expression"), fc_comparisons = NULL, method = "ulm", minsize = 5, min_term_genes = 5, annotation_slot = c("auto", "enriched_per_cluster", "enriched_per_cluster2"), slot_suffix = "decoupler", clear_previous_slots = FALSE, coarse_map = NULL, coarse_include_other = TRUE, refresh_db = FALSE, export_excel = TRUE, excel_file = "Module_Celltype_Activity_decoupler.xlsx", plot_heatmap = FALSE, heatmap_file_name = "Heatmap_modules_celltype_activity_decoupler.pdf", ... )hc_celltype_activity_decoupler( hc, databases = c("Descartes_Cell_Types_and_Tissue_2021", "Human_Gene_Atlas"), custom_gmt_files = NULL, clusters = c("all"), mode = c("coarse", "fine"), top = 3, qval = 0.1, padj = "BH", activity_input = c("gfc", "fc", "expression"), fc_comparisons = NULL, method = "ulm", minsize = 5, min_term_genes = 5, annotation_slot = c("auto", "enriched_per_cluster", "enriched_per_cluster2"), slot_suffix = "decoupler", clear_previous_slots = FALSE, coarse_map = NULL, coarse_include_other = TRUE, refresh_db = FALSE, export_excel = TRUE, excel_file = "Module_Celltype_Activity_decoupler.xlsx", plot_heatmap = FALSE, heatmap_file_name = "Heatmap_modules_celltype_activity_decoupler.pdf", ... )
hc |
A |
databases |
Character vector of Enrichr library names. |
custom_gmt_files |
Optional custom GMT file(s) to include as additional marker resources. Accepts a character vector or named list of file paths. |
clusters |
Either |
mode |
Either |
top |
Number of selected marker activities per module. |
qval |
Adjusted p-value cutoff. |
padj |
Multiple-testing correction method. |
activity_input |
One of |
fc_comparisons |
Vector like |
method |
decoupleR method suffix (e.g. |
minsize |
Minimum target size passed to decoupleR. |
min_term_genes |
Minimum genes per Enrichr term. |
annotation_slot |
Legacy slot override for single-database runs. |
slot_suffix |
Optional slot suffix; default |
clear_previous_slots |
If TRUE, clears old |
coarse_map |
Optional named regex map used in coarse mode. |
coarse_include_other |
Keep |
refresh_db |
Refresh Enrichr cache. |
export_excel |
Write summary workbook. |
excel_file |
Excel filename. |
plot_heatmap |
Replot cluster heatmap with dynamic slots. |
heatmap_file_name |
Heatmap filename when |
... |
Further arguments passed through to the underlying
implementation. Every supported argument is documented on this page;
|
Updated HCoCenaExperiment.
if (requireNamespace("decoupleR", quietly = TRUE)) { hc <- hc_example_data("clustered") gmt <- system.file("extdata", "toy_celltype_markers.gmt", package = "hcocena") hc <- hc_celltype_activity_decoupler( hc, databases = character(0), custom_gmt_files = c(CellTypes = gmt), export_excel = FALSE ) names(hc_satellite(hc, "celltype_activity_decoupler")) }if (requireNamespace("decoupleR", quietly = TRUE)) { hc <- hc_example_data("clustered") gmt <- system.file("extdata", "toy_celltype_markers.gmt", package = "hcocena") hc <- hc_celltype_activity_decoupler( hc, databases = character(0), custom_gmt_files = c(CellTypes = gmt), export_excel = FALSE ) names(hc_satellite(hc, "celltype_activity_decoupler")) }
Module cell-type annotation from Enrichr (S4 API)
hc_celltype_annotation( hc, databases = c("Descartes_Cell_Types_and_Tissue_2021", "Human_Gene_Atlas"), custom_gmt_files = NULL, clusters = c("all"), mode = c("coarse", "fine"), top = 3, qval = 0.1, padj = "BH", min_term_genes = 5, min_gs_size = 10, max_gs_size = 5000, annotation_slot = c("auto", "enriched_per_cluster", "enriched_per_cluster2"), slot_suffix = NULL, clear_previous_slots = TRUE, coarse_map = NULL, coarse_include_other = TRUE, refresh_db = FALSE, export_excel = TRUE, excel_file = "Module_Celltype_Annotation.xlsx", plot_heatmap = FALSE, heatmap_file_name = "Heatmap_modules_celltype_annotation.pdf", ... )hc_celltype_annotation( hc, databases = c("Descartes_Cell_Types_and_Tissue_2021", "Human_Gene_Atlas"), custom_gmt_files = NULL, clusters = c("all"), mode = c("coarse", "fine"), top = 3, qval = 0.1, padj = "BH", min_term_genes = 5, min_gs_size = 10, max_gs_size = 5000, annotation_slot = c("auto", "enriched_per_cluster", "enriched_per_cluster2"), slot_suffix = NULL, clear_previous_slots = TRUE, coarse_map = NULL, coarse_include_other = TRUE, refresh_db = FALSE, export_excel = TRUE, excel_file = "Module_Celltype_Annotation.xlsx", plot_heatmap = FALSE, heatmap_file_name = "Heatmap_modules_celltype_annotation.pdf", ... )
hc |
A |
databases |
Character vector of Enrichr library names. |
custom_gmt_files |
Optional custom GMT file(s) to include in the
cell-type annotation. Accepts a character vector or named list of file
paths. Paths can be absolute/relative or file names inside
|
clusters |
Either |
mode |
Either |
top |
Number of selected categories per module. |
qval |
Maximum adjusted p-value ( |
padj |
Multiple-testing correction method for |
min_term_genes |
Minimum number of genes required per Enrichr term. |
min_gs_size |
Minimum gene-set size used in |
max_gs_size |
Maximum gene-set size used in |
annotation_slot |
Backward-compatibility option when only one database
is used. With multiple databases, one slot per DB is always written
( |
slot_suffix |
Optional character suffix appended to generated annotation
slots (for example |
clear_previous_slots |
Logical. If |
coarse_map |
Optional named character vector with regex rules for
|
coarse_include_other |
Logical. Keep unmatched terms as |
refresh_db |
Logical. If |
export_excel |
Logical. If |
excel_file |
Excel file name in the configured output folder. |
plot_heatmap |
Logical. If |
heatmap_file_name |
File name used when |
... |
Further arguments passed through to the underlying
implementation. Every supported argument is documented on this page;
|
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") gmt <- system.file("extdata", "toy_celltype_markers.gmt", package = "hcocena") # A local marker GMT instead of the default Enrichr libraries, so that the # example runs offline: hc <- hc_celltype_annotation( hc, databases = character(0), custom_gmt_files = c(CellTypes = gmt), export_excel = FALSE ) hc_satellite(hc, "celltype_annotation")$selected_celltypeshc <- hc_example_data("clustered") gmt <- system.file("extdata", "toy_celltype_markers.gmt", package = "hcocena") # A local marker GMT instead of the default Enrichr libraries, so that the # example runs offline: hc <- hc_celltype_annotation( hc, databases = character(0), custom_gmt_files = c(CellTypes = gmt), export_excel = FALSE ) hc_satellite(hc, "celltype_annotation")$selected_celltypes
Recalculate grouped GFCs and replot module heatmap (S4 API)
hc_change_grouping_parameter( hc, group_by, col_order = NULL, cluster_columns = FALSE, row_order = NULL, cluster_rows = TRUE )hc_change_grouping_parameter( hc, group_by, col_order = NULL, cluster_columns = FALSE, row_order = NULL, cluster_rows = TRUE )
hc |
A |
group_by |
Grouping column to use (must be present in all annotation tables). |
col_order |
Optional heatmap column order. |
cluster_columns |
Whether to cluster heatmap columns. Default is
|
row_order |
Optional heatmap row order. |
cluster_rows |
Whether to cluster heatmap rows. |
Uses the existing module definitions from the current object and only recalculates grouped GFCs for a different grouping variable. No integrated network rebuild and no module re-clustering is performed.
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_change_grouping_parameter(hc, group_by = "batch")hc <- hc_example_data("clustered") hc <- hc_change_grouping_parameter(hc, group_by = "batch")
Iteratively calls fix_dir() on the provided working directory paths to fix them if necessary or throw an error if they are invalid.
hc_check_dirs(hc, create_output_dir = TRUE)hc_check_dirs(hc, create_output_dir = TRUE)
hc |
A |
create_output_dir |
Boolean. If TRUE and |
Updated HCoCenaExperiment.
hc <- hc_example_data("prepared") hc <- hc_set_paths( hc, dir_count_data = FALSE, dir_annotation = FALSE, dir_reference_files = FALSE, dir_output = tempdir() ) hc <- hc_check_dirs(hc)hc <- hc_example_data("prepared") hc <- hc_set_paths( hc, dir_count_data = FALSE, dir_annotation = FALSE, dir_reference_files = FALSE, dir_output = tempdir() ) hc <- hc_check_dirs(hc)
Check TF targets (S4 API)
hc_check_tf(hc, TF)hc_check_tf(hc, TF)
hc |
A |
TF |
Transcription factor symbol. |
Updated HCoCenaExperiment.
# Needs the ChEA3 results of hc_tf_overrep_network(), which queries the # ChEA3 web service. hc <- hc_example_data("clustered") hc <- hc_tf_overrep_network(hc, topTF = 10, topTarget = 5) tfs <- names(hc_satellite(hc, "tf_network_targets")) if (length(tfs) > 0) { hc <- hc_check_tf(hc, TF = tfs[[1]]) }# Needs the ChEA3 results of hc_tf_overrep_network(), which queries the # ChEA3 web service. hc <- hc_example_data("clustered") hc <- hc_tf_overrep_network(hc, topTF = 10, topTarget = 5) tfs <- names(hc_satellite(hc, "tf_network_targets")) if (length(tfs) > 0) { hc <- hc_check_tf(hc, TF = tfs[[1]]) }
The function offers several community detection algorithms to identify dense regions in the co-expression network. These dense regions represent collections of highly co-expressed genes likely to form a functional group.
hc_cluster_calculation( hc, cluster_algo = "cluster_leiden", no_of_iterations = 2, resolution = 0.1, partition_type = "RBConfigurationVertexPartition", max_cluster_count_per_gene = 1, return_result = FALSE )hc_cluster_calculation( hc, cluster_algo = "cluster_leiden", no_of_iterations = 2, resolution = 0.1, partition_type = "RBConfigurationVertexPartition", max_cluster_count_per_gene = 1, return_result = FALSE )
hc |
A |
cluster_algo |
The clustering algorithm to be used. The choice is between "cluster_leiden" (default), "cluster_louvain", "cluster_label_prop", "cluster_fast_greedy", "cluster_infomap", "cluster_walktrap" and "auto" (in which case all are tested and the one with the highest modularity is chosen). |
no_of_iterations |
Some of the algorithms are iterative (e.g. Leiden Algorithm). Set here, how many iterations should be performed. For information on which other algorithms are iterative, please refer to their documentation in the igraph or leidenbase package. Default is 2. |
resolution |
The cluster resolution if the cluster algorithm is set to "cluster_leiden". Default is 0.1. Higher values result in more clusters and vice versa. |
partition_type |
Name of the partition type. Select from 'CPMVertexPartition', 'ModularityVertexPartition', 'RBConfigurationVertexPartition' and 'RBERVertexPartition'. Default is 'RBConfigurationVertexPartition'. |
max_cluster_count_per_gene |
The maximum number of different clusters a gene is allowed to be associated with during the different iterations before it is marked as indecisive and removed. Default is 1. |
return_result |
Logical. If |
Updated HCoCenaExperiment. If return_result = TRUE and the
clustering backend returns a cluster table, that table is returned
instead.
hc <- hc_example_data("clustered") hc <- hc_cluster_calculation(hc, cluster_algo = "cluster_leiden")hc <- hc_example_data("clustered") hc <- hc_cluster_calculation(hc, cluster_algo = "cluster_leiden")
HCoCenaExperiment
Access cluster information from an HCoCenaExperiment
hc_clusters(x) ## S4 method for signature 'HCoCenaExperiment' hc_clusters(x)hc_clusters(x) ## S4 method for signature 'HCoCenaExperiment' hc_clusters(x)
x |
An |
Cluster information or NULL if missing.
hc <- hc_init() hc_clusters(hc)hc <- hc_init() hc_clusters(hc)
Add categorical module heatmap annotations (S4 API)
hc_col_anno_categorical(hc, variables, variable_label = NULL, type = "abs")hc_col_anno_categorical(hc, variables, variable_label = NULL, type = "abs")
hc |
A |
variables |
Character vector of categorical annotation column names to add as heatmap column annotations. |
variable_label |
Optional display label(s) for |
type |
Either "abs" (default) for absolute counts or "rel" for relative proportions. |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_col_anno_categorical(hc, variables = "batch")hc <- hc_example_data("clustered") hc <- hc_col_anno_categorical(hc, variables = "batch")
Adds numeric annotation tracks to the columns of the module heatmap. Call
with variables = NULL to remove previously added tracks.
hc_col_anno_numerical(hc, variables, variable_label)hc_col_anno_numerical(hc, variables, variable_label)
hc |
A |
variables |
Character vector of numeric annotation column names to add.
Use |
variable_label |
Display label for the annotation track. |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_col_anno_numerical(hc, variables = "batch", variable_label = "batch")hc <- hc_example_data("clustered") hc <- hc_col_anno_numerical(hc, variables = "batch", variable_label = "batch")
Re-plots the integrated network with one module emphasised by colour and node size.
hc_colour_single_cluster(hc, cluster)hc_colour_single_cluster(hc, cluster)
hc |
A |
cluster |
The module to highlight, given as its colour or module label. |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_colour_single_cluster(hc, cluster = "gold")hc <- hc_example_data("clustered") hc <- hc_colour_single_cluster(hc, cluster = "gold")
HCoCenaExperiment
Access configuration from an HCoCenaExperiment
hc_config(x) ## S4 method for signature 'HCoCenaExperiment' hc_config(x)hc_config(x) ## S4 method for signature 'HCoCenaExperiment' hc_config(x)
x |
An |
A HCoCenaConfig object.
hc <- hc_init() class(hc_config(hc))hc <- hc_init() class(hc_config(hc))
Assigns new sample group labels from the data structure rather than from metadata, by cutting a hierarchical clustering tree. Useful when the variable of interest does not match the structure seen in the heatmaps or the PCA.
hc_cut_hclust( hc, by = "all", set = "all", method = "complete", k, save = FALSE )hc_cut_hclust( hc, by = "all", set = "all", method = "complete", k, save = FALSE )
hc |
A |
by |
What to regroup on: |
set |
Layers to regroup: |
method |
Agglomeration method passed to |
k |
Integer vector giving, per regrouped layer, the number of clusters to cut the dendrogram into. Defaults to 1 per layer (no cutting - good for a first look). |
save |
Logical. If |
Re-run with save = FALSE to try different k values; only set
save = TRUE once you have settled on one, since that overwrites the
original groups and exports a new annotation file (without row names). After
saving, re-run the pipeline from hc_run_expression_analysis_2() onward.
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_cut_hclust(hc, by = "module", k = c(2, 2), save = FALSE)hc <- hc_example_data("clustered") hc <- hc_cut_hclust(hc, by = "module", k = c(2, 2), save = FALSE)
HCoCenaExperiment
Define layers in an HCoCenaExperiment
hc_define_layers(hc, data_sets = list())hc_define_layers(hc, data_sets = list())
hc |
A |
data_sets |
Named list of layers, each value a pair (count, annotation). |
Updated HCoCenaExperiment.
hc <- hc_init() hc <- hc_define_layers( hc, data_sets = list( Layer1 = c("counts.tsv", "anno.tsv") ) ) as.data.frame(methods::slot(hc_config(hc), "layer"))hc <- hc_init() hc <- hc_define_layers( hc, data_sets = list( Layer1 = c("counts.tsv", "anno.tsv") ) ) as.data.frame(methods::slot(hc_config(hc), "layer"))
HCoCenaExperiment
Returns one of the small example objects shipped in inst/extdata, taken
at a given stage of the standard workflow, so that individual steps can be
tried without running everything before them. The data are two simulated
layers of 40 marker genes for four blood cell types over 32 samples; see
inst/scripts/make-fixtures.R for the generating code.
hc_example_data( stage = c("prepared", "after_part1", "after_part2", "clustered"), dir_output = NULL )hc_example_data( stage = c("prepared", "after_part1", "after_part2", "clustered"), dir_output = NULL )
stage |
Workflow stage to load:
|
dir_output |
Output directory to store in the object. Defaults to a
new directory inside |
The output directory stored in the object is replaced by a fresh
directory inside tempdir(), so functions that write plots or tables
never write outside the session's temporary directory.
A HCoCenaExperiment.
hc <- hc_example_data("clustered") hc table(hc_gene_to_cluster(hc)$color)hc <- hc_example_data("clustered") hc table(hc_gene_to_cluster(hc)$color)
Export clusters (S4 API)
hc_export_clusters(hc)hc_export_clusters(hc)
hc |
A |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_export_clusters(hc)hc <- hc_example_data("clustered") hc <- hc_export_clusters(hc)
Export network to Cytoscape (S4 API)
hc_export_to_cytoscape(hc, name = "my igraph", docker_container = FALSE)hc_export_to_cytoscape(hc, name = "my igraph", docker_container = FALSE)
hc |
A |
name |
Name under which the network is created in Cytoscape. Default is "my igraph". |
docker_container |
Logical. Set to |
Updated HCoCenaExperiment.
# Needs a running Cytoscape instance reachable through RCy3. cytoscape_up <- requireNamespace("RCy3", quietly = TRUE) && isTRUE(tryCatch({ RCy3::cytoscapePing() TRUE }, error = function(e) FALSE)) if (cytoscape_up) { hc <- hc_example_data("clustered") hc <- hc_export_to_cytoscape(hc, name = "hcocena example") }# Needs a running Cytoscape instance reachable through RCy3. cytoscape_up <- requireNamespace("RCy3", quietly = TRUE) && isTRUE(tryCatch({ RCy3::cytoscapePing() TRUE }, error = function(e) FALSE)) if (cytoscape_up) { hc <- hc_example_data("clustered") hc <- hc_export_to_cytoscape(hc, name = "hcocena example") }
Export network to local folder (S4 API)
hc_export_to_local_folder(hc, file)hc_export_to_local_folder(hc, file)
hc |
A |
file |
Target folder for the exported network files. If omitted, the
current output/save folder configured in |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_export_to_local_folder(hc, file = tempdir())hc <- hc_example_data("clustered") hc <- hc_export_to_local_folder(hc, file = tempdir())
Determines hub genes per module from a combined ranking of weighted degree, closeness and betweenness centrality.
hc_find_hubs( hc, clusters = c("all"), top = 10, tree_layout = FALSE, TF_only = FALSE, save = FALSE, plot = FALSE )hc_find_hubs( hc, clusters = c("all"), top = 10, tree_layout = FALSE, TF_only = FALSE, save = FALSE, plot = FALSE )
hc |
A |
clusters |
Either "all" (default) or a vector of module colours for which hub detection should be performed. |
top |
Integer. Number of top-ranked genes per module to report as hubs. Default is 10. |
tree_layout |
Logical. Draw the per-module hub network with a tree
layout. Default is |
TF_only |
Either |
save |
Logical. Write the hub network and expression heatmap to PDF.
Default is |
plot |
Logical. Draw the per-module network. Default is |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_find_hubs(hc)hc <- hc_example_data("clustered") hc <- hc_find_hubs(hc)
Functional enrichment (S4 API)
hc_functional_enrichment( hc, gene_sets = c("Go", "Kegg", "Hallmark", "Reactome"), custom_gmt_files = NULL, top = 5, clusters = c("all"), padj = "BH", qval = 0.05, universe = c("all_genes", "network"), consistent_terms = TRUE, heatmap_side = "left", heatmap_cluster_rows = FALSE, cluster_columns = FALSE, heatmap_cluster_columns = NULL, heatmap_show_row_dend = FALSE, heatmap_show_column_dend = FALSE, col_order = NULL, heatmap_col_order = NULL, heatmap_order = NULL, heatmap_module_label_mode = "same", heatmap_show_gene_counts = FALSE, heatmap_column_label_fontsize = NULL, heatmap_module_label_fontsize = NULL, legend_fontsize = NULL, enrichment_label_fontsize = NULL, enrichment_db_header_fontsize = NULL, enrichment_label_wrap = FALSE, enrichment_label_wrap_width = 30, gfc_scale_limits = NULL, store_panel_objects = c("auto", "always", "never"), pdf_width = NULL, pdf_height = NULL, pdf_pointsize = 11, ... )hc_functional_enrichment( hc, gene_sets = c("Go", "Kegg", "Hallmark", "Reactome"), custom_gmt_files = NULL, top = 5, clusters = c("all"), padj = "BH", qval = 0.05, universe = c("all_genes", "network"), consistent_terms = TRUE, heatmap_side = "left", heatmap_cluster_rows = FALSE, cluster_columns = FALSE, heatmap_cluster_columns = NULL, heatmap_show_row_dend = FALSE, heatmap_show_column_dend = FALSE, col_order = NULL, heatmap_col_order = NULL, heatmap_order = NULL, heatmap_module_label_mode = "same", heatmap_show_gene_counts = FALSE, heatmap_column_label_fontsize = NULL, heatmap_module_label_fontsize = NULL, legend_fontsize = NULL, enrichment_label_fontsize = NULL, enrichment_db_header_fontsize = NULL, enrichment_label_wrap = FALSE, enrichment_label_wrap_width = 30, gfc_scale_limits = NULL, store_panel_objects = c("auto", "always", "never"), pdf_width = NULL, pdf_height = NULL, pdf_pointsize = 11, ... )
hc |
A |
gene_sets |
A vector. The names of databases enrichment should be performed for. Choose one or multiple of "Go", "Kegg", "Hallmark", and/or "Reactome". Available databases depend on supplement files previously set Default is "Hallmark". |
custom_gmt_files |
Optional custom GMT file(s) to include directly in
enrichment. Accepts a character vector or named list of file paths.
Unnamed entries are auto-labeled ( |
top |
Integer. The number of most strongly enriched terms to return per cluster. Default is 5. |
clusters |
Either "all" (default) or a vector of clusters as strings. Defines for which clusters to perform the enrichment. |
padj |
Method to use for multiple testing correction. Can be one of "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none". Default is "BH" (Benjamini-Hochberg).
The reported |
qval |
Upper threshold for the adjusted p-value. Default is 0.05. |
universe |
Background gene set for the hypergeometric test. |
consistent_terms |
Logical. If |
heatmap_side |
Position of the hCoCena heatmap in the combined output. Choose one of "left" (default) or "right". |
heatmap_cluster_rows |
A Boolean whether or not to cluster rows in the hCoCena heatmap. |
cluster_columns |
A Boolean whether or not to cluster columns in the hCoCena heatmap. |
heatmap_cluster_columns |
Legacy alias for |
heatmap_show_row_dend |
A Boolean whether to show the row dendrogram when |
heatmap_show_column_dend |
A Boolean whether to show the column dendrogram when |
col_order |
Optional character vector overriding the hCoCena
heatmap column order for this enrichment plot only. If |
heatmap_col_order |
Legacy alias for |
heatmap_order |
Optional character vector specifying module order in the hCoCena heatmap. Entries can be module colors (e.g. "turquoise") or module labels from the main heatmap (e.g. "M1", "M2", ...). Modules not listed are appended afterwards. |
heatmap_module_label_mode |
Controls labels inside module color boxes of the hCoCena heatmap.
One of "same" or "none". "same" reuses the prefix from
|
heatmap_show_gene_counts |
A Boolean whether or not to show gene counts per module in the right annotation of the hCoCena heatmap. Default is FALSE. |
heatmap_column_label_fontsize |
Optional numeric font size for hCoCena heatmap column labels in enrichment plots. If NULL (default), uses automatic sizing. |
heatmap_module_label_fontsize |
Optional numeric font size for module labels
inside module color boxes ( |
legend_fontsize |
Optional numeric base font size for enrichment-related legends (GFC legend and enrichment significance legend). If NULL (default), uses automatic sizing. |
enrichment_label_fontsize |
Optional numeric font size for enrichment term labels. If NULL (default), uses automatic sizing. |
enrichment_db_header_fontsize |
Optional numeric font size for database headers in combined all-DB enrichment plots (e.g. "Go", "Kegg", "Hallmark"). If NULL (default), uses automatic sizing. |
enrichment_label_wrap |
Logical. If TRUE, wraps enrichment term labels using
|
enrichment_label_wrap_width |
Integer wrap width used when
|
gfc_scale_limits |
Optional numeric vector controlling the module-heatmap
color scale limits used in enrichment plots. Provide one positive number
( |
store_panel_objects |
One of |
pdf_width |
Optional numeric width (inches) for enrichment PDFs. If NULL (default), width is auto-estimated from content. |
pdf_height |
Optional numeric height (inches) for enrichment PDFs. If NULL (default), height is auto-estimated from content. |
pdf_pointsize |
Numeric base pointsize used for PDF devices. Default is 11. |
... |
Further arguments passed through to the underlying
implementation. Every supported argument is documented on this page;
|
Updated HCoCenaExperiment.
The result tables carry pvalue (raw), p_adjusted (corrected with the
method given in padj, and what the qval filter and the ranking use),
padj_method (which correction that was) and q_storey (clusterProfiler's
Storey q-value, NA where pi0 could not be fitted - which is common for
small gene-set collections). qvalue is kept as an alias of p_adjusted
so existing scripts and exports keep working.
hc <- hc_example_data("clustered") gmt <- tempfile(fileext = ".gmt") writeLines( c( paste(c("T cells", "-", "CD3D", "CD3E", "CD3G", "CD2", "CD28", "LCK", "ZAP70", "IL7R", "CD7", "TRAC"), collapse = "\t"), paste(c("B cells", "-", "CD19", "MS4A1", "CD79A", "CD79B", "BLNK", "PAX5", "CR2", "FCRL1", "TNFRSF13B", "VPREB3"), collapse = "\t"), paste(c("Monocytes", "-", "CD14", "LYZ", "FCN1", "VCAN", "S100A8", "S100A9", "CSF1R", "ITGAM", "CD68", "FCGR3A"), collapse = "\t"), paste(c("NK cells", "-", "NKG7", "GNLY", "KLRD1", "KLRF1", "PRF1", "GZMB", "NCR1", "KLRC1", "FGFBP2", "SPON2"), collapse = "\t") ), gmt ) hc <- hc_functional_enrichment( hc, gene_sets = character(0), custom_gmt_files = c(CellTypes = gmt) )hc <- hc_example_data("clustered") gmt <- tempfile(fileext = ".gmt") writeLines( c( paste(c("T cells", "-", "CD3D", "CD3E", "CD3G", "CD2", "CD28", "LCK", "ZAP70", "IL7R", "CD7", "TRAC"), collapse = "\t"), paste(c("B cells", "-", "CD19", "MS4A1", "CD79A", "CD79B", "BLNK", "PAX5", "CR2", "FCRL1", "TNFRSF13B", "VPREB3"), collapse = "\t"), paste(c("Monocytes", "-", "CD14", "LYZ", "FCN1", "VCAN", "S100A8", "S100A9", "CSF1R", "ITGAM", "CD68", "FCGR3A"), collapse = "\t"), paste(c("NK cells", "-", "NKG7", "GNLY", "KLRD1", "KLRF1", "PRF1", "GZMB", "NCR1", "KLRC1", "FGFBP2", "SPON2"), collapse = "\t") ), gmt ) hc <- hc_functional_enrichment( hc, gene_sets = character(0), custom_gmt_files = c(CellTypes = gmt) )
Returns the mapping of every network gene to the module it was assigned to.
hc_gene_to_cluster(hc)hc_gene_to_cluster(hc)
hc |
A |
A data frame with two columns: gene (gene symbol) and color
(module colour). Genes that were not assigned to any module carry the
colour "white".
hc <- hc_example_data("clustered") head(hc_gene_to_cluster(hc))hc <- hc_example_data("clustered") head(hc_gene_to_cluster(hc))
Returns the column-order vector stored by hc_add_meta_time_grouping().
hc_get_meta_time_col_order( hc, slot_name = "longitudinal_endotypes", layer = NULL )hc_get_meta_time_col_order( hc, slot_name = "longitudinal_endotypes", layer = NULL )
hc |
A |
slot_name |
Satellite slot containing |
layer |
Layer index, layer id/name, or |
Character vector with heatmap column order as expected by
hc_change_grouping_parameter().
hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) hc <- hc_add_meta_time_grouping(hc, donor_col = "donor", time_col = "timepoint") hc_get_meta_time_col_order(hc)hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) hc <- hc_add_meta_time_grouping(hc, donor_col = "donor", time_col = "timepoint") hc_get_meta_time_col_order(hc)
Module scores (S4 API)
hc_get_module_scores(hc, save = TRUE)hc_get_module_scores(hc, save = TRUE)
hc |
A |
save |
Logical. Write the module-score box plot to PDF.
Default is |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_get_module_scores(hc)hc <- hc_example_data("clustered") hc <- hc_get_module_scores(hc)
HCoCenaExperiment
Access the integrated network of an HCoCenaExperiment
hc_graph(x) ## S4 method for signature 'HCoCenaExperiment' hc_graph(x)hc_graph(x) ## S4 method for signature 'HCoCenaExperiment' hc_graph(x)
x |
An |
The integrated network as an igraph object, or NULL if
hc_build_integrated_network() has not been run yet.
hc <- hc_example_data("clustered") g <- hc_graph(hc) igraph::vcount(g)hc <- hc_example_data("clustered") g <- hc_graph(hc) igraph::vcount(g)
Re-plots the integrated network with a gene set of interest highlighted.
hc_highlight_geneset( hc, gene_set, name = NULL, col = "black", label_offset = 3, plot = TRUE, save = TRUE )hc_highlight_geneset( hc, gene_set, name = NULL, col = "black", label_offset = 3, plot = TRUE, save = TRUE )
hc |
A |
gene_set |
Character vector of gene symbols to highlight. |
name |
Optional name used for the plot title and output file. |
col |
Colour used for the highlighted genes. Default is |
label_offset |
Distance between a node and its label. Default is 3. |
plot |
Logical. Draw the network. Default is |
save |
Logical. Write the network to PDF. Default is |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_highlight_geneset(hc, gene_set = c("CD3D", "CD19"))hc <- hc_example_data("clustered") hc <- hc_highlight_geneset(hc, gene_set = c("CD3D", "CD19"))
Replaces the current module assignment with one read from a file, e.g. a
clustering exported earlier with hc_export_clusters().
hc_import_clusters(hc, file, sep = "\t", header = TRUE)hc_import_clusters(hc, file, sep = "\t", header = TRUE)
hc |
A |
file |
Path to the gene-to-cluster file. Column 1 holds gene symbols, column 2 the cluster each gene belongs to. |
sep |
Field separator of the file. Default is |
header |
Logical. Whether the file carries a header row. Default |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") gtc <- hc_gene_to_cluster(hc) f <- tempfile(fileext = ".tsv") utils::write.table(gtc, f, sep = "\t", row.names = FALSE, quote = FALSE) hc <- hc_import_clusters(hc, file = f)hc <- hc_example_data("clustered") gtc <- hc_gene_to_cluster(hc) f <- tempfile(fileext = ".tsv") utils::write.table(gtc, f, sep = "\t", row.names = FALSE, quote = FALSE) hc <- hc_import_clusters(hc, file = f)
Import layout from Cytoscape (S4 API)
hc_import_layout_from_cytoscape(hc)hc_import_layout_from_cytoscape(hc)
hc |
A |
Updated HCoCenaExperiment.
# Needs a running Cytoscape instance reachable through RCy3. cytoscape_up <- requireNamespace("RCy3", quietly = TRUE) && isTRUE(tryCatch({ RCy3::cytoscapePing() TRUE }, error = function(e) FALSE)) if (cytoscape_up) { hc <- hc_example_data("clustered") hc <- hc_export_to_cytoscape(hc, name = "hcocena example") # ... arrange the network in Cytoscape, then: hc <- hc_import_layout_from_cytoscape(hc) }# Needs a running Cytoscape instance reachable through RCy3. cytoscape_up <- requireNamespace("RCy3", quietly = TRUE) && isTRUE(tryCatch({ RCy3::cytoscapePing() TRUE }, error = function(e) FALSE)) if (cytoscape_up) { hc <- hc_example_data("clustered") hc <- hc_export_to_cytoscape(hc, name = "hcocena example") # ... arrange the network in Cytoscape, then: hc <- hc_import_layout_from_cytoscape(hc) }
Import Cytoscape layout from local folder (S4 API)
hc_import_layout_from_local_folder(hc, file)hc_import_layout_from_local_folder(hc, file)
hc |
A |
file |
Path to the |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") # A layout CSV as written by hc_import_layout_from_cytoscape(): one row per # node, named by gene, with x and y coordinates. g <- hc_graph(hc) xy <- igraph::layout_with_fr(g) rownames(xy) <- igraph::V(g)$name layout_file <- file.path(tempdir(), "network_layout.csv") utils::write.csv(xy, layout_file) hc <- hc_import_layout_from_local_folder(hc, file = layout_file)hc <- hc_example_data("clustered") # A layout CSV as written by hc_import_layout_from_cytoscape(): one row per # node, named by gene, with x and y coordinates. g <- hc_graph(hc) xy <- igraph::layout_with_fr(g) rownames(xy) <- igraph::V(g)$name layout_file <- file.path(tempdir(), "network_layout.csv") utils::write.csv(xy, layout_file) hc <- hc_import_layout_from_local_folder(hc, file = layout_file)
HCoCenaExperiment
Initialize an empty HCoCenaExperiment
hc_init()hc_init()
A valid, empty HCoCenaExperiment.
hc <- hc_init() methods::is(hc, "HCoCenaExperiment")hc <- hc_init() methods::is(hc, "HCoCenaExperiment")
A folder with the given name is created in the output directory. All analysis outputs will be saved to this folder.
hc_init_save_folder(hc, name, use_output_dir = FALSE)hc_init_save_folder(hc, name, use_output_dir = FALSE)
hc |
A |
name |
Folder name. Use |
use_output_dir |
Boolean. If TRUE, ignore |
Updated HCoCenaExperiment.
hc <- hc_example_data("prepared") hc <- hc_init_save_folder(hc, name = "")hc <- hc_example_data("prepared") hc <- hc_init_save_folder(hc, name = "")
HCoCenaExperiment
Access integration payload from an HCoCenaExperiment
hc_integration(x) ## S4 method for signature 'HCoCenaExperiment' hc_integration(x)hc_integration(x) ## S4 method for signature 'HCoCenaExperiment' hc_integration(x)
x |
An |
A HCoCenaIntegration object.
hc <- hc_init() class(hc_integration(hc))hc <- hc_init() class(hc_integration(hc))
HCoCenaExperiment
Access layer results from an HCoCenaExperiment
hc_layer_results(x) ## S4 method for signature 'HCoCenaExperiment' hc_layer_results(x)hc_layer_results(x) ## S4 method for signature 'HCoCenaExperiment' hc_layer_results(x)
x |
An |
A S4Vectors::SimpleList.
hc <- hc_init() class(hc_layer_results(hc))hc <- hc_init() class(hc_layer_results(hc))
Lists Enrichr libraries and optionally filters for cell/tissue related names.
hc_list_celltype_databases( pattern = NULL, include_all = FALSE, ignore_case = TRUE )hc_list_celltype_databases( pattern = NULL, include_all = FALSE, ignore_case = TRUE )
pattern |
Optional regular expression applied to database names. |
include_all |
Logical. If |
ignore_case |
Logical. Passed to |
A data frame with Enrichr library metadata.
hc_list_celltype_databases()hc_list_celltype_databases()
Queries the model-listing endpoint of each selected provider and returns the
available models as a data frame. Supports the same providers as
hc_llm_enrichment(): Gemini, Claude (Anthropic), OpenAI/ChatGPT, and a
local OpenAI-compatible server (vLLM).
hc_list_llm_models( provider = "all", api_key = NULL, base_url = NULL, timeout_sec = 30 )hc_list_llm_models( provider = "all", api_key = NULL, base_url = NULL, timeout_sec = 30 )
provider |
Character vector of providers to query. One or more of
|
api_key |
Optional API key. Only applied when a single provider is
requested; otherwise keys are taken from the per-provider environment
variables ( |
base_url |
Base URL of the local OpenAI-compatible server. Required for
|
timeout_sec |
Per-request timeout in seconds. Default |
A data frame with columns provider, model, and info. Providers
that cannot be reached (e.g. a missing API key) are skipped with a warning
rather than aborting the whole call.
# Contacts the provider APIs; each provider needs its API key set in the # environment (or a reachable server for "vllm"). if (nzchar(Sys.getenv("GEMINI_API_KEY"))) { hc_list_llm_models("gemini") } if (nzchar(Sys.getenv("OPENAI_API_KEY"))) { hc_list_llm_models("openai") }# Contacts the provider APIs; each provider needs its API key set in the # environment (or a reachable server for "vllm"). if (nzchar(Sys.getenv("GEMINI_API_KEY"))) { hc_list_llm_models("gemini") } if (nzchar(Sys.getenv("OPENAI_API_KEY"))) { hc_list_llm_models("openai") }
Asks a large language model what biological program each module (or any other set of genes, proteins or other features) most likely represents. This is an AI-assisted interpretation, not a statistical test.
hc_llm_enrichment( hc = NULL, genes = NULL, modules = "all", system_prompt = NULL, context = NULL, provider = c("claude", "openai", "gemini", "local", "manual"), api_key = NULL, model = NULL, base_url = NULL, evidence = "enrichment", evidence_text = NULL, evidence_top = 10, evidence_qval = 0.05, rag_url = NULL, rag_top_k = 10, slot_name = "llm_enrichment", verbose = TRUE )hc_llm_enrichment( hc = NULL, genes = NULL, modules = "all", system_prompt = NULL, context = NULL, provider = c("claude", "openai", "gemini", "local", "manual"), api_key = NULL, model = NULL, base_url = NULL, evidence = "enrichment", evidence_text = NULL, evidence_top = 10, evidence_qval = 0.05, rag_url = NULL, rag_top_k = 10, slot_name = "llm_enrichment", verbose = TRUE )
hc |
Optional |
genes |
Optional feature set(s) to interpret instead of modules: a character vector (one set) or a named list of character vectors. |
modules |
Modules of |
system_prompt |
Optional instruction that tells the model who it is
and how to answer, e.g. |
context |
Optional free text describing the study, e.g. tissue,
disease, platform or time point. Used for all fields except
|
provider |
|
api_key |
API key. If |
model |
Optional model name. Defaults to |
base_url |
Server address for |
evidence |
Evidence for |
evidence_text |
Optional evidence supplied directly, as a named list or
named character vector (names = set names). Added to the evidence above;
the only way to give evidence together with |
evidence_top |
Maximum number of enriched terms and of regulators per set. Default 10. |
evidence_qval |
Adjusted p-value cutoff for enriched terms. Default 0.05. |
rag_url |
Retrieval endpoint of a DoRAG server for |
rag_top_k |
Number of literature passages per set. Default 10. |
slot_name |
Name under which results are stored in |
verbose |
Logical; print progress messages. Default |
Every set is interpreted in up to three separate requests, so that each answer sees only the input it is meant to see:
general_processes: from the features alone, without context;
contextual_state and key_regulators: from the features and the
context;
grounded_processes and supporting_evidence: from the features,
the context and the evidence - by default the significant terms of
hc_functional_enrichment(); optionally also the regulators of
hc_upstream_inference() and literature passages from a DoRAG server.
hc_plot_llm_enrichment() draws one plot per field, so the plots can be
compared directly: what the model makes of the genes alone, with context,
and with statistical evidence. Without stored enrichment results the third
request is left out (with a message).
The requests can be sent in two ways:
through an API (provider = "claude", "openai", "gemini", or
"local" for an OpenAI-compatible vLLM server), which needs an API key
for the hosted providers;
without an API key (provider = "manual"): one prompt per request type is
prepared (the first is copied to the clipboard); paste each into a new
chat of any provider and read every answer back with hc_llm_import().
The results are stored exactly like API results.
Results are stored in hc_satellite(hc, slot_name) (one entry per set) and
hc_satellite(hc, paste0(slot_name, "_summary")) (a table).
With hc: the updated HCoCenaExperiment (for "manual", with
the pending request stored). Without hc: a data frame with one row per
set (for "manual", an hc_llm_request object to pass to
hc_llm_import()).
hc_llm_import(), hc_plot_llm_enrichment(),
hc_list_llm_models()
# Without an API key: build the requests, answer them in a web chat, import. req <- hc_llm_enrichment( genes = list(IFN = c("STAT1", "IRF7", "CXCL10", "GBP1", "IFI44L")), context = "Whole blood of patients with acute viral infection", evidence_text = list(IFN = "Enriched: type I interferon signaling (q = 1e-6)"), provider = "manual", verbose = FALSE ) length(req$parts) # genes only / with context / with evidence cat(substr(req$parts[[1]], 1, 300)) # The answers copied from the web chat (here written by hand): answer <- paste0( '{"request_id": "', req$id, '", "results": [{"set": "IFN", ', '"general_processes": "type I interferon signaling / antiviral response",', ' "contextual_state": "interferon-high antiviral state",', ' "key_regulators": "STAT1 / IRF7 / IRF9",', ' "grounded_processes": "type I interferon response",', ' "supporting_evidence": "type I interferon signaling"}]}' ) hc_llm_import(req, text = answer, verbose = FALSE) # Through an API (needs a key): if (nzchar(Sys.getenv("ANTHROPIC_API_KEY"))) { hc_llm_enrichment( genes = c("STAT1", "IRF7", "CXCL10", "GBP1", "IFI44L"), provider = "claude" ) }# Without an API key: build the requests, answer them in a web chat, import. req <- hc_llm_enrichment( genes = list(IFN = c("STAT1", "IRF7", "CXCL10", "GBP1", "IFI44L")), context = "Whole blood of patients with acute viral infection", evidence_text = list(IFN = "Enriched: type I interferon signaling (q = 1e-6)"), provider = "manual", verbose = FALSE ) length(req$parts) # genes only / with context / with evidence cat(substr(req$parts[[1]], 1, 300)) # The answers copied from the web chat (here written by hand): answer <- paste0( '{"request_id": "', req$id, '", "results": [{"set": "IFN", ', '"general_processes": "type I interferon signaling / antiviral response",', ' "contextual_state": "interferon-high antiviral state",', ' "key_regulators": "STAT1 / IRF7 / IRF9",', ' "grounded_processes": "type I interferon response",', ' "supporting_evidence": "type I interferon signaling"}]}' ) hc_llm_import(req, text = answer, verbose = FALSE) # Through an API (needs a key): if (nzchar(Sys.getenv("ANTHROPIC_API_KEY"))) { hc_llm_enrichment( genes = c("STAT1", "IRF7", "CXCL10", "GBP1", "IFI44L"), provider = "claude" ) }
Reads an answer to a request created with
hc_llm_enrichment(provider = "manual"), checks that it belongs to that
request, and stores it exactly like an API result. Markdown code fences,
text around the JSON and typographic quotes are tolerated.
hc_llm_import( x, text = NULL, file = NULL, model = NULL, slot_name = "llm_enrichment", verbose = TRUE )hc_llm_import( x, text = NULL, file = NULL, model = NULL, slot_name = "llm_enrichment", verbose = TRUE )
x |
The |
text |
Optional answer text. If |
file |
Optional path to a text file containing the answer. |
model |
Optional name of the model used in the web chat, recorded with the result. |
slot_name |
Slot used in |
verbose |
Logical; print progress messages. Default |
A request has one part per request type (features only, with context, with evidence), and long requests are split further. Import every answer with this function; after each import the next open part is copied to the clipboard. An answer may also contain the fields of several parts.
For an HCoCenaExperiment, the updated object. For an
hc_llm_request, a data frame with one row per set answered so far.
req <- hc_llm_enrichment( genes = list(IFN = c("STAT1", "IRF7", "CXCL10")), provider = "manual", verbose = FALSE ) answer <- paste0( "Here is the result:\n```json\n", '{"request_id": "', req$id, '", "results": [{"set": "IFN", ', '"general_processes": "interferon signaling", ', '"contextual_state": "antiviral state", "key_regulators": "STAT1"}]}', "\n```" ) hc_llm_import(req, text = answer, model = "web chat", verbose = FALSE)req <- hc_llm_enrichment( genes = list(IFN = c("STAT1", "IRF7", "CXCL10")), provider = "manual", verbose = FALSE ) answer <- paste0( "Here is the result:\n```json\n", '{"request_id": "', req$id, '", "results": [{"set": "IFN", ', '"general_processes": "interferon signaling", ', '"contextual_state": "antiviral state", "key_regulators": "STAT1"}]}', "\n```" ) hc_llm_import(req, text = answer, model = "web chat", verbose = FALSE)
Clusters donors based on module-time features produced by
hc_longitudinal_module_means(). Candidate cluster numbers are scored via the
Calinski-Harabasz index.
hc_longitudinal_endotype_clustering( hc, input_slot = "longitudinal_module_means", output_slot = "longitudinal_endotypes", k = 2:6, method = c("kmeans", "hclust"), scale_features = TRUE, nstart = 50, seed = 42, na_impute = c("median", "zero"), endotype_prefix = "E", module_k = NULL, module_method = c("kmeans", "hclust"), module_scale_features = TRUE, module_nstart = 30, module_seed = 42, module_na_impute = c("median", "zero") )hc_longitudinal_endotype_clustering( hc, input_slot = "longitudinal_module_means", output_slot = "longitudinal_endotypes", k = 2:6, method = c("kmeans", "hclust"), scale_features = TRUE, nstart = 50, seed = 42, na_impute = c("median", "zero"), endotype_prefix = "E", module_k = NULL, module_method = c("kmeans", "hclust"), module_scale_features = TRUE, module_nstart = 30, module_seed = 42, module_na_impute = c("median", "zero") )
hc |
A |
input_slot |
Satellite slot produced by |
output_slot |
Satellite slot to store clustering results. |
k |
Integer vector of candidate cluster counts. |
method |
One of |
scale_features |
Logical. If |
nstart |
Number of random starts for |
seed |
Random seed. |
na_impute |
One of |
endotype_prefix |
Prefix for final endotype labels. |
module_k |
Candidate cluster counts for module-wise trajectory clustering. |
module_method |
One of |
module_scale_features |
Logical. If |
module_nstart |
Number of random starts for module-wise |
module_seed |
Random seed for module-wise clustering. |
module_na_impute |
One of |
Updated HCoCenaExperiment with endotype clustering in
hc@satellite[[output_slot]].
hc <- hc_example_data("clustered") hc <- hc_longitudinal_module_means(hc, donor_col = "donor", time_col = "timepoint") hc <- hc_longitudinal_endotype_clustering(hc, k = 2)hc <- hc_example_data("clustered") hc <- hc_longitudinal_module_means(hc, donor_col = "donor", time_col = "timepoint") hc <- hc_longitudinal_endotype_clustering(hc, k = 2)
Clusters donors on CAP features (or alternative longitudinal feature matrices), providing CH-based model selection and PCA/UMAP embeddings.
hc_longitudinal_meta_clustering( hc, slot_name = "longitudinal_endotypes", output_slot = slot_name, feature_source = c("cap_matrix", "module_cluster_matrix", "feature_matrix_used"), k = 2:8, method = c("kmeans", "hclust"), scale_features = TRUE, nstart = 50, seed = 42, na_impute = c("median", "zero"), cluster_prefix = "MC", consensus = TRUE, consensus_runs = 200, consensus_sample_fraction = 0.8, consensus_feature_fraction = 0.8, consensus_linkage = "average", compute_umap = TRUE, umap_neighbors = 15, umap_min_dist = 0.3 )hc_longitudinal_meta_clustering( hc, slot_name = "longitudinal_endotypes", output_slot = slot_name, feature_source = c("cap_matrix", "module_cluster_matrix", "feature_matrix_used"), k = 2:8, method = c("kmeans", "hclust"), scale_features = TRUE, nstart = 50, seed = 42, na_impute = c("median", "zero"), cluster_prefix = "MC", consensus = TRUE, consensus_runs = 200, consensus_sample_fraction = 0.8, consensus_feature_fraction = 0.8, consensus_linkage = "average", compute_umap = TRUE, umap_neighbors = 15, umap_min_dist = 0.3 )
hc |
A |
slot_name |
Satellite slot containing longitudinal outputs. |
output_slot |
Satellite slot to write results to (default in-place). |
feature_source |
One of |
k |
Candidate meta-cluster numbers. |
method |
One of |
scale_features |
Logical. If |
nstart |
Number of random starts for |
seed |
Random seed. |
na_impute |
One of |
cluster_prefix |
Prefix for meta-cluster labels. |
consensus |
Logical. If |
consensus_runs |
Number of consensus resampling runs per candidate |
consensus_sample_fraction |
Fraction of donors sampled per consensus run. |
consensus_feature_fraction |
Fraction of features sampled per consensus run. |
consensus_linkage |
Linkage method for final hierarchical clustering on
the consensus distance ( |
compute_umap |
Logical. If |
umap_neighbors |
UMAP neighborhood size. |
umap_min_dist |
UMAP minimum distance. |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", seed = 1 )hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", seed = 1 )
CAP (cluster assignment proportions) quantifies for each donor the proportion of repeated clustering runs assigned to each module-specific cluster. This is the generalized, data-agnostic analogue of the CAP concept used in the legacy longitudinal scripts.
hc_longitudinal_module_cap( hc, slot_name = "longitudinal_endotypes", output_slot = slot_name, runs = 50, method = c("kmeans", "hclust"), nstart = 30, seed = 42, scale_features = TRUE, na_impute = c("median", "zero"), jitter_sd = 0 )hc_longitudinal_module_cap( hc, slot_name = "longitudinal_endotypes", output_slot = slot_name, runs = 50, method = c("kmeans", "hclust"), nstart = 30, seed = 42, scale_features = TRUE, na_impute = c("median", "zero"), jitter_sd = 0 )
hc |
A |
slot_name |
Satellite slot containing outputs from
|
output_slot |
Satellite slot to write results to. Defaults to
|
runs |
Number of repeated clustering runs per module (for |
method |
One of |
nstart |
|
seed |
Random seed. |
scale_features |
Logical. If |
na_impute |
One of |
jitter_sd |
Optional Gaussian jitter SD added to features per run
( |
Updated HCoCenaExperiment with CAP outputs in
hc@satellite[[output_slot]].
hc <- hc_example_data("clustered") long <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 ) hc <- long$hc hc <- hc_longitudinal_module_cap(hc, runs = 1)hc <- hc_example_data("clustered") long <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 ) hc <- long$hc hc <- hc_longitudinal_module_cap(hc, runs = 1)
Computes module-level mean expression trajectories from the clustered modules
in an HCoCenaExperiment. This creates a donor-by-(module x timepoint)
feature matrix that can be used for longitudinal endotype discovery.
hc_longitudinal_module_means( hc, donor_col = "donor", time_col = "time_point", layer = NULL, group_col = NULL, modules = NULL, use_module_labels = TRUE, time_levels = NULL, aggregate_fun = function(x) base::mean(x, na.rm = TRUE), value_label = NULL, impute_missing = c("linear", "locf", "none"), min_genes_per_module = 5, slot_name = "longitudinal_module_means" )hc_longitudinal_module_means( hc, donor_col = "donor", time_col = "time_point", layer = NULL, group_col = NULL, modules = NULL, use_module_labels = TRUE, time_levels = NULL, aggregate_fun = function(x) base::mean(x, na.rm = TRUE), value_label = NULL, impute_missing = c("linear", "locf", "none"), min_genes_per_module = 5, slot_name = "longitudinal_module_means" )
hc |
A |
donor_col |
Annotation column holding donor/patient IDs. |
time_col |
Annotation column holding ordered timepoint labels. |
layer |
Layer to use (index, layer id, or layer name). Defaults to the first available layer. |
group_col |
Optional annotation column (e.g. outcome group) to carry. |
modules |
Optional subset of modules (module labels or color names). |
use_module_labels |
Logical. If |
time_levels |
Optional explicit timepoint order. |
aggregate_fun |
Function used to aggregate technical replicates per
donor/timepoint/module (default |
value_label |
Optional y-axis label base (e.g. |
impute_missing |
One of |
min_genes_per_module |
Minimum number of overlapping genes required to keep a module. |
slot_name |
Name of the satellite slot to store outputs. |
Updated HCoCenaExperiment with longitudinal data in
hc@satellite[[slot_name]].
hc <- hc_example_data("clustered") hc <- hc_longitudinal_module_means(hc, donor_col = "donor", time_col = "timepoint")hc <- hc_example_data("clustered") hc <- hc_longitudinal_module_means(hc, donor_col = "donor", time_col = "timepoint")
Computes longitudinal module means, then clusters donors separately within
each module directly on the donor-by-time trajectory matrix. The downstream
quick steps remain unchanged and can be run via
hc_longitudinal_step2_meta_clustering(),
hc_longitudinal_step3_meta_module_trajectories(), and
hc_plot_longitudinal_enrichment_meta_waves().
hc_longitudinal_step1_module_donor( hc, donor_col = "Subject", time_col = "Time_token", layer = NULL, time_levels, k = 2:6, method = c("kmeans", "hclust"), nstart = 50, cap_runs = 50, impute = TRUE, impute_method = "rfcont", ntree = 10, min_cluster_fraction = 0.1, score_method = c("calinski_harabasz", "tot_withinss"), scale_features = FALSE, na_impute = c("median", "zero"), cap_scale_features = scale_features, cap_na_impute = na_impute, cap_jitter_sd = 0, seed = 42, means_slot = "longitudinal_module_means", output_slot = "longitudinal_endotypes" )hc_longitudinal_step1_module_donor( hc, donor_col = "Subject", time_col = "Time_token", layer = NULL, time_levels, k = 2:6, method = c("kmeans", "hclust"), nstart = 50, cap_runs = 50, impute = TRUE, impute_method = "rfcont", ntree = 10, min_cluster_fraction = 0.1, score_method = c("calinski_harabasz", "tot_withinss"), scale_features = FALSE, na_impute = c("median", "zero"), cap_scale_features = scale_features, cap_na_impute = na_impute, cap_jitter_sd = 0, seed = 42, means_slot = "longitudinal_module_means", output_slot = "longitudinal_endotypes" )
hc |
A |
donor_col |
Annotation column containing donor IDs. |
time_col |
Annotation column containing timepoint labels. |
layer |
Optional layer index, layer id, layer name, or |
time_levels |
Required explicit timepoint order vector. |
k |
Candidate donor-trajectory cluster numbers per module. |
method |
One of |
nstart |
Number of random starts for direct |
cap_runs |
Number of repeated clustering runs used to build CAP. |
impute |
Logical. If |
impute_method |
Missing-value method passed to |
ntree |
Number of trees for |
min_cluster_fraction |
Minimum allowed fraction of donors in the smallest module cluster. |
score_method |
One of |
scale_features |
Logical. If |
na_impute |
One of |
cap_scale_features |
Logical. If |
cap_na_impute |
One of |
cap_jitter_sd |
Optional Gaussian jitter SD added per CAP rerun when
|
seed |
Random seed. |
means_slot |
Satellite slot for module means. |
output_slot |
Satellite slot for endotype outputs. |
A list with updated hc, step plots, and diagnostics. When
layer = "all" (or multiple layers are supplied), returns per-layer plot
and diagnostic lists keyed by layer id.
hc <- hc_example_data("clustered") res <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 ) hc <- res$hchc <- hc_example_data("clustered") res <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 ) hc <- res$hc
Computes longitudinal module means, then clusters donors separately within each module directly on the donor-by-time trajectory matrix, especially for short trajectories with only a few timepoints.
hc_longitudinal_step1_module_donor_direct( hc, donor_col = "Subject", time_col = "Time_token", layer = NULL, time_levels, k = 2:6, method = c("kmeans", "hclust"), nstart = 50, cap_runs = 50, impute = TRUE, impute_method = "rfcont", ntree = 10, min_cluster_fraction = 0.1, score_method = c("calinski_harabasz", "tot_withinss"), scale_features = TRUE, na_impute = c("median", "zero"), cap_scale_features = scale_features, cap_na_impute = na_impute, cap_jitter_sd = 0, seed = 42, means_slot = "longitudinal_module_means_direct", output_slot = "longitudinal_endotypes_direct" )hc_longitudinal_step1_module_donor_direct( hc, donor_col = "Subject", time_col = "Time_token", layer = NULL, time_levels, k = 2:6, method = c("kmeans", "hclust"), nstart = 50, cap_runs = 50, impute = TRUE, impute_method = "rfcont", ntree = 10, min_cluster_fraction = 0.1, score_method = c("calinski_harabasz", "tot_withinss"), scale_features = TRUE, na_impute = c("median", "zero"), cap_scale_features = scale_features, cap_na_impute = na_impute, cap_jitter_sd = 0, seed = 42, means_slot = "longitudinal_module_means_direct", output_slot = "longitudinal_endotypes_direct" )
hc |
A |
donor_col |
Annotation column containing donor IDs. |
time_col |
Annotation column containing timepoint labels. |
layer |
Optional layer index, layer id, layer name, or |
time_levels |
Required explicit timepoint order vector. |
k |
Candidate donor-trajectory cluster numbers per module. |
method |
One of |
nstart |
Number of random starts for direct |
cap_runs |
Number of repeated clustering runs used to build CAP. |
impute |
Logical. If |
impute_method |
Missing-value method passed to |
ntree |
Number of trees for |
min_cluster_fraction |
Minimum allowed fraction of donors in the smallest module cluster. |
score_method |
One of |
scale_features |
Logical. If |
na_impute |
One of |
cap_scale_features |
Logical. If |
cap_na_impute |
One of |
cap_jitter_sd |
Optional Gaussian jitter SD added per CAP rerun when
|
seed |
Random seed. |
means_slot |
Satellite slot for module means. |
output_slot |
Satellite slot for direct endotype outputs. |
A list with updated hc, step plots, and diagnostics. When
layer = "all" (or multiple layers are supplied), returns per-layer plot
and diagnostic lists keyed by layer id.
hc <- hc_example_data("clustered") res <- hc_longitudinal_step1_module_donor_direct( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 ) hc <- res$hchc <- hc_example_data("clustered") res <- hc_longitudinal_step1_module_donor_direct( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 ) hc <- res$hc
Runs the exact CAP -> PCA -> graph -> Leiden donor meta-clustering and returns the PCA/UMAP embeddings.
hc_longitudinal_step2_meta_clustering( hc, slot_name = "longitudinal_endotypes", dimensions = 4, graph_method = c("knn", "snn"), knn_method = c("annoy", "rann"), graph_k = 7, resolution = 0.4, leiden_method = "RBConfigurationVertexPartition", cluster_prefix = "MC", compute_umap = TRUE, umap_neighbors = 15, umap_min_dist = 0.3, seed = 42 )hc_longitudinal_step2_meta_clustering( hc, slot_name = "longitudinal_endotypes", dimensions = 4, graph_method = c("knn", "snn"), knn_method = c("annoy", "rann"), graph_k = 7, resolution = 0.4, leiden_method = "RBConfigurationVertexPartition", cluster_prefix = "MC", compute_umap = TRUE, umap_neighbors = 15, umap_min_dist = 0.3, seed = 42 )
hc |
A |
slot_name |
Satellite slot containing step 1 outputs. Use a concrete
slot name, a shared prefix such as |
dimensions |
Number of PCA dimensions used to build the donor graph. |
graph_method |
Graph type used before Leiden clustering. |
knn_method |
Nearest-neighbor backend used for graph construction. |
graph_k |
Number of neighbors used for the donor graph. |
resolution |
Leiden resolution parameter. |
leiden_method |
Leiden partition method. |
cluster_prefix |
Prefix for meta-cluster labels. |
compute_umap |
Logical. If |
umap_neighbors |
UMAP neighborhood size. |
umap_min_dist |
UMAP minimum distance. |
seed |
Random seed. |
A list with updated hc, step plots, and diagnostics. When multiple
slots are processed, plots and diagnostics are returned as named lists
keyed by layer/slot, plus a slot_info table describing the resolved
slots.
hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc res <- hc_longitudinal_step2_meta_clustering(hc, graph_k = 5, dimensions = 2) hc <- res$hchc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc res <- hc_longitudinal_step2_meta_clustering(hc, graph_k = 5, dimensions = 2) hc <- res$hc
Plots module trajectories after meta-clustering using donor and meta-cluster mean waves.
hc_longitudinal_step3_meta_module_trajectories( hc, slot_name = "longitudinal_endotypes", facet_ncol = 4, free_y = TRUE, square_panels = TRUE, value_mode = c("scaled_mean_vst", "expression"), value_range = c(-2, 2) )hc_longitudinal_step3_meta_module_trajectories( hc, slot_name = "longitudinal_endotypes", facet_ncol = 4, free_y = TRUE, square_panels = TRUE, value_mode = c("scaled_mean_vst", "expression"), value_range = c(-2, 2) )
hc |
A |
slot_name |
Satellite slot containing meta-clustering outputs. Use a
concrete slot name, a shared prefix such as |
facet_ncol |
Number of facet columns. |
free_y |
Logical. If |
square_panels |
Logical. If |
value_mode |
One of |
value_range |
Optional numeric vector of length 2 for the y-axis range
when |
A list with unchanged hc and the step 3 plot. When multiple slots
are processed, plots is returned as a named list keyed by layer/slot,
plus a slot_info table describing the resolved slots.
hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) res <- hc_longitudinal_step3_meta_module_trajectories(hc)hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) res <- hc_longitudinal_step3_meta_module_trajectories(hc)
Runs the direct donor-by-time step 1 backend and then reuses the existing step 2 and step 3 quick wrappers on the resulting output slot family.
hc_longitudinal_workflow_direct( hc, donor_col = "Subject", time_col = "Time_token", layer = NULL, time_levels, k = 2:6, method = c("kmeans", "hclust"), nstart = 50, cap_runs = 50, impute = TRUE, impute_method = "rfcont", ntree = 10, min_cluster_fraction = 0.1, score_method = c("calinski_harabasz", "tot_withinss"), scale_features = TRUE, na_impute = c("median", "zero"), cap_scale_features = scale_features, cap_na_impute = na_impute, cap_jitter_sd = 0, seed = 42, means_slot = "longitudinal_module_means_direct", output_slot = "longitudinal_endotypes_direct" )hc_longitudinal_workflow_direct( hc, donor_col = "Subject", time_col = "Time_token", layer = NULL, time_levels, k = 2:6, method = c("kmeans", "hclust"), nstart = 50, cap_runs = 50, impute = TRUE, impute_method = "rfcont", ntree = 10, min_cluster_fraction = 0.1, score_method = c("calinski_harabasz", "tot_withinss"), scale_features = TRUE, na_impute = c("median", "zero"), cap_scale_features = scale_features, cap_na_impute = na_impute, cap_jitter_sd = 0, seed = 42, means_slot = "longitudinal_module_means_direct", output_slot = "longitudinal_endotypes_direct" )
hc |
A |
donor_col |
Annotation column containing donor IDs. |
time_col |
Annotation column containing timepoint labels. |
layer |
Optional layer index, layer id, layer name, or |
time_levels |
Required explicit timepoint order vector. |
k |
Candidate donor-trajectory cluster numbers per module. |
method |
One of |
nstart |
Number of random starts for direct |
cap_runs |
Number of repeated clustering runs used to build CAP. |
impute |
Logical. If |
impute_method |
Missing-value method passed to |
ntree |
Number of trees for |
min_cluster_fraction |
Minimum allowed fraction of donors in the smallest module cluster. |
score_method |
One of |
scale_features |
Logical. If |
na_impute |
One of |
cap_scale_features |
Logical. If |
cap_na_impute |
One of |
cap_jitter_sd |
Optional Gaussian jitter SD added per CAP rerun when
|
seed |
Random seed. |
means_slot |
Satellite slot for module means. |
output_slot |
Satellite slot for direct endotype outputs. |
A list with updated hc, nested plots, and per-step diagnostics.
hc <- hc_example_data("clustered") res <- hc_longitudinal_workflow_direct( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 ) hc <- res$hchc <- hc_example_data("clustered") res <- hc_longitudinal_workflow_direct( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 ) hc <- res$hc
MultiAssayExperiment from an HCoCenaExperiment
Access MultiAssayExperiment from an HCoCenaExperiment
hc_mae(x) ## S4 method for signature 'HCoCenaExperiment' hc_mae(x)hc_mae(x) ## S4 method for signature 'HCoCenaExperiment' hc_mae(x)
x |
An |
A MultiAssayExperiment::MultiAssayExperiment object.
hc <- hc_init() class(hc_mae(hc))hc <- hc_init() class(hc_mae(hc))
Cuts the dendrogram of the module heatmap to merge modules with similar
expression patterns. Run with save = FALSE first to preview a given k;
save = TRUE overwrites the current module assignment and cannot be undone.
hc_merge_clusters( hc, k = "auto", save = TRUE, method = "complete", k_min = 2, k_max = NULL, auto_parsimony_penalty = 1e-04, verbose = TRUE )hc_merge_clusters( hc, k = "auto", save = TRUE, method = "complete", k_min = 2, k_max = NULL, auto_parsimony_penalty = 1e-04, verbose = TRUE )
hc |
A |
k |
Either an integer (the number of merged modules) or |
save |
Logical. If |
method |
Agglomeration method for the dendrogram. Default |
k_min |
Smallest candidate |
k_max |
Largest candidate |
auto_parsimony_penalty |
Small penalty applied in auto mode to prefer
fewer modules when silhouette scores are nearly tied. Default |
verbose |
Logical. Print the selected |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_plot_cluster_heatmap(hc, file_name = FALSE) hc <- hc_merge_clusters(hc, k = 2, save = FALSE)hc <- hc_example_data("clustered") hc <- hc_plot_cluster_heatmap(hc, file_name = FALSE) hc <- hc_merge_clusters(hc, k = 2, save = FALSE)
Correlate categorical metadata with modules (S4 API)
hc_meta_correlation_cat(hc, meta, set, p_val = 0.05, padj = "BH")hc_meta_correlation_cat(hc, meta, set, p_val = 0.05, padj = "BH")
hc |
A |
meta |
A single string. Name of the categorical annotation column to correlate with the module expression patterns. |
set |
An integer. Number of the dataset/layer to use. |
p_val |
Maximum adjusted p-value for a correlation to count as significant. Default is 0.05. Non-significant cells are shown in grey. |
padj |
Multiple-testing correction method passed to
|
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc_meta_correlation_cat(hc, set = 1, meta = "batch")hc <- hc_example_data("clustered") hc_meta_correlation_cat(hc, set = 1, meta = "batch")
Correlates the mean expression of each module's genes per sample with one or more numeric annotation columns, and shows the result as a heatmap. Non-significant correlations are left blank.
hc_meta_correlation_num(hc, set, meta, p_val = 0.05, padj = "BH")hc_meta_correlation_num(hc, set, meta, p_val = 0.05, padj = "BH")
hc |
A |
set |
An integer. Number of the dataset/layer to use. |
meta |
Character vector of numeric annotation column names to correlate with the module expression patterns. |
p_val |
Maximum adjusted p-value for a correlation to count as significant. Default is 0.05. |
padj |
Multiple-testing correction method passed to
|
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc_meta_correlation_num(hc, set = 1, meta = "age")hc <- hc_example_data("clustered") hc_meta_correlation_num(hc, set = 1, meta = "age")
Meta-data plotting (S4 API)
hc_meta_plot( hc, set, group_col = NULL, meta_col = NULL, type = "cat", cols = NULL )hc_meta_plot( hc, set, group_col = NULL, meta_col = NULL, type = "cat", cols = NULL )
hc |
A |
set |
An integer. Number of the dataset/layer to inspect. |
group_col |
Annotation column used to group the samples, e.g. the timepoint or condition. |
meta_col |
Annotation column whose distribution is plotted. |
type |
Either "cat" (default) for categorical |
cols |
Optional named vector of colours for the groups. |
Updated HCoCenaExperiment.
hc <- hc_example_data("prepared") hc <- hc_meta_plot(hc, set = 1, group_col = "group", meta_col = "batch")hc <- hc_example_data("prepared") hc <- hc_meta_plot(hc, set = 1, group_col = "group", meta_col = "batch")
Test module differences between conditions (S4 API)
hc_module_condition_significance( hc, set = "all", condition_col = NULL, donor_col = NULL, time_col = NULL, run_wilcox = TRUE, run_limma = TRUE, run_lmm = FALSE, lmm_include_time = TRUE, limma_reference = NULL, limma_trend = TRUE, standardize_modules = FALSE, padj = "BH", export_excel = TRUE, excel_file = "Module_condition_significance.xlsx", slot_name = "module_condition_significance" )hc_module_condition_significance( hc, set = "all", condition_col = NULL, donor_col = NULL, time_col = NULL, run_wilcox = TRUE, run_limma = TRUE, run_lmm = FALSE, lmm_include_time = TRUE, limma_reference = NULL, limma_trend = TRUE, standardize_modules = FALSE, padj = "BH", export_excel = TRUE, excel_file = "Module_condition_significance.xlsx", slot_name = "module_condition_significance" )
hc |
A |
set |
Integer vector of layer indices or |
condition_col |
Column name in annotation files defining conditions.
If |
donor_col |
Optional donor identifier column in annotation files.
Required if |
time_col |
Optional time column in annotation files (used by LMM when
available and |
run_wilcox |
Logical; run Wilcoxon/Kruskal module-wise test. |
run_limma |
Logical; run limma pairwise contrasts. |
run_lmm |
Logical; run linear mixed model ( |
lmm_include_time |
Logical; include |
limma_reference |
Optional reference condition for one-vs-reference
limma contrasts. If |
limma_trend |
Logical; passed to |
standardize_modules |
Logical; z-score each module across the samples of a layer before testing. Raw module means carry the module's absolute expression level, so limma's variance moderation - which borrows information across modules - is dominated by the highly expressed ones, and the reported effect sizes are not comparable between modules. The standardization is applied per layer, so with several layers pooled
( Default |
padj |
Multiple-testing correction method (passed to |
export_excel |
Logical; write result tables to Excel in save folder. |
excel_file |
File name for the Excel export. |
slot_name |
Satellite slot name for storing results. |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_module_condition_significance( hc, condition_col = "group", run_limma = FALSE, export_excel = FALSE )hc <- hc_example_data("clustered") hc <- hc_module_condition_significance( hc, condition_col = "group", run_limma = FALSE, export_excel = FALSE )
Returns the Group-Fold-Change values behind the module heatmap as tables: once aggregated per group (the numbers shown in the heatmap) and once resolved per individual sample.
hc_module_gfc_tables( hc, layer = 1, group_col = NULL, modules = "all", annotate = TRUE, export_xlsx = TRUE, out_dir = NULL, file_name = "Module_GFC_group_and_sample.xlsx", verbose = TRUE )hc_module_gfc_tables( hc, layer = 1, group_col = NULL, modules = "all", annotate = TRUE, export_xlsx = TRUE, out_dir = NULL, file_name = "Module_GFC_group_and_sample.xlsx", verbose = TRUE )
hc |
A |
layer |
Layer to use, either its index or its name. Defaults to the first layer. |
group_col |
Annotation column used for grouping. Defaults to the
|
modules |
Either |
annotate |
Logical; if |
export_xlsx |
Logical; if |
out_dir |
Target folder for the workbook. If |
file_name |
File name of the workbook. |
verbose |
Logical; print the self-check and the export path. |
hCoCena itself only stores the group level (module_gfc_means, modules by
groups). This function computes the per-sample counterpart using hCoCena's
own GFC definition, so both tables live on the same scale:
when data_in_log is TRUE, values are anti-logged (base 2) and all
averaging happens on the linear scale,
group means (or the raw sample values) are formed per gene,
the reference follows the control_keyword global setting, exactly as
hc_run_expression_analysis_2() does. With "none" it is the unweighted
mean of the group means – not the mean across all samples, which
differs whenever the groups are unequally sized. With a control keyword
it is the mean of the matching control group, and that group is dropped
from the group table just like in the heatmap,
foldchange(x, ref) is x / ref when x >= ref and -ref / x
otherwise, a signed ratio rather than a difference of logs,
values are clamped to +/- range_GFC,
the module value is the mean across the genes of that module.
Because step 4 is non-linear and step 5 truncates, the group table is not
the average of the sample table (fc(mean(x)) != mean(fc(x))). Both are
correct but answer different questions: by_group is the value plotted in
the heatmap, by_sample shows how uniformly the samples carry it. Use
by_sample for sample-level statistics and by_group for figure labels.
As a self-check the function compares its own by_group against the
grp_means stored by hCoCena and reports the largest absolute difference,
which is expected to be on the order of 1e-3 – the rounding hCoCena
applies per gene.
Updated HCoCenaExperiment. The tables are stored in
hc@satellite$module_gfc_tables as by_group, by_group_long,
by_sample, by_sample_long, plus reference and settings.
hc_plot_cluster_heatmap(), which produces the group-level
module_gfc_means table.
hc <- hc_example_data("clustered") hc <- hc_module_gfc_tables(hc, export_xlsx = FALSE) hc_satellite(hc, "module_gfc_tables")$by_grouphc <- hc_example_data("clustered") hc <- hc_module_gfc_tables(hc, export_xlsx = FALSE) hc_satellite(hc, "module_gfc_tables")$by_group
Compares two externally stored gene-to-cluster tables and visualises how the modules of the first assignment map onto those of the second.
hc_network_comparison_1( hc, gtc1_path, gtc2_path, sep = "\t", header = TRUE, cellsize = 18 )hc_network_comparison_1( hc, gtc1_path, gtc2_path, sep = "\t", header = TRUE, cellsize = 18 )
hc |
A |
gtc1_path |
Path to the first gene-to-cluster file. |
gtc2_path |
Path to the second gene-to-cluster file. |
sep |
Field separator of both files. Default is |
header |
Logical. Whether the files carry a header row. Default |
cellsize |
Cell size of the resulting heatmap. Default is 18. |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") gtc <- hc_gene_to_cluster(hc) f1 <- tempfile(fileext = ".tsv") f2 <- tempfile(fileext = ".tsv") utils::write.table(gtc, f1, sep = "\t", row.names = FALSE, quote = FALSE) utils::write.table(gtc, f2, sep = "\t", row.names = FALSE, quote = FALSE) hc <- hc_network_comparison_1(hc, gtc1_path = f1, gtc2_path = f2)hc <- hc_example_data("clustered") gtc <- hc_gene_to_cluster(hc) f1 <- tempfile(fileext = ".tsv") f2 <- tempfile(fileext = ".tsv") utils::write.table(gtc, f1, sep = "\t", row.names = FALSE, quote = FALSE) utils::write.table(gtc, f2, sep = "\t", row.names = FALSE, quote = FALSE) hc <- hc_network_comparison_1(hc, gtc1_path = f1, gtc2_path = f2)
Contrasts the neighbourhoods of gene_vec between two networks and reports
which edges are shared and which are unique to either network.
hc_network_comparison_2(hc, net1, net2, as = "igraph", gene_vec)hc_network_comparison_2(hc, net1, net2, as = "igraph", gene_vec)
hc |
A |
net1 |
First network as an |
net2 |
Second network as an |
as |
Object type of |
gene_vec |
Character vector of genes to restrict the comparison to. |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") g <- hc_graph(hc) hc <- hc_network_comparison_2( hc, net1 = g, net2 = g, gene_vec = igraph::V(g)$name[1:3] )hc <- hc_example_data("clustered") g <- hc_graph(hc) hc <- hc_network_comparison_2( hc, net1 = g, net2 = g, gene_vec = igraph::V(g)$name[1:3] )
PCA plotting (S4 API)
hc_pca(hc, which = "all", color_by = NULL, ellipses = FALSE, cols = NULL)hc_pca(hc, which = "all", color_by = NULL, ellipses = FALSE, cols = NULL)
hc |
A |
which |
Which gene set to run the PCA on: "all" (default, all genes), "topvar" (the top-variable genes of each layer) or "network_genes" (only genes that ended up in the integrated network). |
color_by |
Optional annotation column name used to colour the samples.
If |
ellipses |
Logical. Whether to draw group confidence ellipses.
Default is |
cols |
Optional named vector of colours for the groups. If |
Updated HCoCenaExperiment.
hc <- hc_example_data("prepared") hc <- hc_pca(hc)hc <- hc_example_data("prepared") hc <- hc_pca(hc)
PCA algorithm comparison (S4 API)
hc_pca_algo_compare(hc, gtc = NULL, algo = NULL, cols = NULL)hc_pca_algo_compare(hc, gtc = NULL, algo = NULL, cols = NULL)
hc |
A |
gtc |
Optional gene-to-cluster table to compare against. If |
algo |
Optional name of the clustering algorithm the |
cols |
Optional named vector of colours for the sample groups. |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_pca_algo_compare(hc)hc <- hc_example_data("clustered") hc <- hc_pca_algo_compare(hc)
Uses hc@satellite$celltype_annotation and draws a heatmap-like matrix
(modules x cell types) for easier interpretation than stacked barplots.
hc_plot_celltype_annotation_matrix( hc, database = NULL, value = c("pct", "count"), top_celltypes = 15, include_other = TRUE, other_label = "Other", cluster_order = NULL, low_color = "#f7fbff", high_color = "#08306b", return_data = TRUE )hc_plot_celltype_annotation_matrix( hc, database = NULL, value = c("pct", "count"), top_celltypes = 15, include_other = TRUE, other_label = "Other", cluster_order = NULL, low_color = "#f7fbff", high_color = "#08306b", return_data = TRUE )
hc |
A |
database |
Optional single database name. If |
value |
One of |
top_celltypes |
Maximum number of cell types to show. Remaining cell
types can be collapsed into |
include_other |
Logical. Collapse non-top cell types into one column. |
other_label |
Label for the collapsed column. |
cluster_order |
Optional explicit module order (character vector). |
low_color |
Low-end fill color. |
high_color |
High-end fill color. |
return_data |
Logical. If |
A ggplot object or a list containing plot + data.
hc <- hc_example_data("clustered") gmt <- system.file("extdata", "toy_celltype_markers.gmt", package = "hcocena") hc <- hc_celltype_annotation( hc, databases = character(0), custom_gmt_files = c(CellTypes = gmt), export_excel = FALSE ) p <- hc_plot_celltype_annotation_matrix(hc)hc <- hc_example_data("clustered") gmt <- system.file("extdata", "toy_celltype_markers.gmt", package = "hcocena") hc <- hc_celltype_annotation( hc, databases = character(0), custom_gmt_files = c(CellTypes = gmt), export_excel = FALSE ) p <- hc_plot_celltype_annotation_matrix(hc)
Plot module heatmap (S4 API)
hc_plot_cluster_heatmap(hc, file_name = "Heatmap_modules.pdf", ...)hc_plot_cluster_heatmap(hc, file_name = "Heatmap_modules.pdf", ...)
hc |
A |
file_name |
Optional export file name for the module heatmap.
Defaults to |
... |
Additional plotting arguments forwarded to the heatmap backend,
including |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_plot_cluster_heatmap(hc, file_name = FALSE)hc <- hc_example_data("clustered") hc <- hc_plot_cluster_heatmap(hc, file_name = FALSE)
Creates a module heatmap view for selected modules in the exact order
supplied by modules. The module labels and module-color annotations are
preserved, and the GFC expression color scale is inherited from the full
heatmap cache instead of being recomputed from the subset.
hc_plot_cluster_heatmap_view( hc, modules, file_name = "Heatmap_modules_view.pdf", col_order = NULL, cluster_columns = FALSE, cluster_rows = FALSE, gfc_colors = NULL, gfc_scale_limits = NULL, preserve_full_heatmap = TRUE, store_view = TRUE, view_name = NULL, ... )hc_plot_cluster_heatmap_view( hc, modules, file_name = "Heatmap_modules_view.pdf", col_order = NULL, cluster_columns = FALSE, cluster_rows = FALSE, gfc_colors = NULL, gfc_scale_limits = NULL, preserve_full_heatmap = TRUE, store_view = TRUE, view_name = NULL, ... )
hc |
A |
modules |
Character/numeric vector of modules to show. Accepts current
module labels such as |
file_name |
Optional export file name for the view. Use |
col_order |
Optional condition order. If |
cluster_columns |
Logical. Whether to cluster columns in the view. |
cluster_rows |
Logical. Whether to cluster rows in the view. Defaults to
|
gfc_colors |
Optional GFC palette override. If |
gfc_scale_limits |
Optional GFC scale override. If |
preserve_full_heatmap |
Logical. If |
store_view |
Logical. If |
view_name |
Optional name used when |
... |
Additional plotting arguments forwarded to
|
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_plot_cluster_heatmap_view( hc, modules = c("M2", "M3"), file_name = FALSE )hc <- hc_example_data("clustered") hc <- hc_plot_cluster_heatmap_view( hc, modules = c("M2", "M3"), file_name = FALSE )
plot cutoffs
hc_plot_cutoffs( hc, interactive = TRUE, hline = list(R.squared = NULL, no_edges = NULL, no_nodes = NULL, no_networks = NULL) )hc_plot_cutoffs( hc, interactive = TRUE, hline = list(R.squared = NULL, no_edges = NULL, no_nodes = NULL, no_networks = NULL) )
hc |
A |
interactive |
Logical. If |
hline |
Named list of horizontal reference lines to draw, with the
entries |
Updated HCoCenaExperiment, invisibly; called for the cut-off
diagnostic plot it draws.
hc <- hc_example_data("after_part1") hc <- hc_plot_cutoffs(hc, interactive = FALSE)hc <- hc_example_data("after_part1") hc <- hc_plot_cutoffs(hc, interactive = FALSE)
Plots the logged degree distribution and its linear fit for each layer at the chosen correlation cutoff, to check how well the network follows a scale-free topology.
hc_plot_deg_dist(hc)hc_plot_deg_dist(hc)
hc |
A |
Updated HCoCenaExperiment.
hc <- hc_example_data("after_part1") hc <- hc_plot_deg_dist(hc)hc <- hc_example_data("after_part1") hc <- hc_plot_deg_dist(hc)
This is a convenience plotting helper for notebook/interactive usage. It
draws the enrichment panels already stored in hc@satellite$enrichments
after hc_functional_enrichment(), without recomputing enrichment.
hc_plot_enrichment_panels(hc, panels = NULL, heatmap_side = "left")hc_plot_enrichment_panels(hc, panels = NULL, heatmap_side = "left")
hc |
A |
panels |
Optional character vector of panel names to draw.
Default ( |
heatmap_side |
One of |
Invisibly returns hc.
hc <- hc_example_data("clustered") gmt <- tempfile(fileext = ".gmt") writeLines( c( paste(c("T cells", "-", "CD3D", "CD3E", "CD3G", "CD2", "CD28", "LCK", "ZAP70", "IL7R", "CD7", "TRAC"), collapse = "\t"), paste(c("B cells", "-", "CD19", "MS4A1", "CD79A", "CD79B", "BLNK", "PAX5", "CR2", "FCRL1", "TNFRSF13B", "VPREB3"), collapse = "\t"), paste(c("Monocytes", "-", "CD14", "LYZ", "FCN1", "VCAN", "S100A8", "S100A9", "CSF1R", "ITGAM", "CD68", "FCGR3A"), collapse = "\t"), paste(c("NK cells", "-", "NKG7", "GNLY", "KLRD1", "KLRF1", "PRF1", "GZMB", "NCR1", "KLRC1", "FGFBP2", "SPON2"), collapse = "\t") ), gmt ) hc <- hc_functional_enrichment( hc, gene_sets = character(0), custom_gmt_files = c(CellTypes = gmt) ) p <- hc_plot_enrichment_panels(hc)hc <- hc_example_data("clustered") gmt <- tempfile(fileext = ".gmt") writeLines( c( paste(c("T cells", "-", "CD3D", "CD3E", "CD3G", "CD2", "CD28", "LCK", "ZAP70", "IL7R", "CD7", "TRAC"), collapse = "\t"), paste(c("B cells", "-", "CD19", "MS4A1", "CD79A", "CD79B", "BLNK", "PAX5", "CR2", "FCRL1", "TNFRSF13B", "VPREB3"), collapse = "\t"), paste(c("Monocytes", "-", "CD14", "LYZ", "FCN1", "VCAN", "S100A8", "S100A9", "CSF1R", "ITGAM", "CD68", "FCGR3A"), collapse = "\t"), paste(c("NK cells", "-", "NKG7", "GNLY", "KLRD1", "KLRF1", "PRF1", "GZMB", "NCR1", "KLRC1", "FGFBP2", "SPON2"), collapse = "\t") ), gmt ) hc <- hc_functional_enrichment( hc, gene_sets = character(0), custom_gmt_files = c(CellTypes = gmt) ) p <- hc_plot_enrichment_panels(hc)
Plot module knowledge network from enrichment + upstream inference (S4 API)
hc_plot_enrichment_upstream_network( hc, enrichment_mode = "selected", upstream_mode = "selected", clusters = c("all"), max_enrichment_per_module = NULL, max_upstream_per_module = NULL, collapse_redundant_terms = TRUE, link_min_share = 0.25, label_mode = "both", show_plot = TRUE, save_pdf = TRUE, pdf_name = "Module_Knowledge_Network.pdf", gfc_scale_limits = NULL, col_order = NULL, heatmap_col_order = NULL, cluster_columns = FALSE, heatmap_cluster_columns = NULL, pdf_width = NULL, pdf_height = NULL, pdf_pointsize = 11, overall_plot_scale = 1 )hc_plot_enrichment_upstream_network( hc, enrichment_mode = "selected", upstream_mode = "selected", clusters = c("all"), max_enrichment_per_module = NULL, max_upstream_per_module = NULL, collapse_redundant_terms = TRUE, link_min_share = 0.25, label_mode = "both", show_plot = TRUE, save_pdf = TRUE, pdf_name = "Module_Knowledge_Network.pdf", gfc_scale_limits = NULL, col_order = NULL, heatmap_col_order = NULL, cluster_columns = FALSE, heatmap_cluster_columns = NULL, pdf_width = NULL, pdf_height = NULL, pdf_pointsize = 11, overall_plot_scale = 1 )
hc |
A |
enrichment_mode |
Character scalar. One of |
upstream_mode |
Character scalar. One of |
clusters |
Either |
max_enrichment_per_module |
Optional positive integer. If set, keeps at most this many enrichment edges per module (best q-values first). |
max_upstream_per_module |
Optional positive integer. If set, keeps at most this many upstream edges per module (best q-values first). |
collapse_redundant_terms |
Logical. If |
link_min_share |
Minimum share of a regulator's targets in the module that must belong to a term for a term -> regulator line; the term must also hold at least 1.5 times more of these targets than expected from its size in the module (at most 3 terms per regulator). Regulators without such a term are linked to the module directly. Default 0.25. |
label_mode |
Character scalar controlling term label density:
|
show_plot |
Logical; if |
save_pdf |
Logical; if |
pdf_name |
Output PDF filename. |
gfc_scale_limits |
Optional numeric vector controlling the left module
heatmap color scale limits. Provide one positive number ( |
col_order |
Optional character vector overriding the hCoCena
heatmap column order for this knowledge-network plot only. If |
heatmap_col_order |
Legacy alias for |
cluster_columns |
Logical. If |
heatmap_cluster_columns |
Legacy alias for |
pdf_width |
Optional numeric width (inches) for network PDFs. If NULL (default), width is auto-estimated from content. |
pdf_height |
Optional numeric height (inches) for network PDFs. If NULL (default), height is auto-estimated from content. |
pdf_pointsize |
Numeric base pointsize used for PDF export devices. Default is 11. |
overall_plot_scale |
Numeric scaling factor for text and line sizes. |
Updated HCoCenaExperiment.
if (requireNamespace("decoupleR", quietly = TRUE)) { hc <- hc_example_data("clustered") gmt <- system.file("extdata", "toy_celltype_markers.gmt", package = "hcocena") hc <- hc_functional_enrichment( hc, gene_sets = character(0), custom_gmt_files = c(CellTypes = gmt), universe = "network" ) hc <- hc_upstream_inference( hc, resources = "Pathway", custom_pathway_gmt = c(CellTypes = gmt), plot = FALSE, save_pdf = FALSE ) hc <- hc_plot_enrichment_upstream_network(hc, save_pdf = FALSE) }if (requireNamespace("decoupleR", quietly = TRUE)) { hc <- hc_example_data("clustered") gmt <- system.file("extdata", "toy_celltype_markers.gmt", package = "hcocena") hc <- hc_functional_enrichment( hc, gene_sets = character(0), custom_gmt_files = c(CellTypes = gmt), universe = "network" ) hc <- hc_upstream_inference( hc, resources = "Pathway", custom_pathway_gmt = c(CellTypes = gmt), plot = FALSE, save_pdf = FALSE ) hc <- hc_plot_enrichment_upstream_network(hc, save_pdf = FALSE) }
Plot network colored by GFC (S4 API)
hc_plot_gfc_network(hc)hc_plot_gfc_network(hc)
hc |
A |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_plot_gfc_network(hc)hc <- hc_example_data("clustered") hc <- hc_plot_gfc_network(hc)
Plot integrated network (S4 API)
hc_plot_integrated_network( hc, layout = NULL, layout_algorithm = NULL, gene_labels = NULL, save = TRUE, store_plot = FALSE, label_offset = 50 )hc_plot_integrated_network( hc, layout = NULL, layout_algorithm = NULL, gene_labels = NULL, save = TRUE, store_plot = FALSE, label_offset = 50 )
hc |
A |
layout |
Optional pre-computed layout matrix. If |
layout_algorithm |
Optional igraph layout function name, e.g.
|
gene_labels |
Optional character vector of genes to label in the plot. |
save |
Logical. Write the network to PDF. Default is |
store_plot |
Logical. Keep the plot object in |
label_offset |
Distance between a node and its label. Default is 50. |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_plot_integrated_network(hc)hc <- hc_example_data("clustered") hc <- hc_plot_integrated_network(hc)
Draws the interpretations stored by hc_llm_enrichment() or
hc_llm_import(): a colored module box on the left and the inferred
function on the right, optionally next to the module heatmap.
hc_plot_llm_enrichment( hc, slot_name = "llm_enrichment", modules = NULL, fields = c("general_processes", "contextual_state", "key_regulators", "grounded_processes"), max_chars = 90, text_size = 4, with_heatmap = TRUE, col_order = NULL, heatmap_col_order = NULL, cluster_columns = FALSE, heatmap_cluster_columns = NULL, heatmap_rel_width = 1.7, text_rel_width = 1.25, title = "AI-assisted module interpretation", module_label_fontsize = NULL, module_label_pt_size = NULL, module_box_width_cm = NULL, save = TRUE, file_stem = "LLM_enrichment", pdf_width = NULL, pdf_height = NULL, dpi = 300 )hc_plot_llm_enrichment( hc, slot_name = "llm_enrichment", modules = NULL, fields = c("general_processes", "contextual_state", "key_regulators", "grounded_processes"), max_chars = 90, text_size = 4, with_heatmap = TRUE, col_order = NULL, heatmap_col_order = NULL, cluster_columns = FALSE, heatmap_cluster_columns = NULL, heatmap_rel_width = 1.7, text_rel_width = 1.25, title = "AI-assisted module interpretation", module_label_fontsize = NULL, module_label_pt_size = NULL, module_box_width_cm = NULL, save = TRUE, file_stem = "LLM_enrichment", pdf_width = NULL, pdf_height = NULL, dpi = 300 )
hc |
An |
slot_name |
Slot the results were stored under. Default is
|
modules |
Optional character vector to subset modules. |
fields |
Character vector selecting which fields to plot:
|
max_chars |
Approximate number of characters shown per term. Longer
text is wrapped onto at most two lines (never inside parentheses); if it
still does not fit, whole processes are dropped from the end, so the text
ends at a |
text_size |
Numeric text size passed to |
with_heatmap |
Logical. If |
col_order |
Optional character vector overriding the hCoCena
heatmap column order for this LLM plot only. If |
heatmap_col_order |
Legacy alias for |
cluster_columns |
Logical. If |
heatmap_cluster_columns |
Legacy alias for |
heatmap_rel_width |
Relative width of the heatmap panel when
|
text_rel_width |
Relative width of the text panel when
|
title |
Plot title. Default is |
module_label_fontsize |
Optional numeric fontsize for module labels
inside the colored module boxes. If |
module_label_pt_size |
Optional numeric glyph size for module labels
inside the colored module boxes. Uses |
module_box_width_cm |
Optional numeric width (cm) for the module color
boxes. If |
save |
Logical. If |
file_stem |
Base file name used for exported plots. Field names and, for
single-module selections, the module label are appended automatically.
Default is |
pdf_width |
Optional numeric export width in inches. If |
pdf_height |
Optional numeric export height in inches. If |
dpi |
Numeric export DPI for PNG output. Default is |
A single plot object when one field is selected, otherwise a named list of plot objects.
# Interpretations imported from a web chat answer (no API key needed): hc <- hc_example_data("clustered") hc <- hc_plot_cluster_heatmap(hc, file_name = FALSE) hc <- hc_llm_enrichment(hc, modules = "M1", provider = "manual", verbose = FALSE) id <- hc_satellite(hc, "llm_enrichment_pending")$id answer <- paste0( '{"request_id": "', id, '", "results": [{"set": "M1", ', '"general_processes": "B cell receptor signaling", ', '"contextual_state": "mature B cell program", ', '"key_regulators": "PAX5 / EBF1"}]}' ) hc <- hc_llm_import(hc, text = answer, verbose = FALSE) p <- hc_plot_llm_enrichment(hc, with_heatmap = FALSE, save = FALSE)# Interpretations imported from a web chat answer (no API key needed): hc <- hc_example_data("clustered") hc <- hc_plot_cluster_heatmap(hc, file_name = FALSE) hc <- hc_llm_enrichment(hc, modules = "M1", provider = "manual", verbose = FALSE) id <- hc_satellite(hc, "llm_enrichment_pending")$id answer <- paste0( '{"request_id": "', id, '", "results": [{"set": "M1", ', '"general_processes": "B cell receptor signaling", ', '"contextual_state": "mature B cell program", ', '"key_regulators": "PAX5 / EBF1"}]}' ) hc <- hc_llm_import(hc, text = answer, verbose = FALSE) p <- hc_plot_llm_enrichment(hc, with_heatmap = FALSE, save = FALSE)
Plot CAP heatmap (donor x module-cluster proportions)
hc_plot_longitudinal_cap( hc, slot_name = "longitudinal_endotypes", save_pdf = TRUE, file_prefix = "Longitudinal_CAP", show_values = FALSE, min_label_prop = 0.5, donor_order = NULL )hc_plot_longitudinal_cap( hc, slot_name = "longitudinal_endotypes", save_pdf = TRUE, file_prefix = "Longitudinal_CAP", show_values = FALSE, min_label_prop = 0.5, donor_order = NULL )
hc |
A |
slot_name |
Satellite slot with CAP outputs. |
save_pdf |
Logical. If |
file_prefix |
Prefix for output filename. |
show_values |
Logical. If |
min_label_prop |
Minimum proportion threshold for text labels. |
donor_order |
Optional donor order for x-axis. If |
List with cap_heatmap ggplot.
hc <- hc_example_data("clustered") long <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 ) hc <- long$hc p <- hc_plot_longitudinal_cap(hc, save_pdf = FALSE)hc <- hc_example_data("clustered") long <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 ) hc <- long$hc p <- hc_plot_longitudinal_cap(hc, save_pdf = FALSE)
Plot endotype-to-meta-cluster flow as Sankey diagram
hc_plot_longitudinal_endotype_meta_flow( hc, slot_name = "longitudinal_endotypes", save_html = TRUE, file_prefix = "Longitudinal_Endotype_Meta_Flow" )hc_plot_longitudinal_endotype_meta_flow( hc, slot_name = "longitudinal_endotypes", save_html = TRUE, file_prefix = "Longitudinal_Endotype_Meta_Flow" )
hc |
A |
slot_name |
Satellite slot with |
save_html |
Logical. If |
file_prefix |
Output filename prefix. |
A list with sankey htmlwidget (or NULL if unavailable) and
links table.
hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) p <- hc_plot_longitudinal_endotype_meta_flow(hc, save_html = FALSE)hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) p <- hc_plot_longitudinal_endotype_meta_flow(hc, save_html = FALSE)
Creates a PCA donor plot and a module-wave plot (mean module value over time
per endotype) from hc_longitudinal_endotype_clustering() outputs.
hc_plot_longitudinal_endotypes( hc, slot_name = "longitudinal_endotypes", save_pdf = TRUE, file_prefix = "Longitudinal_Endotypes", pca_width = 7, pca_height = 5, waves_width = 12, waves_height = 8 )hc_plot_longitudinal_endotypes( hc, slot_name = "longitudinal_endotypes", save_pdf = TRUE, file_prefix = "Longitudinal_Endotypes", pca_width = 7, pca_height = 5, waves_width = 12, waves_height = 8 )
hc |
A |
slot_name |
Satellite slot containing endotype clustering output. |
save_pdf |
Logical. If |
file_prefix |
Prefix for generated PDF names. |
pca_width, pca_height
|
PDF size for PCA plot. |
waves_width, waves_height
|
PDF size for trajectory plot. |
A named list with pca and waves ggplot objects.
hc <- hc_example_data("clustered") hc <- hc_longitudinal_module_means(hc, donor_col = "donor", time_col = "timepoint") hc <- hc_longitudinal_endotype_clustering(hc, k = 2) p <- hc_plot_longitudinal_endotypes(hc, save_pdf = FALSE)hc <- hc_example_data("clustered") hc <- hc_longitudinal_module_means(hc, donor_col = "donor", time_col = "timepoint") hc <- hc_longitudinal_endotype_clustering(hc, k = 2) p <- hc_plot_longitudinal_endotypes(hc, save_pdf = FALSE)
Creates one plot per enrichment database. For each module, the top x terms
are placed into dedicated side-by-side panels (Top 1, Top 2, ...), and
meta-cluster trajectories are drawn as longitudinal waves.
hc_plot_longitudinal_enrichment_meta_waves( hc, slot_name = "longitudinal_endotypes", databases = "Kegg", top = 3, custom_terms = NULL, term_match = c("exact", "contains", "regex"), enrichment_table = c("all", "selected", "significant"), score_method = c("ssgsea", "zscore", "rank_mean"), score_scale = c("none", "z"), layer = NULL, donor_col = NULL, time_col = NULL, time_levels = NULL, min_term_genes = 5, impute_missing = c("auto", "linear", "locf", "none"), qvalue_max = NULL, show_donor_lines = TRUE, donor_alpha = 0.04, donor_linewidth = 0.18, mean_linewidth = 2, mean_point_size = 1.8, show_ci = FALSE, ci_level = 0.95, ci_alpha = 0.12, free_y = TRUE, save_pdf = TRUE, file_prefix = "Longitudinal_Enrichment_MetaWaves", save_width = 12, save_height = 12, export_excel = TRUE )hc_plot_longitudinal_enrichment_meta_waves( hc, slot_name = "longitudinal_endotypes", databases = "Kegg", top = 3, custom_terms = NULL, term_match = c("exact", "contains", "regex"), enrichment_table = c("all", "selected", "significant"), score_method = c("ssgsea", "zscore", "rank_mean"), score_scale = c("none", "z"), layer = NULL, donor_col = NULL, time_col = NULL, time_levels = NULL, min_term_genes = 5, impute_missing = c("auto", "linear", "locf", "none"), qvalue_max = NULL, show_donor_lines = TRUE, donor_alpha = 0.04, donor_linewidth = 0.18, mean_linewidth = 2, mean_point_size = 1.8, show_ci = FALSE, ci_level = 0.95, ci_alpha = 0.12, free_y = TRUE, save_pdf = TRUE, file_prefix = "Longitudinal_Enrichment_MetaWaves", save_width = 12, save_height = 12, export_excel = TRUE )
hc |
A |
slot_name |
Satellite slot with |
databases |
Character vector of databases to visualize (e.g. |
top |
Integer number of top terms per module. |
custom_terms |
Optional custom term filter (character vector or named module list). If set, matched terms are used instead of automatic top-term selection. |
term_match |
Matching mode for |
enrichment_table |
Source enrichment table: |
score_method |
|
score_scale |
Plot-only scaling: |
layer |
Optional layer selector forwarded to
|
donor_col, time_col, time_levels
|
Optional overrides forwarded to
|
min_term_genes |
Minimum matched genes per term. |
impute_missing |
Missing-value handling. |
qvalue_max |
Optional q-value cutoff before top-term selection. |
show_donor_lines |
Logical; include faint donor trajectories. |
donor_alpha, donor_linewidth
|
Styling for donor lines. |
mean_linewidth, mean_point_size
|
Styling for meta-cluster means. |
show_ci |
Logical; if |
ci_level |
Confidence level in |
ci_alpha |
Ribbon alpha for confidence bands. |
free_y |
Logical; use free y scales per module row. |
save_pdf |
Logical; save one PDF per selected database. |
file_prefix |
Prefix for saved files. |
save_width, save_height
|
PDF size. |
export_excel |
Logical; export tables per database. |
A list with plots, top_terms, donor_trajectories,
mean_trajectories, and score_method_used. When multiple slots are
processed, these top-level components are flattened with slot-prefixed
names for convenient iteration, and nested per-slot outputs are also
returned in results_by_slot, together with slot_info.
hc <- hc_example_data("clustered") gmt <- system.file("extdata", "toy_celltype_markers.gmt", package = "hcocena") hc <- hc_functional_enrichment( hc, gene_sets = character(0), custom_gmt_files = c(CellTypes = gmt), universe = "network" ) hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) waves <- hc_plot_longitudinal_enrichment_meta_waves( hc, databases = "Celltypes", top = 1, min_term_genes = 3, score_method = "rank_mean", save_pdf = FALSE, export_excel = FALSE )hc <- hc_example_data("clustered") gmt <- system.file("extdata", "toy_celltype_markers.gmt", package = "hcocena") hc <- hc_functional_enrichment( hc, gene_sets = character(0), custom_gmt_files = c(CellTypes = gmt), universe = "network" ) hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) waves <- hc_plot_longitudinal_enrichment_meta_waves( hc, databases = "Celltypes", top = 1, min_term_genes = 3, score_method = "rank_mean", save_pdf = FALSE, export_excel = FALSE )
Uses enrichment outputs from hc_functional_enrichment() to select top terms
per module for one or multiple databases (for example Kegg), then computes
sample-level term activity scores and visualizes trajectories across
donor/timepoint in module-faceted wave plots.
hc_plot_longitudinal_enrichment_waves( hc, slot_name = "longitudinal_module_means", databases = "Kegg", top = 5, custom_terms = NULL, term_match = c("exact", "contains", "regex"), enrichment_table = c("selected", "all", "significant"), score_method = c("ssgsea", "zscore", "rank_mean"), score_scale = c("none", "z"), layer = NULL, donor_col = NULL, time_col = NULL, time_levels = NULL, min_term_genes = 5, impute_missing = c("auto", "linear", "locf", "none"), qvalue_max = NULL, show_donor_lines = TRUE, facet_ncol = 4, free_y = TRUE, save_pdf = TRUE, file_prefix = "Longitudinal_Enrichment_Waves", save_width = 13, save_height = 9, export_excel = TRUE )hc_plot_longitudinal_enrichment_waves( hc, slot_name = "longitudinal_module_means", databases = "Kegg", top = 5, custom_terms = NULL, term_match = c("exact", "contains", "regex"), enrichment_table = c("selected", "all", "significant"), score_method = c("ssgsea", "zscore", "rank_mean"), score_scale = c("none", "z"), layer = NULL, donor_col = NULL, time_col = NULL, time_levels = NULL, min_term_genes = 5, impute_missing = c("auto", "linear", "locf", "none"), qvalue_max = NULL, show_donor_lines = TRUE, facet_ncol = 4, free_y = TRUE, save_pdf = TRUE, file_prefix = "Longitudinal_Enrichment_Waves", save_width = 13, save_height = 9, export_excel = TRUE )
hc |
A |
slot_name |
Satellite slot with longitudinal settings/module lookup.
Usually |
databases |
Character vector of databases to plot. |
top |
Number of top terms per module. |
custom_terms |
Optional custom term filter. Can be a character vector
(applied to all modules) or a named list with module names (e.g. |
term_match |
Matching mode for |
enrichment_table |
Which enrichment table to use:
|
score_method |
One of |
score_scale |
Plot-only scaling: |
layer |
Optional layer selector (index/id/name). If |
donor_col, time_col
|
Optional donor/time annotation columns. If |
time_levels |
Optional explicit time ordering. |
min_term_genes |
Minimum number of matched genes per term. |
impute_missing |
One of |
qvalue_max |
Optional q-value filter before top-term selection. |
show_donor_lines |
Logical; add faint donor lines behind term means. |
facet_ncol |
Number of facet columns. |
free_y |
Logical; free y-axis per module facet. |
save_pdf |
Logical; save one PDF per database. |
file_prefix |
Prefix used for output files. |
save_width, save_height
|
PDF size in inches. |
export_excel |
Logical; export top-term + trajectory tables to Excel. |
Scoring uses GSVA ssGSEA when available (score_method = "ssgsea"), with a
rank-based fallback if GSVA is unavailable.
A list with plots, top_terms, mean_trajectories,
donor_trajectories, and score_method_used.
hc <- hc_example_data("clustered") gmt <- system.file("extdata", "toy_celltype_markers.gmt", package = "hcocena") hc <- hc_functional_enrichment( hc, gene_sets = character(0), custom_gmt_files = c(CellTypes = gmt), universe = "network" ) hc <- hc_longitudinal_module_means(hc, donor_col = "donor", time_col = "timepoint") # Database names are title-cased by hc_functional_enrichment(). waves <- hc_plot_longitudinal_enrichment_waves( hc, databases = "Celltypes", top = 1, min_term_genes = 3, score_method = "rank_mean", save_pdf = FALSE, export_excel = FALSE ) waves$top_termshc <- hc_example_data("clustered") gmt <- system.file("extdata", "toy_celltype_markers.gmt", package = "hcocena") hc <- hc_functional_enrichment( hc, gene_sets = character(0), custom_gmt_files = c(CellTypes = gmt), universe = "network" ) hc <- hc_longitudinal_module_means(hc, donor_col = "donor", time_col = "timepoint") # Database names are title-cased by hc_functional_enrichment(). waves <- hc_plot_longitudinal_enrichment_waves( hc, databases = "Celltypes", top = 1, min_term_genes = 3, score_method = "rank_mean", save_pdf = FALSE, export_excel = FALSE ) waves$top_terms
Plot k-criterion diagnostics for longitudinal clustering
hc_plot_longitudinal_k_criterion( hc, slot_name = "longitudinal_endotypes", save_pdf = TRUE, file_prefix = "Longitudinal_KCriterion", facet_ncol = 4, global_scope = c("auto", "meta", "endotype") )hc_plot_longitudinal_k_criterion( hc, slot_name = "longitudinal_endotypes", save_pdf = TRUE, file_prefix = "Longitudinal_KCriterion", facet_ncol = 4, global_scope = c("auto", "meta", "endotype") )
hc |
A |
slot_name |
Satellite slot with longitudinal clustering outputs. |
save_pdf |
Logical. If |
file_prefix |
Prefix for output files. |
facet_ncol |
Number of facet columns for module-wise diagnostics. |
global_scope |
One of |
List with ggplots global_k and module_k.
hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) p <- hc_plot_longitudinal_k_criterion(hc, save_pdf = FALSE)hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) p <- hc_plot_longitudinal_k_criterion(hc, save_pdf = FALSE)
Creates three consensus diagnostics:
donor-by-donor consensus matrix heatmap (selected k)
consensus metric trajectories across tested k (delta/PAC/coverage)
donor stability distribution per meta-cluster.
hc_plot_longitudinal_meta_consensus( hc, slot_name = "longitudinal_endotypes", save_pdf = TRUE, file_prefix = "Longitudinal_Meta_Consensus", show_donor_labels = FALSE, save_table = TRUE, table_format = c("xlsx", "csv") )hc_plot_longitudinal_meta_consensus( hc, slot_name = "longitudinal_endotypes", save_pdf = TRUE, file_prefix = "Longitudinal_Meta_Consensus", show_donor_labels = FALSE, save_table = TRUE, table_format = c("xlsx", "csv") )
hc |
A |
slot_name |
Satellite slot with meta-clustering outputs. |
save_pdf |
Logical. If |
file_prefix |
Output filename prefix. |
show_donor_labels |
Logical. If |
save_table |
Logical. If |
table_format |
One of |
A list with consensus_heatmap, optional consensus_k,
optional stability, and optional summary_table.
hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) p <- hc_plot_longitudinal_meta_consensus( hc, save_pdf = FALSE, save_table = FALSE )hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) p <- hc_plot_longitudinal_meta_consensus( hc, save_pdf = FALSE, save_table = FALSE )
Plot meta-clustering embeddings and endotype cross-tab
hc_plot_longitudinal_meta_embeddings( hc, slot_name = "longitudinal_endotypes", save_pdf = TRUE, file_prefix = "Longitudinal_Meta", show_endotype_crosstab = FALSE, show_cluster_labels = TRUE, save_tables = TRUE, table_file_prefix = NULL, table_format = c("xlsx", "csv"), table_detail = c("simple", "full") )hc_plot_longitudinal_meta_embeddings( hc, slot_name = "longitudinal_endotypes", save_pdf = TRUE, file_prefix = "Longitudinal_Meta", show_endotype_crosstab = FALSE, show_cluster_labels = TRUE, save_tables = TRUE, table_file_prefix = NULL, table_format = c("xlsx", "csv"), table_detail = c("simple", "full") )
hc |
A |
slot_name |
Satellite slot with meta-clustering outputs. |
save_pdf |
Logical. If |
file_prefix |
Output filename prefix. |
show_endotype_crosstab |
Logical. If |
show_cluster_labels |
Logical. If |
save_tables |
Logical. If |
table_file_prefix |
Optional prefix for summary tables. Defaults to
|
table_format |
One of |
table_detail |
One of |
List with pca, optional umap, optional cross_tab, and tables.
hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) p <- hc_plot_longitudinal_meta_embeddings( hc, save_pdf = FALSE, save_tables = FALSE )hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) p <- hc_plot_longitudinal_meta_embeddings( hc, save_pdf = FALSE, save_tables = FALSE )
Creates module-wise wave plots after meta-clustering: faint donor trajectories plus bold meta-cluster mean trajectories.
hc_plot_longitudinal_meta_module_waves( hc, slot_name = "longitudinal_endotypes", save_pdf = TRUE, file_prefix = "Longitudinal_Meta_ModuleWaves", donor_alpha = 0.13, donor_linewidth = 0.28, mean_linewidth = 1.2, mean_point_size = 1.9, facet_ncol = 4, free_y = TRUE, square_panels = TRUE, value_mode = c("scaled_mean_vst", "expression"), value_range = c(-2, 2), save_width = NULL, save_height = NULL )hc_plot_longitudinal_meta_module_waves( hc, slot_name = "longitudinal_endotypes", save_pdf = TRUE, file_prefix = "Longitudinal_Meta_ModuleWaves", donor_alpha = 0.13, donor_linewidth = 0.28, mean_linewidth = 1.2, mean_point_size = 1.9, facet_ncol = 4, free_y = TRUE, square_panels = TRUE, value_mode = c("scaled_mean_vst", "expression"), value_range = c(-2, 2), save_width = NULL, save_height = NULL )
hc |
A |
slot_name |
Satellite slot with meta-clustering outputs. |
save_pdf |
Logical. If |
file_prefix |
Output filename prefix. |
donor_alpha |
Alpha for donor-level trajectories. |
donor_linewidth |
Line width for donor-level trajectories. |
mean_linewidth |
Line width for meta-cluster mean lines. |
mean_point_size |
Point size for meta-cluster mean points. |
facet_ncol |
Number of facet columns. |
free_y |
Logical. If |
square_panels |
Logical. If |
value_mode |
One of |
value_range |
Optional numeric vector of length 2 giving the y-axis
range for |
save_width, save_height
|
Optional PDF width/height in inches. |
A list with one ggplot object (meta_module_waves).
hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) p <- hc_plot_longitudinal_meta_module_waves(hc, save_pdf = FALSE)hc <- hc_example_data("clustered") hc <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 )$hc hc <- hc_longitudinal_endotype_clustering(hc, k = 2, nstart = 1, seed = 1) hc <- hc_longitudinal_meta_clustering( hc, feature_source = "feature_matrix_used", k = 2:3, method = "kmeans", consensus = TRUE, seed = 1 ) p <- hc_plot_longitudinal_meta_module_waves(hc, save_pdf = FALSE)
Uses module-wise clustering results from hc_longitudinal_endotype_clustering()
and produces:
donor trajectories with module-cluster means per module
a module-by-donor cluster heatmap
hc_plot_longitudinal_module_clusters( hc, slot_name = "longitudinal_endotypes", save_pdf = TRUE, file_prefix = "Longitudinal_ModuleClusters", donor_alpha = 0.14, donor_linewidth = 0.28, mean_linewidth = 1.15, mean_point_size = 1.9, facet_ncol = 4, free_y = TRUE, show_heatmap_numbers = TRUE, square_panels = FALSE, save_waves_width = NULL, save_waves_height = NULL, save_heatmap_width = NULL, save_heatmap_height = NULL )hc_plot_longitudinal_module_clusters( hc, slot_name = "longitudinal_endotypes", save_pdf = TRUE, file_prefix = "Longitudinal_ModuleClusters", donor_alpha = 0.14, donor_linewidth = 0.28, mean_linewidth = 1.15, mean_point_size = 1.9, facet_ncol = 4, free_y = TRUE, show_heatmap_numbers = TRUE, square_panels = FALSE, save_waves_width = NULL, save_waves_height = NULL, save_heatmap_width = NULL, save_heatmap_height = NULL )
hc |
A |
slot_name |
Satellite slot containing results from
|
save_pdf |
Logical. If |
file_prefix |
Prefix used for saved PDF file names. |
donor_alpha |
Alpha for donor trajectories. |
donor_linewidth |
Line width for donor trajectories. |
mean_linewidth |
Line width for cluster mean trajectories. |
mean_point_size |
Point size for cluster mean markers. |
facet_ncol |
Number of facet columns. |
free_y |
Logical. If |
show_heatmap_numbers |
Logical. If |
square_panels |
Logical. If |
save_waves_width, save_waves_height
|
Optional PDF size for trajectory plot in inches. |
save_heatmap_width, save_heatmap_height
|
Optional PDF size for CAP heatmap in inches. |
A list with ggplot objects: module_cluster_waves and
module_cluster_heatmap.
hc <- hc_example_data("clustered") long <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 ) hc <- long$hc p <- hc_plot_longitudinal_module_clusters(hc, save_pdf = FALSE)hc <- hc_example_data("clustered") long <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 ) hc <- long$hc p <- hc_plot_longitudinal_module_clusters(hc, save_pdf = FALSE)
Uses outputs from hc_longitudinal_module_means() to visualize donor
trajectories per module. Individual donors are shown in a light stroke, with
a highlighted module mean trajectory on top.
hc_plot_longitudinal_module_means( hc, slot_name = "longitudinal_module_means", save_pdf = TRUE, file_prefix = "Longitudinal_ModuleMeans", donor_alpha = 0.16, donor_linewidth = 0.35, mean_linewidth = 1.1, mean_point_size = 1.8, facet_ncol = 4, free_y = TRUE, square_panels = FALSE, save_width = NULL, save_height = NULL )hc_plot_longitudinal_module_means( hc, slot_name = "longitudinal_module_means", save_pdf = TRUE, file_prefix = "Longitudinal_ModuleMeans", donor_alpha = 0.16, donor_linewidth = 0.35, mean_linewidth = 1.1, mean_point_size = 1.8, facet_ncol = 4, free_y = TRUE, square_panels = FALSE, save_width = NULL, save_height = NULL )
hc |
A |
slot_name |
Satellite slot containing results from
|
save_pdf |
Logical. If |
file_prefix |
Prefix used for saved PDF file names. |
donor_alpha |
Alpha for individual donor trajectories. |
donor_linewidth |
Line width for individual donor trajectories. |
mean_linewidth |
Line width for mean trajectories. |
mean_point_size |
Point size for mean trajectory markers. |
facet_ncol |
Number of facet columns. |
free_y |
Logical. If |
square_panels |
Logical. If |
save_width, save_height
|
Optional PDF width/height in inches. If
|
A list with one ggplot object (module_means).
hc <- hc_example_data("clustered") long <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 ) hc <- long$hc p <- hc_plot_longitudinal_module_means(hc, save_pdf = FALSE)hc <- hc_example_data("clustered") long <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 ) hc <- long$hc p <- hc_plot_longitudinal_module_means(hc, save_pdf = FALSE)
Plot sample distributions (S4 API)
hc_plot_sample_distributions( hc, plot_type = "boxplot", log_2 = TRUE, plot = TRUE )hc_plot_sample_distributions( hc, plot_type = "boxplot", log_2 = TRUE, plot = TRUE )
hc |
A |
plot_type |
Either "boxplot" (default) or "freqdist" for a distribution-focused view. |
log_2 |
Logical. Log2-transform the values before plotting.
Default is |
plot |
Logical. Draw the plot. Default is |
Updated HCoCenaExperiment.
hc <- hc_example_data("prepared") hc <- hc_plot_sample_distributions(hc)hc <- hc_example_data("prepared") hc <- hc_plot_sample_distributions(hc)
Downloads and previews terms from a selected Enrichr library to help choose tissue/cell-type databases.
hc_preview_celltype_database( database, pattern = NULL, n = NULL, tissue_pattern = NULL, max_terms = 80, max_genes_per_term = 25, include_genes = TRUE )hc_preview_celltype_database( database, pattern = NULL, n = NULL, tissue_pattern = NULL, max_terms = 80, max_genes_per_term = 25, include_genes = TRUE )
database |
Enrichr library name. |
pattern |
Backward-compatible alias for |
n |
Backward-compatible alias for |
tissue_pattern |
Optional regular expression used to filter term names. |
max_terms |
Maximum number of terms to return. Default is 80. |
max_genes_per_term |
Maximum number of genes shown in |
include_genes |
Logical. If |
A data frame with terms and gene counts.
hc_preview_celltype_database("PanglaoDB")hc_preview_celltype_database("PanglaoDB")
Convenience printer for outputs from the stepwise longitudinal functions.
hc_print_longitudinal_endotypes(x, show_tables = TRUE)hc_print_longitudinal_endotypes(x, show_tables = TRUE)
x |
Output list from one of the longitudinal step functions, or a list
containing nested |
show_tables |
Logical. If |
Invisibly returns x.
hc <- hc_example_data("clustered") long <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 ) hc <- long$hc hc_print_longitudinal_endotypes(long)hc <- hc_example_data("clustered") long <- hc_longitudinal_step1_module_donor( hc, donor_col = "donor", time_col = "timepoint", time_levels = c("T1", "T2"), k = 2, nstart = 1, cap_runs = 1, impute = FALSE, seed = 1 ) hc <- long$hc hc_print_longitudinal_endotypes(long)
The function loads the count and annotation data for each layer and saves it in the hCoCena-Object's "data" slot. Genes with a variance of 0 will be automatically be excluded from the analysis.
hc_read_data( hc, sep_counts = "\t", sep_anno = "\t", gene_symbol_col = NULL, sample_col = NULL, count_has_rn = TRUE, anno_has_rn = TRUE, auto_setup_output = TRUE, create_output_dir = TRUE, project_folder = NULL )hc_read_data( hc, sep_counts = "\t", sep_anno = "\t", gene_symbol_col = NULL, sample_col = NULL, count_has_rn = TRUE, anno_has_rn = TRUE, auto_setup_output = TRUE, create_output_dir = TRUE, project_folder = NULL )
hc |
A |
sep_counts |
The separator of the count files. Default is tab separated files. Ignore when loading data from objects instead of files. |
sep_anno |
The separator of the annotation files. Default is tab separated files. Ignore when loading data from objects instead of files. |
gene_symbol_col |
A String. Name of the column that contains the gene symbols. Ignore when loading data from objects instead of files. |
sample_col |
A String. Name of the column that contains the sample IDs. Ignore when loading data from objects instead of files. |
count_has_rn |
A Boolean. Whether or not the count file has rownames. Default is TRUE. Ignore when loading data from objects instead of files. |
anno_has_rn |
A Boolean. Whether or not the annotation file has rownames. Default is TRUE. Ignore when loading data from objects instead of files. |
auto_setup_output |
Boolean. If |
create_output_dir |
Boolean passed to |
project_folder |
Optional save subfolder name. Use |
Count inputs are normalized to numeric expression matrices during
import. For object-based count inputs, non-numeric helper columns are
dropped. Genes with zero variance are removed during loading because they
can destabilize downstream variance-based heuristics such as
hc_suggest_topvar(). As a result, suggested inflection points can differ
slightly from older releases on the same raw input.
Updated HCoCenaExperiment.
extdir <- paste0( normalizePath(system.file("extdata", package = "hcocena"), winslash = "/"), "/" ) outdir <- file.path(tempdir(), "hcocena-read-data") dir.create(outdir, recursive = TRUE, showWarnings = FALSE) hc <- hc_init() hc <- hc_set_paths( hc, dir_count_data = extdir, dir_annotation = extdir, dir_reference_files = extdir, dir_output = outdir ) hc <- hc_define_layers( hc, data_sets = list( Layer1 = c("toy_layer1_counts.tsv", "toy_layer1_anno.tsv"), Layer2 = c("toy_layer2_counts.tsv", "toy_layer2_anno.tsv") ) ) hc <- hc_read_data( hc, sep_counts = "\t", sep_anno = "\t", gene_symbol_col = "SYMBOL", sample_col = "SampleID", count_has_rn = FALSE, anno_has_rn = FALSE ) names(MultiAssayExperiment::experiments(hc_mae(hc)))extdir <- paste0( normalizePath(system.file("extdata", package = "hcocena"), winslash = "/"), "/" ) outdir <- file.path(tempdir(), "hcocena-read-data") dir.create(outdir, recursive = TRUE, showWarnings = FALSE) hc <- hc_init() hc <- hc_set_paths( hc, dir_count_data = extdir, dir_annotation = extdir, dir_reference_files = extdir, dir_output = outdir ) hc <- hc_define_layers( hc, data_sets = list( Layer1 = c("toy_layer1_counts.tsv", "toy_layer1_anno.tsv"), Layer2 = c("toy_layer2_counts.tsv", "toy_layer2_anno.tsv") ) ) hc <- hc_read_data( hc, sep_counts = "\t", sep_anno = "\t", gene_symbol_col = "SYMBOL", sample_col = "SampleID", count_has_rn = FALSE, anno_has_rn = FALSE ) names(MultiAssayExperiment::experiments(hc_mae(hc)))
Function to read and collect the supplementary files set in set_supp_files().
hc_read_supplementary(hc)hc_read_supplementary(hc)
hc |
A |
Updated HCoCenaExperiment.
refdir <- file.path(tempdir(), "hcocena-reference-files") dir.create(refdir, recursive = TRUE, showWarnings = FALSE) writeLines("ToySet\\tdescription\\tG1\\tG2", file.path(refdir, "hallmark.gmt")) hc <- hc_init() hc <- hc_set_paths( hc, dir_count_data = FALSE, dir_annotation = FALSE, dir_reference_files = paste0(normalizePath(refdir, winslash = "/"), "/"), dir_output = tempdir() ) hc <- hc_set_supp_files(hc, Hallmark = "hallmark.gmt") hc <- hc_read_supplementary(hc) names(hcocena:::as_hcobject(hc)$supplementary_data)refdir <- file.path(tempdir(), "hcocena-reference-files") dir.create(refdir, recursive = TRUE, showWarnings = FALSE) writeLines("ToySet\\tdescription\\tG1\\tG2", file.path(refdir, "hallmark.gmt")) hc <- hc_init() hc <- hc_set_paths( hc, dir_count_data = FALSE, dir_annotation = FALSE, dir_reference_files = paste0(normalizePath(refdir, winslash = "/"), "/"), dir_output = tempdir() ) hc <- hc_set_supp_files(hc, Hallmark = "hallmark.gmt") hc <- hc_read_supplementary(hc) names(hcocena:::as_hcobject(hc)$supplementary_data)
Builds a module-by-sample fold-change matrix for one or more layers, clusters
samples hierarchically, and cuts each dendrogram into k groups. By default,
this is a non-destructive preview: the input object, its variable of interest,
module assignments, and annotation files are not changed.
hc_regroup_samples( hc, layer = "all", modules = "all", k = 2, reference = c("mean", "control"), method = "complete", distance = "euclidean", group_col = "hc_regroup", apply = FALSE, overwrite = FALSE, show_values = FALSE, silent = !base::interactive() )hc_regroup_samples( hc, layer = "all", modules = "all", k = 2, reference = c("mean", "control"), method = "complete", distance = "euclidean", group_col = "hc_regroup", apply = FALSE, overwrite = FALSE, show_values = FALSE, silent = !base::interactive() )
hc |
A |
layer |
Layer selection. Use |
modules |
Modules used as clustering features. Use |
k |
Number of sample groups after cutting the dendrogram. Supply one integer for all selected layers or one integer per selected layer. Named vectors may use layer ids or configured layer names. |
reference |
Reference used for sample-level fold changes. |
method |
Hierarchical clustering method passed to |
distance |
Distance used between samples. Supports methods accepted by
|
group_col |
Name of the new annotation column created when
|
apply |
Logical. If |
overwrite |
Logical. Allow an existing |
show_values |
Logical. Display rounded fold-change values in heatmap cells. |
silent |
Logical. If |
Fold changes are calculated for every gene in every sample relative to either
that gene's mean across the layer or its mean in the configured control
samples. Gene-level values are then averaged within the current modules. This
follows the signed-ratio convention used by hCoCena: two-fold down is -2, no
change is 1, and two-fold up is 2.
A list with hc, per-layer results, plots, parameters, and
applied. Each layer result contains sample_gfc, module_table,
distance, tree, clusters, and plot.
hc <- hc_example_data("clustered") preview <- hc_regroup_samples(hc, layer = 1, k = 2, silent = TRUE) preview$results$set1$clusters preview$results$set1$sample_gfc applied <- hc_regroup_samples( hc, layer = "all", k = 2, group_col = "module_profile_group", apply = TRUE, silent = TRUE ) hc <- applied$hchc <- hc_example_data("clustered") preview <- hc_regroup_samples(hc, layer = 1, k = 2, silent = TRUE) preview$results$set1$clusters preview$results$set1$sample_gfc applied <- hc_regroup_samples( hc, layer = "all", k = 2, group_col = "module_profile_group", apply = TRUE, silent = TRUE ) hc <- applied$hc
Resolve hCoCena input/output directories for Docker or local projects
hc_resolve_paths( project_root_hint = NULL, local_count_subdir = "count_data", local_annotation_subdir = "annotation_data", local_reference_subdir = "reference_files", local_output_subdir = "output", docker_reference_dir = "/home/rstudio/reference_files", docker_count_dir = "/home/rstudio/count_data", docker_annotation_dir = "/home/rstudio/annotation_data", docker_output_dir = "/home/rstudio/output", create_docker_dirs = TRUE, fallback_count_data = "PATH_TO_FOLDER_THAT_HOLDS_YOUR_GENE_EXPRESSION_TABLES/", fallback_annotation = "PATH_TO_FOLDER_THAT_HOLDS_YOUR_ANNOTATION_TABLES/", fallback_reference_files = "PATH_TO_REFERENCE_FILES_FOLDER/", fallback_output = "PATH_TO_FOLDER_WHERE_HCOCENA_SHOULD_SAVE_ALL_ANALYSIS_OUTPUTS/" )hc_resolve_paths( project_root_hint = NULL, local_count_subdir = "count_data", local_annotation_subdir = "annotation_data", local_reference_subdir = "reference_files", local_output_subdir = "output", docker_reference_dir = "/home/rstudio/reference_files", docker_count_dir = "/home/rstudio/count_data", docker_annotation_dir = "/home/rstudio/annotation_data", docker_output_dir = "/home/rstudio/output", create_docker_dirs = TRUE, fallback_count_data = "PATH_TO_FOLDER_THAT_HOLDS_YOUR_GENE_EXPRESSION_TABLES/", fallback_annotation = "PATH_TO_FOLDER_THAT_HOLDS_YOUR_ANNOTATION_TABLES/", fallback_reference_files = "PATH_TO_REFERENCE_FILES_FOLDER/", fallback_output = "PATH_TO_FOLDER_WHERE_HCOCENA_SHOULD_SAVE_ALL_ANALYSIS_OUTPUTS/" )
project_root_hint |
Optional local project root to prioritize if it exists. If missing or not found, the current working directory is used. |
local_count_subdir |
Local count-data subfolder below |
local_annotation_subdir |
Local annotation-data subfolder below |
local_reference_subdir |
Local reference-files subfolder below |
local_output_subdir |
Local output subfolder below |
docker_reference_dir |
Docker reference-files directory used to detect Docker mode. |
docker_count_dir |
Docker count-data directory. |
docker_annotation_dir |
Docker annotation-data directory. |
docker_output_dir |
Docker output directory. |
create_docker_dirs |
Boolean. If TRUE and Docker mode is detected, create the Docker directories when missing. |
fallback_count_data |
Fallback count-data directory string used outside Docker when no local folder was detected. |
fallback_annotation |
Fallback annotation directory string used outside Docker when no local folder was detected. |
fallback_reference_files |
Fallback reference-files directory string used outside Docker when no local folder was detected. |
fallback_output |
Fallback output directory string used outside Docker when no local folder was detected. |
Named list with docker_mode, project_root, dir_count_data,
dir_annotation, dir_reference_files, and dir_output.
root <- file.path(tempdir(), "hcocena-paths") dir.create(file.path(root, "reference_files"), recursive = TRUE, showWarnings = FALSE) dir.create(file.path(root, "output"), recursive = TRUE, showWarnings = FALSE) paths <- hc_resolve_paths( project_root_hint = root, local_count_subdir = NULL, local_annotation_subdir = NULL ) names(paths)root <- file.path(tempdir(), "hcocena-paths") dir.create(file.path(root, "reference_files"), recursive = TRUE, showWarnings = FALSE) dir.create(file.path(root, "output"), recursive = TRUE, showWarnings = FALSE) paths <- hc_resolve_paths( project_root_hint = root, local_count_subdir = NULL, local_annotation_subdir = NULL ) names(paths)
This function executes the frist part of the data processing procedure. It leads up to choosing the correlation cut-off for each layer. All datasets will be filtered for their most variant genes as defined in the layer-specific settings. After this filtering step, the pair-wise correlation coefficients for all pairs of genes are calculated. Correlations that are negative or that have an associated p-value higher than 0.05 are immediately discarded. Next, a set of statistics will be calculated for the set range of cut-off values that aim to facilitate the cut-off choice. This includes determining the number of graph components resulting from creating a network when cutting the data with the respective cut-off, as well as the number of nodes and edges this network comprises. The last parameter that is evaluated is the R^2-value of the data to a linear regression through the logged degree distribution for the given network.
hc_run_expression_analysis_1( hc, padj = "none", export = FALSE, import = NULL, bayes = FALSE, prior = 2, alpha = 0.5, corr_method = "pearson", corr_backend = "auto" )hc_run_expression_analysis_1( hc, padj = "none", export = FALSE, import = NULL, bayes = FALSE, prior = 2, alpha = 0.5, corr_method = "pearson", corr_backend = "auto" )
hc |
A |
padj |
A String. Defines the method to be used for p-value adjustment. Valid values are "none" (default) or values for "method" in stats::p.adjust. |
export |
A Boolean. If TRUE, correlation values and p-values will be exported. This can save time if you plan on re-running the analysis since computing pari-wise correlations is a bottleneck of the analysis. Default is FALSE. |
import |
A list. Each slot in the list corresponds to one of the layers (datasets) and is either a vector of two strings (1. path to file holding the correlation matrix and 2. Path to the file holding the p-value matrix) or NA. A list slot is set to NA if for that layer you do not want to import a pre-calculated correlation matrix. The files do not necessarily have to be exported from a previous run, but can have any kind of origin (created with a different program or method). For compatibility it is only important, that it is a whitespace-separated text (.txt) file containing a symmetric, numeric matrix. The first line has to be gene names, there must be no row names, since the first line will be used for column names and row names. Also, you must provide a matrix with correlation values AND a matrix with corresponding p-values, where cells in the matrices correspond to each other (only a correlation matrix will not be sufficient). Default is NULL. |
bayes |
Sanchez-Taltavull et al. (2016) suggest superiority of Bayesian correlation analysis to Pearson correlation in some cases. Therefore, the Pearson correlation values can be weighted with Bayesian correlation values. To do so, set the "bayes"-parameter to TRUE. Default is FALSE, using only Pearson correlations. |
prior |
An integer, either 2 or 3, using prior 2 or 3 for the Bayes weighting as described in "Bayesian correlation analysis for sequence count data" by Sanchez-Taltavull et al. (2016). |
alpha |
A numeric value from 0 to 1. Allows to adjust the strength of the Bayes weighting: For alpha = 0 the Pearson correlation values remain unaltered, for alpha = 1 the Pearson correlation value and the Bayesian correlation value contribute equally to the final correlation. |
corr_method |
Correlation method to use. Supported values are "pearson" (default) and "spearman". |
corr_backend |
Correlation backend. |
Updated HCoCenaExperiment.
hc <- hc_example_data("prepared") hc <- hc_run_expression_analysis_1(hc)hc <- hc_example_data("prepared") hc <- hc_run_expression_analysis_1(hc)
This function plots a heatmap for the network genes in each data layer and computes the Group-Fold-Changes for all genes per layer.
hc_run_expression_analysis_2( hc, grouping_v = NULL, plot_HM = TRUE, method = "complete", additional_anno = NULL, cols = NULL )hc_run_expression_analysis_2( hc, grouping_v = NULL, plot_HM = TRUE, method = "complete", additional_anno = NULL, cols = NULL )
hc |
A |
grouping_v |
A string giving a column name present in all annotation files, if this variable shall be used for grouping the samles isntead of the variable of interest. Default is NULL. |
plot_HM |
A Boolean. Whether or not to plot the heatmap (for networks with many genes this may be very demanding for your computer if you are running the analysis locally). Default is TRUE. |
method |
The method used for clustering the heatmap in the pheatmap function. Default is "complete". |
additional_anno |
A list, with one slot per data set. A slot contains a vector of column names from that data set's annotation file that you wish to annotate with. If for some of the data sets you don't wish any further annotation, you can set the corresponding list slot to NULL. Default is NULL. |
cols |
A named list of color vectors. The list names need to match the chosen annotation column names. Default is NULL which uses implemented colors. |
Updated HCoCenaExperiment.
hc <- hc_example_data("after_part1") hc <- hc_run_expression_analysis_2(hc, plot_HM = FALSE)hc <- hc_example_data("after_part1") hc <- hc_run_expression_analysis_2(hc, plot_HM = FALSE)
HCoCenaExperiment
Downstream steps (module gene lists, enrichments, hub genes, module
statistics, ...) store their results in a named list inside the object.
hc_satellite() returns that list, or a single entry of it.
hc_satellite(x, name = NULL) ## S4 method for signature 'HCoCenaExperiment' hc_satellite(x, name = NULL)hc_satellite(x, name = NULL) ## S4 method for signature 'HCoCenaExperiment' hc_satellite(x, name = NULL)
x |
An |
name |
Optional name of a single entry. If |
A S4Vectors::SimpleList of stored results, or the entry name
(NULL if that entry does not exist).
hc <- hc_example_data("clustered") names(hc_satellite(hc))hc <- hc_example_data("clustered") names(hc_satellite(hc))
Set network cutoffs (S4 API)
hc_set_cutoff( hc, cutoff_vector = base::c(), auto = FALSE, fallback_cutoff = 0.982, verbose = TRUE )hc_set_cutoff( hc, cutoff_vector = base::c(), auto = FALSE, fallback_cutoff = 0.982, verbose = TRUE )
hc |
A |
cutoff_vector |
A vector of correlation cutoff values, one per layer,
in the order the layers were declared in |
auto |
Logical; if
|
fallback_cutoff |
Numeric fallback cutoff used for still-missing layers
(for both |
verbose |
Logical; print additional source details. The final applied cutoff vector is always printed. |
Updated HCoCenaExperiment.
hc <- hc_example_data("after_part1") hc <- hc_set_cutoff(hc, cutoff_vector = c(0.3, 0.3))hc <- hc_example_data("after_part1") hc <- hc_set_cutoff(hc, cutoff_vector = c(0.3, 0.3))
Receives all settings that are globally valid, i.e., that are not dataset specific.
hc_set_global_settings( hc, organism = "human", control_keyword = "none", variable_of_interest = "merged", min_nodes_number_for_network = 50, min_nodes_number_for_cluster = 50, range_GFC = 2, layout_algorithm = "layout_with_stress", data_in_log = TRUE )hc_set_global_settings( hc, organism = "human", control_keyword = "none", variable_of_interest = "merged", min_nodes_number_for_network = 50, min_nodes_number_for_cluster = 50, range_GFC = 2, layout_algorithm = "layout_with_stress", data_in_log = TRUE )
hc |
A |
organism |
Specification of the organism needed for all TF-related analyses. Set to "human" for human data and "mouse" for mouse data. Currently, hCoCena only supports human and mouse data, however, all analysis steps not related to TFs can be applied to other organisms. |
control_keyword |
Either 'none' if no controls are present (only possible when analysing one single dataset) or a string contained in the control sample descriptor of all annotation files, e.g. "healthy". The string must only be contained in the descriptor, e.g. "healthy" would work for "rhinovirusSetHealthy" and "influenzaSetHealthy", it does not have to match it perfectly. |
variable_of_interest |
The name of the column that mus be rpesent in all annotation files and which will be used for grouping samples, e.g., "condition"". |
min_nodes_number_for_network |
An integer. The minimum number of nodes in the subsequently created network that can define a graph component. Graph components with less nodes will be discarded. Default is 50. |
min_nodes_number_for_cluster |
An integer. The minimum number of nodes that constitute a module/cluster when detecting community structures in the network. Default is 50. |
range_GFC |
A float. Defines the maximum value the group fold changes (GFCs) can acquire, all values above this value or beneath its negative will be truncated. Default is 2.0. |
layout_algorithm |
Layout algorithm used for the network. Supported values are:
|
data_in_log |
Boolean. Whether or not the provided gene expression data is logged to the base of 2. |
Updated HCoCenaExperiment.
extdir <- paste0( normalizePath(system.file("extdata", package = "hcocena"), winslash = "/"), "/" ) outdir <- file.path(tempdir(), "hcocena-global-settings") dir.create(outdir, recursive = TRUE, showWarnings = FALSE) hc <- hc_init() hc <- hc_set_paths( hc, dir_count_data = extdir, dir_annotation = extdir, dir_reference_files = extdir, dir_output = outdir ) hc <- hc_define_layers( hc, data_sets = list( Layer1 = c("toy_layer1_counts.tsv", "toy_layer1_anno.tsv"), Layer2 = c("toy_layer2_counts.tsv", "toy_layer2_anno.tsv") ) ) hc <- hc_read_data( hc, sep_counts = "\t", sep_anno = "\t", gene_symbol_col = "SYMBOL", sample_col = "SampleID", count_has_rn = FALSE, anno_has_rn = FALSE ) hc <- hc_set_global_settings( hc, organism = "human", control_keyword = "control", variable_of_interest = "group", data_in_log = TRUE ) as.data.frame(methods::slot(hc_config(hc), "global"))extdir <- paste0( normalizePath(system.file("extdata", package = "hcocena"), winslash = "/"), "/" ) outdir <- file.path(tempdir(), "hcocena-global-settings") dir.create(outdir, recursive = TRUE, showWarnings = FALSE) hc <- hc_init() hc <- hc_set_paths( hc, dir_count_data = extdir, dir_annotation = extdir, dir_reference_files = extdir, dir_output = outdir ) hc <- hc_define_layers( hc, data_sets = list( Layer1 = c("toy_layer1_counts.tsv", "toy_layer1_anno.tsv"), Layer2 = c("toy_layer2_counts.tsv", "toy_layer2_anno.tsv") ) ) hc <- hc_read_data( hc, sep_counts = "\t", sep_anno = "\t", gene_symbol_col = "SYMBOL", sample_col = "SampleID", count_has_rn = FALSE, anno_has_rn = FALSE ) hc <- hc_set_global_settings( hc, organism = "human", control_keyword = "control", variable_of_interest = "group", data_in_log = TRUE ) as.data.frame(methods::slot(hc_config(hc), "global"))
Receives all settings that are dataset specific and not globally valid.
hc_set_layer_settings( hc, top_var, min_corr = 0.7, range_cutoff_length, print_distribution_plots = FALSE )hc_set_layer_settings( hc, top_var, min_corr = 0.7, range_cutoff_length, print_distribution_plots = FALSE )
hc |
A |
top_var |
A vector with the length equal to the number of datasets/layers. Each entry of the vector is either "all" or an integer. Defines the number of most variable genes to be extracted per dataset. The order in the vector corresponds to the order in which the datasets have been declared in define_layers(). |
min_corr |
A vector of floats with the length equal to the number of datasets/layers. To construct a meaningful co-expression network for each layer, correlation cut-offs must be determined for every dataset that mark the lower boundary for the correlation of two genes in order for their co-expression to be represented as an edge in the network. To facilitate choosing these cut-offs, a series of parameters will be calculated for a defined number of different cut-offs. The number of cut-offs for which these parameters are calculated is determined by 'range_cutoff_length'. The range from which these possible cut-offs are taken is on the lower end restricted by 'min_corr' and on the upper end by the maximum correlation calculated between any two genes in the dataset. Default is 0.7. |
range_cutoff_length |
A vector of integers with the length equal to the number of datasets/layers. Details see "min_corr". |
print_distribution_plots |
A vector of Booleans with the length equal to the number of datasets/layers. Whether or not to print the degree distribution plots for all tested cut-offs to pdf files. The number of plots per data set will therefore be equal to the 'range_cutoff_length' parameter you have set. Given the potential size, this should only be set to TRUE, if 'range_cutoff_length' is small or if one wishes to thoroughly analyse how the degree distribution changes in detail for differing cut-offs. Default is FALSE. |
Updated HCoCenaExperiment.
extdir <- paste0( normalizePath(system.file("extdata", package = "hcocena"), winslash = "/"), "/" ) outdir <- file.path(tempdir(), "hcocena-layer-settings") dir.create(outdir, recursive = TRUE, showWarnings = FALSE) hc <- hc_init() hc <- hc_set_paths( hc, dir_count_data = extdir, dir_annotation = extdir, dir_reference_files = extdir, dir_output = outdir ) hc <- hc_define_layers( hc, data_sets = list( Layer1 = c("toy_layer1_counts.tsv", "toy_layer1_anno.tsv"), Layer2 = c("toy_layer2_counts.tsv", "toy_layer2_anno.tsv") ) ) hc <- hc_read_data( hc, sep_counts = "\t", sep_anno = "\t", gene_symbol_col = "SYMBOL", sample_col = "SampleID", count_has_rn = FALSE, anno_has_rn = FALSE ) hc <- hc_set_layer_settings( hc, top_var = c(2, 2), min_corr = 0.1, range_cutoff_length = c(2, 2), print_distribution_plots = FALSE ) as.data.frame(methods::slot(hc_config(hc), "layer"))extdir <- paste0( normalizePath(system.file("extdata", package = "hcocena"), winslash = "/"), "/" ) outdir <- file.path(tempdir(), "hcocena-layer-settings") dir.create(outdir, recursive = TRUE, showWarnings = FALSE) hc <- hc_init() hc <- hc_set_paths( hc, dir_count_data = extdir, dir_annotation = extdir, dir_reference_files = extdir, dir_output = outdir ) hc <- hc_define_layers( hc, data_sets = list( Layer1 = c("toy_layer1_counts.tsv", "toy_layer1_anno.tsv"), Layer2 = c("toy_layer2_counts.tsv", "toy_layer2_anno.tsv") ) ) hc <- hc_read_data( hc, sep_counts = "\t", sep_anno = "\t", gene_symbol_col = "SYMBOL", sample_col = "SampleID", count_has_rn = FALSE, anno_has_rn = FALSE ) hc <- hc_set_layer_settings( hc, top_var = c(2, 2), min_corr = 0.1, range_cutoff_length = c(2, 2), print_distribution_plots = FALSE ) as.data.frame(methods::slot(hc_config(hc), "layer"))
HCoCenaExperiment
Set input/output paths in an HCoCenaExperiment
hc_set_paths( hc, dir_count_data, dir_annotation, dir_reference_files, dir_output )hc_set_paths( hc, dir_count_data, dir_annotation, dir_reference_files, dir_output )
hc |
A |
dir_count_data |
Path to count data. |
dir_annotation |
Path to annotation data. |
dir_reference_files |
Path to reference files. |
dir_output |
Output directory. |
Updated HCoCenaExperiment.
hc <- hc_init() hc <- hc_set_paths( hc, dir_count_data = FALSE, dir_annotation = FALSE, dir_reference_files = tempdir(), dir_output = tempdir() ) as.data.frame(methods::slot(hc_config(hc), "paths"))hc <- hc_init() hc <- hc_set_paths( hc, dir_count_data = FALSE, dir_annotation = FALSE, dir_reference_files = tempdir(), dir_output = tempdir() ) as.data.frame(methods::slot(hc_config(hc), "paths"))
Receives the file names of the supplementary files
hc_set_supp_files( hc, Tf = NULL, Hallmark = NULL, Go = NULL, Kegg = NULL, Reactome = NULL, ... )hc_set_supp_files( hc, Tf = NULL, Hallmark = NULL, Go = NULL, Kegg = NULL, Reactome = NULL, ... )
hc |
A |
Tf |
A file name. The file must contain a list of at least two columns. One column should be titled with the organism from which the datasets originate and contain gene names, the other column must always be the last column and contain the information if the gene is a transcription factor ("TF"), a co-factor ("Co_factor"), a chromatin remodelling protein ("Chromatin_remodeller") or a ribonucleic acid binding protein ("RNBP"). The name of the last column may vary. An exmemplary file for mouse and human is found in the Reference Files Folder in the repository. |
Hallmark |
A file name for a .gmt MSigDB hallmark gene set file. You can find one in the reference file folder in the repository. |
Go |
A file name for a .gmt gene ontology file. You can find one in the reference file folder in the repository. |
Kegg |
A file name for a .gmt KEGG database file. You can find one in the reference file folder in the repository. |
Reactome |
A file name for a .gmt Reactomte database file. You can find one in the reference file folder in the repository. |
... |
Additional supplementary files passed through to |
Updated HCoCenaExperiment.
hc <- hc_init() hc <- hc_set_supp_files( hc, Hallmark = "hallmark.gmt", Go = "go.gmt" ) sort(names(hcocena:::as_hcobject(hc)$supplement))hc <- hc_init() hc <- hc_set_supp_files( hc, Hallmark = "hallmark.gmt", Go = "go.gmt" ) sort(names(hcocena:::as_hcobject(hc)$supplement))
Re-clusters genes within selected modules and replaces those modules by submodules (with color shades of the parent module).
hc_split_modules( hc, modules, cluster_algo = "cluster_leiden", no_of_iterations = 2, resolution = 0.1, resolution_grid = NULL, resolution_test_only = FALSE, partition_type = "RBConfigurationVertexPartition", seed = 168575, drop_small_submodules = TRUE, min_submodule_size = NULL, min_module_size = NULL, verbose = TRUE )hc_split_modules( hc, modules, cluster_algo = "cluster_leiden", no_of_iterations = 2, resolution = 0.1, resolution_grid = NULL, resolution_test_only = FALSE, partition_type = "RBConfigurationVertexPartition", seed = 168575, drop_small_submodules = TRUE, min_submodule_size = NULL, min_module_size = NULL, verbose = TRUE )
hc |
A |
modules |
Character/numeric vector of modules to split. Accepts module
labels (e.g. |
cluster_algo |
Clustering algorithm for within-module splitting.
One of |
no_of_iterations |
Number of Leiden iterations (used only for Leiden). |
resolution |
Leiden resolution (used only for Leiden). Use either one
positive value for all selected modules or one positive value per selected
module in the same order as |
resolution_grid |
Optional numeric vector of candidate resolutions to test before splitting. For each candidate, hCoCena reports how many submodules would be retained after size filtering. |
resolution_test_only |
Logical; if |
partition_type |
Leiden partition type (used only for Leiden). |
seed |
Random seed used for deterministic clustering. |
drop_small_submodules |
Logical; if |
min_submodule_size |
Optional minimum size for retained split
submodules. If |
min_module_size |
Optional alias for |
verbose |
Logical; print progress messages. |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_plot_cluster_heatmap(hc, file_name = FALSE) hc <- hc_split_modules(hc, modules = "M1", resolution = 1)hc <- hc_example_data("clustered") hc <- hc_plot_cluster_heatmap(hc, file_name = FALSE) hc <- hc_split_modules(hc, modules = "M1", resolution = 1)
Suggest top variable genes (S4 API)
hc_suggest_topvar(hc)hc_suggest_topvar(hc)
hc |
A |
hc_suggest_topvar() operates on the counts stored in hc, i.e.
after hc_read_data() preprocessing. Because hc_read_data() removes
zero-variance genes and drops non-numeric helper columns from object-based
count inputs, suggested inflection points can differ slightly from older
releases on the same raw input even though the hc_suggest_topvar()
heuristic itself is unchanged.
Updated HCoCenaExperiment.
hc <- hc_example_data("prepared") hc <- hc_suggest_topvar(hc)hc <- hc_example_data("prepared") hc <- hc_suggest_topvar(hc)
TF enrichment per module (S4 API)
hc_tf_overrep_module(hc, clusters = "all", topTF = 5, topTarget = 5)hc_tf_overrep_module(hc, clusters = "all", topTF = 5, topTarget = 5)
hc |
A |
clusters |
Either "all" (default) or a vector of module colours/labels for which the TF enrichment should be performed. |
topTF |
Integer. Number of top ranking transcription factors to return per module. Default is 5. |
topTarget |
Integer. Number of top ranking targets to return per transcription factor. Default is 5. |
Updated HCoCenaExperiment.
# Queries the ChEA3 web service. hc <- hc_example_data("clustered") hc <- hc_tf_overrep_module(hc, topTF = 3, topTarget = 3)# Queries the ChEA3 web service. hc <- hc_example_data("clustered") hc <- hc_tf_overrep_module(hc, topTF = 3, topTarget = 3)
TF enrichment network-wide (S4 API)
hc_tf_overrep_network(hc, topTF = 100, topTarget = 30)hc_tf_overrep_network(hc, topTF = 100, topTarget = 30)
hc |
A |
topTF |
Integer. Number of transcription factors with the highest number of enriched targets network-wide. Default is 100. |
topTarget |
Integer. Number of top enriched targets to return per transcription factor. Default is 30. |
Updated HCoCenaExperiment.
# Queries the ChEA3 web service. hc <- hc_example_data("clustered") hc <- hc_tf_overrep_network(hc, topTF = 10, topTarget = 5) names(hc_satellite(hc, "tf_network_targets"))# Queries the ChEA3 web service. hc <- hc_example_data("clustered") hc <- hc_tf_overrep_network(hc, topTF = 10, topTarget = 5) names(hc_satellite(hc, "tf_network_targets"))
Short-name wrapper around hc_auto_tune_cutoff_tiered() for daily use.
The report is stored in hc@satellite$cutoff_tuning.
hc_tune_cutoff( hc, apply = FALSE, tier1_sft_min = 0.85, tier1_mean_k_min = 10, tier2_sft_min = 0.8, tier2_mean_k_min = 5, fallback_sft_min = 0.7, require_negative_slope = TRUE, max_no_networks = NULL, max_components = NULL, min_node_fraction = NULL, fallback_respect_base_filters = TRUE, verbose = TRUE )hc_tune_cutoff( hc, apply = FALSE, tier1_sft_min = 0.85, tier1_mean_k_min = 10, tier2_sft_min = 0.8, tier2_mean_k_min = 5, fallback_sft_min = 0.7, require_negative_slope = TRUE, max_no_networks = NULL, max_components = NULL, min_node_fraction = NULL, fallback_respect_base_filters = TRUE, verbose = TRUE )
hc |
A |
apply |
Logical; if |
tier1_sft_min |
Numeric minimum SFT fit ( |
tier1_mean_k_min |
Numeric minimum mean connectivity ( |
tier2_sft_min |
Numeric minimum SFT fit ( |
tier2_mean_k_min |
Numeric minimum mean connectivity ( |
fallback_sft_min |
Numeric lower bound for |
require_negative_slope |
Logical; require a negative slope ( |
max_no_networks |
Optional numeric scalar. If set, only cutoffs with
|
max_components |
Deprecated alias for |
min_node_fraction |
Optional numeric in |
fallback_respect_base_filters |
Logical; if |
verbose |
Logical; print per-layer recommendation messages. |
Key tuning knobs:
tier1_sft_min, tier1_mean_k_min: strict-tier thresholds.
tier2_sft_min, tier2_mean_k_min: relaxed-tier thresholds.
fallback_sft_min: minimum fit for best_available selection.
require_negative_slope: enforce negative slope in tier filters.
max_no_networks: optional upper bound for connected-component count.
min_node_fraction: optional retained-node requirement relative to best
available node count across tested cutoffs.
fallback_respect_base_filters: whether best_available must respect the same
base filters (slope/components/nodes).
Updated HCoCenaExperiment.
hc <- hc_example_data("after_part1") hc <- hc_tune_cutoff(hc, apply = FALSE, verbose = FALSE)hc <- hc_example_data("after_part1") hc <- hc_tune_cutoff(hc, apply = FALSE, verbose = FALSE)
Convenience wrapper for clustering-focused auto-tuning.
Internally this calls hc_auto_tune(..., tune_cutoff = FALSE, tune_clustering = TRUE).
The clustering report is additionally mirrored to hc@satellite$resolution_tuning.
hc_tune_resolution( hc, apply = FALSE, cluster_algorithms = c("cluster_leiden", "cluster_louvain"), resolution_grid = base::seq(0.05, 0.5, by = 0.05), no_of_iterations = 2, partition_type = "RBConfigurationVertexPartition", max_cluster_count_per_gene = 1, module_count_bounds = c(3, 60), prefer_resolution = 0.1, verbose = TRUE )hc_tune_resolution( hc, apply = FALSE, cluster_algorithms = c("cluster_leiden", "cluster_louvain"), resolution_grid = base::seq(0.05, 0.5, by = 0.05), no_of_iterations = 2, partition_type = "RBConfigurationVertexPartition", max_cluster_count_per_gene = 1, module_count_bounds = c(3, 60), prefer_resolution = 0.1, verbose = TRUE )
hc |
A |
apply |
Logical; if |
cluster_algorithms |
Character vector of candidate algorithms. |
resolution_grid |
Numeric vector of Leiden resolutions. |
no_of_iterations |
Passed to clustering. |
partition_type |
Passed to clustering.
For Leiden, resolution sweeps are only informative with
|
max_cluster_count_per_gene |
Passed to clustering. |
module_count_bounds |
Optional length-2 numeric vector
( |
prefer_resolution |
Tie-break preference for resolution. |
verbose |
Logical; print progress messages. |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_tune_resolution(hc, apply = FALSE)hc <- hc_example_data("clustered") hc <- hc_tune_resolution(hc, apply = FALSE)
Restores module structure from split history.
hc_unsplit_modules(hc, which = c("last", "all"), verbose = TRUE)hc_unsplit_modules(hc, which = c("last", "all"), verbose = TRUE)
hc |
A |
which |
Either |
verbose |
Logical; print progress messages. |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_plot_cluster_heatmap(hc, file_name = FALSE) hc <- hc_split_modules(hc, modules = "M1", resolution = 1) hc <- hc_unsplit_modules(hc, which = "all")hc <- hc_example_data("clustered") hc <- hc_plot_cluster_heatmap(hc, file_name = FALSE) hc <- hc_split_modules(hc, modules = "M1", resolution = 1) hc <- hc_unsplit_modules(hc, which = "all")
Update clustering algorithm (S4 API)
hc_update_clustering_algorithm(hc, new_algo = NULL, gtc = NULL)hc_update_clustering_algorithm(hc, new_algo = NULL, gtc = NULL)
hc |
A |
new_algo |
Name of the clustering algorithm to switch to, e.g.
|
gtc |
Optional externally supplied gene-to-cluster table to adopt instead of re-running an algorithm. |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_update_clustering_algorithm(hc, new_algo = "cluster_louvain")hc <- hc_example_data("clustered") hc <- hc_update_clustering_algorithm(hc, new_algo = "cluster_louvain")
Links each module to transcription factors and signalling pathways whose target genes are over-represented among the module genes.
hc_upstream_inference( hc, resources = c("TF", "Pathway"), top = 5, clusters = c("all"), padj = "BH", qval = 0.05, tf_resource = "auto", tf_confidence = c("A", "B", "C"), progeny_top = 100, minsize = 5, min_overlap = 3, collapse_redundant = TRUE, redundancy_jaccard = 0.5, method = "ora", activity_input = "gfc", fc_comparisons = NULL, custom_pathway_gmt = NULL, heatmap_side = "left", cluster_columns = FALSE, heatmap_cluster_columns = NULL, col_order = NULL, heatmap_col_order = NULL, gfc_scale_limits = NULL, plot = TRUE, save_pdf = TRUE, pdf_width = NULL, pdf_height = NULL, pdf_pointsize = 11, plot_per_comparison = TRUE, consistent_terms = TRUE, overall_plot_scale = 1 )hc_upstream_inference( hc, resources = c("TF", "Pathway"), top = 5, clusters = c("all"), padj = "BH", qval = 0.05, tf_resource = "auto", tf_confidence = c("A", "B", "C"), progeny_top = 100, minsize = 5, min_overlap = 3, collapse_redundant = TRUE, redundancy_jaccard = 0.5, method = "ora", activity_input = "gfc", fc_comparisons = NULL, custom_pathway_gmt = NULL, heatmap_side = "left", cluster_columns = FALSE, heatmap_cluster_columns = NULL, col_order = NULL, heatmap_col_order = NULL, gfc_scale_limits = NULL, plot = TRUE, save_pdf = TRUE, pdf_width = NULL, pdf_height = NULL, pdf_pointsize = 11, plot_per_comparison = TRUE, consistent_terms = TRUE, overall_plot_scale = 1 )
hc |
A |
resources |
Character vector of upstream resources to use.
Allowed values are |
top |
Integer. Number of top significant regulators/pathways to keep per module and resource in the selected summary. Default is 5. |
clusters |
Either |
padj |
Multiple-testing correction method passed to
|
qval |
Adjusted p-value threshold for significance. Default is 0.05. |
tf_resource |
TF regulon resource: |
tf_confidence |
Character vector of DoRothEA confidence levels to keep
(DoRothEA only). Default is |
progeny_top |
Number of most responsive genes per PROGENy pathway (smallest p-value in the PROGENy model). Default is 100. |
minsize |
Minimum number of targets among the network genes a regulator needs to be tested; also the minimum module size. Default is 5. |
min_overlap |
Minimum number of a regulator's targets in a module for the link to count as significant. Default is 3. |
collapse_redundant |
Logical. If |
redundancy_jaccard |
Jaccard index of the module targets from which a regulator counts as redundant. Default is 0.5. |
method |
Test that links modules and regulators. Only |
activity_input |
Character scalar selecting the values used for the
signed score per condition:
|
fc_comparisons |
Character vector of pairwise comparisons used only when
|
custom_pathway_gmt |
Optional custom pathway GMT file(s) added to the
pathway inference resource. Accepts a character vector or named list of
file paths. Paths can be absolute/relative or file names inside
|
heatmap_side |
Position of the hCoCena heatmap in the combined output.
Choose one of |
cluster_columns |
Logical. If |
heatmap_cluster_columns |
Legacy alias for |
col_order |
Optional character vector overriding the hCoCena
heatmap column order for this upstream plot only. If |
heatmap_col_order |
Legacy alias for |
gfc_scale_limits |
Optional numeric vector controlling the module-heatmap
color scale limits used in upstream combined heatmaps (left/right hCoCena
panel). Provide one positive number ( |
plot |
Logical; if |
save_pdf |
Logical; if |
pdf_width |
Optional numeric width (inches) for |
pdf_height |
Optional numeric height (inches) for |
pdf_pointsize |
Numeric base pointsize used for the upstream PDF device. Default is 11. |
plot_per_comparison |
Logical; if |
consistent_terms |
Logical; controls term comparability when
|
overall_plot_scale |
Numeric scaling factor for plot typography and marker sizes. Default is 1. |
For every module and regulator, a hypergeometric test compares the
regulator's targets in the module with its targets among all network genes
(the genes that could have landed in a module). P-values are adjusted over
all module x regulator tests of a resource. TF regulons come from CollecTRI
(or DoRothEA), pathway-responsive genes from PROGENy (top progeny_top
genes per pathway) and optional custom GMT files.
A link is significant when its adjusted p-value (qvalue) is at most
qval and at least min_overlap targets lie in the module.
For each link the result also reports
score: how the module's targets of the regulator move, as the mean
of mode of regulation x GFC (or log2 FC) per condition; positive values
mean the targets change as expected for a more active regulator. The
overall score is the one of the condition with the largest absolute value
(peak_condition).
consistency: share of those targets that move in the direction of
the score.
activity, activity_qvalue (per condition): regulator activity
estimated with decoupleR::run_ulm() over all network genes, adjusted
per condition. A regulator counts as active in a condition when this
activity is significant and has the same sign as the module score;
n_active_conditions counts those conditions, and the per-condition
heatmaps mark them with *.
regulator_module, regulator_in_module, regulator_cor (TFs): the
module of the TF gene itself and the correlation of its profile with
the module mean. A TF co-expressed with its targets is framed in the
heatmaps.
redundant_with: a better-ranked regulator of the same module whose
module targets largely overlap (see collapse_redundant).
Updated HCoCenaExperiment.
if (requireNamespace("decoupleR", quietly = TRUE)) { hc <- hc_example_data("clustered") gmt <- system.file("extdata", "toy_celltype_markers.gmt", package = "hcocena") # Pathways from a local GMT; TF regulons (`resources = "TF"`) need # the `OmnipathR` (CollecTRI) or `dorothea` package. hc <- hc_upstream_inference( hc, resources = "Pathway", custom_pathway_gmt = c(CellTypes = gmt), plot = FALSE, save_pdf = FALSE ) head(hc_satellite(hc, "upstream_inference")$selected_upstream_all) }if (requireNamespace("decoupleR", quietly = TRUE)) { hc <- hc_example_data("clustered") gmt <- system.file("extdata", "toy_celltype_markers.gmt", package = "hcocena") # Pathways from a local GMT; TF regulons (`resources = "TF"`) need # the `OmnipathR` (CollecTRI) or `dorothea` package. hc <- hc_upstream_inference( hc, resources = "Pathway", custom_pathway_gmt = c(CellTypes = gmt), plot = FALSE, save_pdf = FALSE ) head(hc_satellite(hc, "upstream_inference")$selected_upstream_all) }
Scores every module against a user-supplied list of terms of interest, either
given directly via enrichment_keys or read from a file.
hc_user_specific_cluster_profiling( hc, from_file = FALSE, path = NULL, enrichment_keys = NULL, db = c("Go", "Kegg", "Hallmark"), padj = "BH", qval = 0.1 )hc_user_specific_cluster_profiling( hc, from_file = FALSE, path = NULL, enrichment_keys = NULL, db = c("Go", "Kegg", "Hallmark"), padj = "BH", qval = 0.1 )
hc |
A |
from_file |
Logical. If |
path |
Path to the file holding the terms of interest. Only used when
|
enrichment_keys |
Character vector of terms to profile the modules
against. Required when |
db |
Databases to search for the terms. Default is
|
padj |
Multiple-testing correction method. Default is |
qval |
Maximum adjusted p-value for a term to count. Default is 0.1. |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") gmt <- tempfile(fileext = ".gmt") writeLines( c( paste(c("T cells", "-", "CD3D", "CD3E", "CD3G", "CD2", "CD28", "LCK", "ZAP70", "IL7R", "CD7", "TRAC"), collapse = "\t"), paste(c("B cells", "-", "CD19", "MS4A1", "CD79A", "CD79B", "BLNK", "PAX5", "CR2", "FCRL1", "TNFRSF13B", "VPREB3"), collapse = "\t"), paste(c("Monocytes", "-", "CD14", "LYZ", "FCN1", "VCAN", "S100A8", "S100A9", "CSF1R", "ITGAM", "CD68", "FCGR3A"), collapse = "\t"), paste(c("NK cells", "-", "NKG7", "GNLY", "KLRD1", "KLRF1", "PRF1", "GZMB", "NCR1", "KLRC1", "FGFBP2", "SPON2"), collapse = "\t") ), gmt ) hc <- hc_functional_enrichment( hc, gene_sets = character(0), custom_gmt_files = c(CellTypes = gmt) ) hc <- hc_user_specific_cluster_profiling(hc, from_file = FALSE)hc <- hc_example_data("clustered") gmt <- tempfile(fileext = ".gmt") writeLines( c( paste(c("T cells", "-", "CD3D", "CD3E", "CD3G", "CD2", "CD28", "LCK", "ZAP70", "IL7R", "CD7", "TRAC"), collapse = "\t"), paste(c("B cells", "-", "CD19", "MS4A1", "CD79A", "CD79B", "BLNK", "PAX5", "CR2", "FCRL1", "TNFRSF13B", "VPREB3"), collapse = "\t"), paste(c("Monocytes", "-", "CD14", "LYZ", "FCN1", "VCAN", "S100A8", "S100A9", "CSF1R", "ITGAM", "CD68", "FCGR3A"), collapse = "\t"), paste(c("NK cells", "-", "NKG7", "GNLY", "KLRD1", "KLRF1", "PRF1", "GZMB", "NCR1", "KLRC1", "FGFBP2", "SPON2"), collapse = "\t") ), gmt ) hc <- hc_functional_enrichment( hc, gene_sets = character(0), custom_gmt_files = c(CellTypes = gmt) ) hc <- hc_user_specific_cluster_profiling(hc, from_file = FALSE)
Plots the mean expression per condition for a set of genes as a heatmap.
hc_visualize_gene_expression( hc, genes, name = NULL, width = 15, height = 10, save = TRUE )hc_visualize_gene_expression( hc, genes, name = NULL, width = 15, height = 10, save = TRUE )
hc |
A |
genes |
Character vector of gene symbols to plot. |
name |
Optional name used for the plot title and output file. If |
width |
Plot width in inches. Default is 15. |
height |
Plot height in inches. Default is 10. |
save |
Logical. Write the heatmap to PDF. Default is |
Updated HCoCenaExperiment.
hc <- hc_example_data("clustered") hc <- hc_visualize_gene_expression(hc, genes = "CD3D")hc <- hc_example_data("clustered") hc <- hc_visualize_gene_expression(hc, genes = "CD3D")
Write session info (S4 API)
hc_write_session_info(hc)hc_write_session_info(hc)
hc |
A |
Updated HCoCenaExperiment.
hc <- hc_example_data("prepared") hc <- hc_write_session_info(hc)hc <- hc_example_data("prepared") hc <- hc_write_session_info(hc)
Draws one or all heatmaps stored in the result returned by
hc_regroup_samples(). This uses explicit grid drawing so it also works in
RStudio and notebook contexts where print() may not display a silent
pheatmap object.
## S3 method for class 'hc_sample_regrouping' plot(x, layer = "all", ...)## S3 method for class 'hc_sample_regrouping' plot(x, layer = "all", ...)
x |
An |
layer |
Layer to draw. Use |
... |
Reserved for future plotting options. |
Invisibly returns x.
hc <- hc_example_data("clustered") rg <- hc_regroup_samples(hc, layer = 1, k = 2, apply = FALSE) plot(rg)hc <- hc_example_data("clustered") rg <- hc_regroup_samples(hc, layer = 1, k = 2, apply = FALSE) plot(rg)