| Title: | Microbiome Confounder-Adjusted Robust Analysis |
|---|---|
| Description: | Provides a comprehensive framework for multi-cohort microbiome differential abundance and residual correlation analysis. It integrates confounder-adjusted linear models with centered log-ratio transformed taxonomic and functional pathway profiles. The package features robust preprocessing, automated covariate handling, multiple-testing correction, and quality control diagnostics for multi-omics data. Interactive visualization tools are included to facilitate downstream interpretation of cross-domain interaction networks. |
| Authors: | Safa Bushnaq [aut, cre] (ORCID: <https://orcid.org/0009-0000-3723-5725>) |
| Maintainer: | Safa Bushnaq <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.99.2 |
| Built: | 2026-10-04 14:42:14 UTC |
| Source: | https://github.com/BiocStaging/MiCARA |
Applies a single multiple-testing correction across all taxon-pathway
associations tested across all analysed disease groups in a
micara_interactions object.
compute_global_fdr( interactions, method = "BH", q_cutoff = 0.05, r_cutoff = 0.2, verbose = TRUE )compute_global_fdr( interactions, method = "BH", q_cutoff = 0.05, r_cutoff = 0.2, verbose = TRUE )
interactions |
An object of class |
method |
Multiple-testing correction method passed to
|
q_cutoff |
Global adjusted p-value threshold for retaining an
association. Default is |
r_cutoff |
Minimum absolute Spearman correlation required for retaining
an association. Default is |
verbose |
Logical; if |
The function operates on the $all_links component produced by
compute_residualCLR_correlations. The existing disease-specific
$links results are not modified. Instead, globally supported
associations are stored in a new $global_links component for each
disease, and the globally adjusted p-values are added to $all_links
as q_global.
This correction is optional and is most appropriate when inference is intended across multiple disease groups, disease stages, cancer types, cohorts, or other collections of simultaneous taxon-pathway tests.
The global correction is performed once across the complete set of
available $all_links tables from all analysed diseases. It is
therefore different from the disease-specific BH correction already
performed by compute_residualCLR_correlations.
Global correction is performed only on the p-values from tested taxon-pathway pairs. The correlation threshold is applied after correction and does not enter the multiplicity adjustment.
An object of class micara_interactions. For each disease,
the returned object contains:
all_links: all tested taxon-pathway pairs with an added
q_global column;
links: the original disease-specific BH-significant links,
unchanged;
global_links: associations passing the global adjusted
p-value and correlation thresholds;
n_global_links: number of globally significant associations.
The returned object also contains a "global_fdr" attribute with
correction settings, the total number of tested pairs, and the total
number of globally significant associations.
# Construct minimal mock interactions input mock_interactions <- list( IBD = list( status = "analysed", all_links = data.frame( taxon = c("TaxonA", "TaxonB", "TaxonC"), pathway = c("Path1", "Path2", "Path1"), p = c(0.001, 0.030, 0.450), rho = c(0.45, -0.28, 0.05), stringsAsFactors = FALSE ), links = data.frame( taxon = c("TaxonA", "TaxonB"), pathway = c("Path1", "Path2"), p = c(0.001, 0.030), rho = c(0.45, -0.28), stringsAsFactors = FALSE ) ) ) class(mock_interactions) <- c("micara_interactions", "list") # Run global FDR evaluation interactions_global <- compute_global_fdr(mock_interactions) # Inspect global links interactions_global$IBD$sig_links_global attr(interactions_global, "global_hits")# Construct minimal mock interactions input mock_interactions <- list( IBD = list( status = "analysed", all_links = data.frame( taxon = c("TaxonA", "TaxonB", "TaxonC"), pathway = c("Path1", "Path2", "Path1"), p = c(0.001, 0.030, 0.450), rho = c(0.45, -0.28, 0.05), stringsAsFactors = FALSE ), links = data.frame( taxon = c("TaxonA", "TaxonB"), pathway = c("Path1", "Path2"), p = c(0.001, 0.030), rho = c(0.45, -0.28), stringsAsFactors = FALSE ) ) ) class(mock_interactions) <- c("micara_interactions", "list") # Run global FDR evaluation interactions_global <- compute_global_fdr(mock_interactions) # Inspect global links interactions_global$IBD$sig_links_global attr(interactions_global, "global_hits")
Applies the second analytical layer of MiCARA after differential abundance analysis. For each disease with at least one robust differentially abundant taxon and pathway, the function:
compute_residualCLR_correlations( micara_obj, diffab_obj = NULL, taxa_diffab = NULL, pathway_diffab = NULL, diseases = NULL, covariates = NULL, q_cutoff = 0.05, r_cutoff = 0.2, pseudocount = NULL, min_samples_per_disease = 10L, min_residual_df = 3L, retain_all_pairs = TRUE, verbose = TRUE )compute_residualCLR_correlations( micara_obj, diffab_obj = NULL, taxa_diffab = NULL, pathway_diffab = NULL, diseases = NULL, covariates = NULL, q_cutoff = 0.05, r_cutoff = 0.2, pseudocount = NULL, min_samples_per_disease = 10L, min_residual_df = 3L, retain_all_pairs = TRUE, verbose = TRUE )
micara_obj |
A |
diffab_obj |
Optional combined |
taxa_diffab |
Optional |
pathway_diffab |
Optional |
diseases |
Character vector of diseases to analyse. The default
|
covariates |
Character vector of metadata columns to remove before
correlation. The default |
q_cutoff |
Strict BH-adjusted p-value threshold for retaining links.
Default |
r_cutoff |
Strict minimum absolute Spearman correlation for retaining
links. Default |
pseudocount |
Zero replacement used before taking logarithms.
|
min_samples_per_disease |
Minimum number of disease samples required
before attempting residualisation. Default |
min_residual_df |
Minimum residual degrees of freedom required after
building the covariate design matrix. Default |
retain_all_pairs |
Logical. If |
verbose |
Logical; print progress and a disease-level summary. |
CLR-transforms the complete taxonomic and pathway matrices.
selects the disease-specific significant taxa and pathways.
restricts the analysis to samples from that disease.
residualises both feature sets against estimable covariates.
computes all taxon-pathway Spearman correlations on the residuals.
applies Benjamini-Hochberg correction within each disease.
retains links satisfying both q < q_cutoff and
abs(rho) > r_cutoff.
CLR is calculated on the full feature set before disease-specific feature selection. Canonical taxon and pathway identifiers are preserved; labels should be cleaned only in downstream plotting functions.
#' For analyses requiring correction across the pooled interaction search
space, the returned object can optionally be passed to
compute_global_fdr.
An object of class micara_interactions. It is a named list
with one element per analysed disease. Each disease element contains:
"analysed" or "skipped".
Reason for skipping, otherwise NA.
Associations passing both thresholds.
All tested associations when
retain_all_pairs = TRUE.
Differential-abundance directions for tested taxa and pathways.
Covariate provenance for that disease.
Analysis scope and model diagnostics.
The object carries "summary" and "settings" attributes.
Access them with attr(x, "summary") and
attr(x, "settings").
set.seed(123) sample_ids <- paste0("Sample_", 1:20) taxa_mat <- as.data.frame(matrix( rpois(100, lambda = 50), nrow = 5, ncol = 20, dimnames = list(paste0("Taxon_", 1:5), sample_ids) )) path_mat <- as.data.frame(matrix( rpois(100, lambda = 100), nrow = 5, ncol = 20, dimnames = list(paste0("Pathway_", 1:5), sample_ids) )) # Inject strong signal so features pass significance testing taxa_mat["Taxon_1", 11:20] <- taxa_mat["Taxon_1", 11:20] + 300 path_mat["Pathway_1", 11:20] <- path_mat["Pathway_1", 11:20] + 500 meta_df <- data.frame( sample_id = sample_ids, disease = rep(c("Control", "Disease"), each = 10), age = rnorm(20, mean = 40, sd = 5), row.names = sample_ids ) validated_obj <- validate_inputs( taxa = taxa_mat, pathways = path_mat, metadata = meta_df, disease_col = "disease", disease_min_samples = 5, verbose = FALSE ) diff_res <- run_diff_abundance( micara_obj = validated_obj, feature_type = c("taxa", "pathways"), rand_effect = NULL, n_cores = 1, verbose = FALSE ) corr_res <- compute_residualCLR_correlations( micara_obj = validated_obj, diffab_obj = diff_res, covariates = "age", q_cutoff = 1.0, min_samples_per_disease = 5L, verbose = FALSE )set.seed(123) sample_ids <- paste0("Sample_", 1:20) taxa_mat <- as.data.frame(matrix( rpois(100, lambda = 50), nrow = 5, ncol = 20, dimnames = list(paste0("Taxon_", 1:5), sample_ids) )) path_mat <- as.data.frame(matrix( rpois(100, lambda = 100), nrow = 5, ncol = 20, dimnames = list(paste0("Pathway_", 1:5), sample_ids) )) # Inject strong signal so features pass significance testing taxa_mat["Taxon_1", 11:20] <- taxa_mat["Taxon_1", 11:20] + 300 path_mat["Pathway_1", 11:20] <- path_mat["Pathway_1", 11:20] + 500 meta_df <- data.frame( sample_id = sample_ids, disease = rep(c("Control", "Disease"), each = 10), age = rnorm(20, mean = 40, sd = 5), row.names = sample_ids ) validated_obj <- validate_inputs( taxa = taxa_mat, pathways = path_mat, metadata = meta_df, disease_col = "disease", disease_min_samples = 5, verbose = FALSE ) diff_res <- run_diff_abundance( micara_obj = validated_obj, feature_type = c("taxa", "pathways"), rand_effect = NULL, n_cores = 1, verbose = FALSE ) corr_res <- compute_residualCLR_correlations( micara_obj = validated_obj, diffab_obj = diff_res, covariates = "age", q_cutoff = 1.0, min_samples_per_disease = 5L, verbose = FALSE )
A simulated metadata data frame containing sample covariates and disease status.
data(example_metadata)data(example_metadata)
A data frame with 30 rows and 6 columns:
Unique sample identifier
Disease group assignment ("Control" or "Case")
Age cohort ("Adult" or "Senior")
Body Mass Index
Sex of the participant
Cohort study origin
Simulated synthetic data for MiCARA testing and demonstration.
A simulated count matrix representing functional pathway abundances across samples.
data(example_pathways)data(example_pathways)
A numeric matrix with 10 rows (pathways) and 30 columns (samples).
Simulated synthetic data for MiCARA testing and demonstration.
A simulated count matrix representing bacterial taxonomic abundances across samples.
data(example_taxa)data(example_taxa)
A numeric matrix with 20 rows (taxa) and 30 columns (samples).
Simulated synthetic data for MiCARA testing and demonstration.
Imputes missing values in host confounders (age, gender, BMI)
that were retained by validate_inputs (i.e., below the missingness
cutoff). Experimental design indicators such as disease, study_name,
and sequencing depth (number_reads) are strictly protected and used only
as auxiliary predictors to inform imputation. age_category is also treated
as an auxiliary predictor when complete to guide continuous age imputation.
impute_metadata( micara_obj, impute_vars = NULL, auxiliary_predictors = NULL, m = 5, method = NULL, seed = 123, imputation_index = 1, verbose = TRUE )impute_metadata( micara_obj, impute_vars = NULL, auxiliary_predictors = NULL, m = 5, method = NULL, seed = 123, imputation_index = 1, verbose = TRUE )
micara_obj |
An object of class |
impute_vars |
Character vector of host confounders to impute.
Defaults to the intersection of |
auxiliary_predictors |
Character vector of additional metadata
columns to include as MICE predictors (never imputation targets).
Defaults to |
m |
Number of multiple imputations (default 5, the MICE convention). |
method |
Imputation method passed to |
seed |
Random seed for reproducibility (default 123). |
imputation_index |
Which of the |
verbose |
Logical; print progress and summary report to console (default TRUE). |
Scientific Guidance on Downstream Covariate Selection:
Imputed continuous age is generally recommended over binned age_category
for differential abundance modeling (e.g., ANCOM-BC2) as it avoids discretization
power loss. However, age_category should be used directly if modeling
distinct non-linear biological thresholds (e.g., pediatric vs. adult states) or
if continuous age missingness exceeded 50\
An object of class c("micara_imputed", "micara_input"):
the input object with updated metadata, plus mice_fit (the full
mids object, or NULL if skipped), imputed_vars, and
imputation_performed (logical; FALSE if no missingness was
present or imputation was skipped).
set.seed(123) sample_ids <- paste0("Sample_", 1:20) taxa_mat <- as.data.frame(matrix( rpois(100, lambda = 50), nrow = 5, ncol = 20, dimnames = list(paste0("Taxon_", 1:5), sample_ids) )) path_mat <- as.data.frame(matrix( rpois(100, lambda = 100), nrow = 5, ncol = 20, dimnames = list(paste0("Pathway_", 1:5), sample_ids) )) # Create metadata with missing age values (NA) meta_df <- data.frame( sample_id = sample_ids, disease = rep(c("Control", "Disease"), each = 10), age = c( 25, NA, 30, 45, NA, 50, 33, 29, 41, 38, 52, 60, NA, 48, 55, 62, NA, 39, 44, 51 ), row.names = sample_ids ) validated_obj <- validate_inputs( taxa = taxa_mat, pathways = path_mat, metadata = meta_df, disease_col = "disease", disease_min_samples = 5, verbose = FALSE ) # Run imputation on missing age column imputed_obj <- impute_metadata( micara_obj = validated_obj, impute_vars = "age", m = 2, seed = 123, verbose = FALSE )set.seed(123) sample_ids <- paste0("Sample_", 1:20) taxa_mat <- as.data.frame(matrix( rpois(100, lambda = 50), nrow = 5, ncol = 20, dimnames = list(paste0("Taxon_", 1:5), sample_ids) )) path_mat <- as.data.frame(matrix( rpois(100, lambda = 100), nrow = 5, ncol = 20, dimnames = list(paste0("Pathway_", 1:5), sample_ids) )) # Create metadata with missing age values (NA) meta_df <- data.frame( sample_id = sample_ids, disease = rep(c("Control", "Disease"), each = 10), age = c( 25, NA, 30, 45, NA, 50, 33, 29, 41, 38, 52, 60, NA, 48, 55, 62, NA, 39, 44, 51 ), row.names = sample_ids ) validated_obj <- validate_inputs( taxa = taxa_mat, pathways = path_mat, metadata = meta_df, disease_col = "disease", disease_min_samples = 5, verbose = FALSE ) # Run imputation on missing age column imputed_obj <- impute_metadata( micara_obj = validated_obj, impute_vars = "age", m = 2, seed = 123, verbose = FALSE )
Renders a Sankey diagram of confounder-adjusted taxon-pathway
correlations for a single disease, as computed by
compute_residualCLR_correlations. Positive and negative
correlations are rendered as separate diagrams (matching the two-panel
"Figure A/B" convention used throughout this package's companion analyses)
to preserve clear biological interpretation.
plot_interaction_sankey( interactions, disease, direction = c("both", "positive", "negative"), significance = c("local", "global"), top_n_per_pathway = NULL, node_colors = c(up = "#2196F3", down = "#F44336", unchanged = "grey70", stable = "gray70"), font_size = 18, node_width = 35, save_path = NULL )plot_interaction_sankey( interactions, disease, direction = c("both", "positive", "negative"), significance = c("local", "global"), top_n_per_pathway = NULL, node_colors = c(up = "#2196F3", down = "#F44336", unchanged = "grey70", stable = "gray70"), font_size = 18, node_width = 35, save_path = NULL )
interactions |
A |
disease |
Name of the disease to plot (must be present in
|
direction |
One of |
significance |
Character string specifying which interaction set
to plot. |
top_n_per_pathway |
Optional integer; if supplied, keeps only
the |
node_colors |
Named character vector mapping node group to
colour. Default |
font_size, node_width
|
Passed to
|
save_path |
Optional file path (with or without extension) to save the
diagram(s). If supplied, saves interactive |
When significance = "global", the input object must have been
processed by compute_global_fdr.
A networkD3 htmlwidget object (for "positive" or
"negative"), or a named list of two networkD3 htmlwidget
objects ($positive and $negative) when direction = "both"
(returned invisibly if save_path is supplied).
set.seed(123) sample_ids <- paste0("Sample_", 1:20) taxa_mat <- as.data.frame(matrix( rpois(100, lambda = 50), nrow = 5, ncol = 20, dimnames = list(paste0("Taxon_", 1:5), sample_ids) )) path_mat <- as.data.frame(matrix( rpois(100, lambda = 100), nrow = 5, ncol = 20, dimnames = list(paste0("Pathway_", 1:5), sample_ids) )) # Inject strong differential signal AND wide variance across Disease samples taxa_mat["Taxon_1", 11:20] <- seq(100, 1000, length.out = 10) path_mat["Pathway_1", 11:20] <- taxa_mat["Taxon_1", 11:20] * 2 meta_df <- data.frame( sample_id = sample_ids, disease = rep(c("Control", "Disease"), each = 10), age = rnorm(20, mean = 40, sd = 5), row.names = sample_ids ) validated_obj <- validate_inputs( taxa = taxa_mat, pathways = path_mat, metadata = meta_df, disease_col = "disease", disease_min_samples = 5, verbose = FALSE ) diff_res <- run_diff_abundance( micara_obj = validated_obj, feature_type = c("taxa", "pathways"), rand_effect = NULL, n_cores = 1, verbose = FALSE ) corr_res <- compute_residualCLR_correlations( micara_obj = validated_obj, diffab_obj = diff_res, covariates = "age", q_cutoff = 1.0, min_samples_per_disease = 5L, verbose = FALSE ) plot_interaction_sankey(corr_res, disease = "Disease")set.seed(123) sample_ids <- paste0("Sample_", 1:20) taxa_mat <- as.data.frame(matrix( rpois(100, lambda = 50), nrow = 5, ncol = 20, dimnames = list(paste0("Taxon_", 1:5), sample_ids) )) path_mat <- as.data.frame(matrix( rpois(100, lambda = 100), nrow = 5, ncol = 20, dimnames = list(paste0("Pathway_", 1:5), sample_ids) )) # Inject strong differential signal AND wide variance across Disease samples taxa_mat["Taxon_1", 11:20] <- seq(100, 1000, length.out = 10) path_mat["Pathway_1", 11:20] <- taxa_mat["Taxon_1", 11:20] * 2 meta_df <- data.frame( sample_id = sample_ids, disease = rep(c("Control", "Disease"), each = 10), age = rnorm(20, mean = 40, sd = 5), row.names = sample_ids ) validated_obj <- validate_inputs( taxa = taxa_mat, pathways = path_mat, metadata = meta_df, disease_col = "disease", disease_min_samples = 5, verbose = FALSE ) diff_res <- run_diff_abundance( micara_obj = validated_obj, feature_type = c("taxa", "pathways"), rand_effect = NULL, n_cores = 1, verbose = FALSE ) corr_res <- compute_residualCLR_correlations( micara_obj = validated_obj, diffab_obj = diff_res, covariates = "age", q_cutoff = 1.0, min_samples_per_disease = 5L, verbose = FALSE ) plot_interaction_sankey(corr_res, disease = "Disease")
Clean HUMAnN Pathway Matrix
prep_humann_pathways(pathway_matrix)prep_humann_pathways(pathway_matrix)
pathway_matrix |
Numeric matrix of pathway abundances from HUMAnN. |
Cleaned pathway matrix containing only community-level unstratified pathways.
dummy_pathways <- matrix( c(150.2, 300.8, 0, 120.0, 450.5, 10.0), nrow = 3, ncol = 2, dimnames = list( c("PWY-101: gnb1", "UNMAPPED", "PWY-101|s__Staphylococcus_aureus"), c("Sample1", "Sample2") ) ) prep_humann_pathways(dummy_pathways)dummy_pathways <- matrix( c(150.2, 300.8, 0, 120.0, 450.5, 10.0), nrow = 3, ncol = 2, dimnames = list( c("PWY-101: gnb1", "UNMAPPED", "PWY-101|s__Staphylococcus_aureus"), c("Sample1", "Sample2") ) ) prep_humann_pathways(dummy_pathways)
Clean MetaPhlAn Taxonomic Names
prep_metaphlan_taxa(taxa_matrix, rank = "species")prep_metaphlan_taxa(taxa_matrix, rank = "species")
taxa_matrix |
Numeric matrix of taxonomic abundances with MetaPhlAn row names. |
rank |
Taxonomic rank to extract (default: "species"). |
Cleaned taxonomic matrix with standardized species names.
dummy_taxa <- matrix( c(10.5, 89.5, 20.0, 80.0), nrow = 2, ncol = 2, dimnames = list( c( "k__Bacteria|s__Staphylococcus_aureus", "k__Bacteria|s__Bacteroides_fragilis" ), c("Sample1", "Sample2") ) ) prep_metaphlan_taxa(dummy_taxa, rank = "species")dummy_taxa <- matrix( c(10.5, 89.5, 20.0, 80.0), nrow = 2, ncol = 2, dimnames = list( c( "k__Bacteria|s__Staphylococcus_aureus", "k__Bacteria|s__Bacteroides_fragilis" ), c("Sample1", "Sample2") ) ) prep_metaphlan_taxa(dummy_taxa, rank = "species")
Performs bias-corrected differential abundance testing for microbial taxa,
functional pathways, or both using ANCOM-BC2 (ANCOMBC::ancombc2).
Automatically integrates retained host confounders from validate_inputs
as fixed effects and supports multi-cohort random effects.
run_diff_abundance( micara_obj, feature_type = c("taxa", "pathways"), fix_effects = NULL, exclude_covariates = NULL, rand_effect = "study_name", reference_level = NULL, p_adj_method = "BH", prv_cut = 0.1, alpha = 0.05, pairwise = FALSE, struc_zero = TRUE, neg_lb = TRUE, pseudo_sens = TRUE, use_robust = TRUE, n_cores = 1, verbose = TRUE )run_diff_abundance( micara_obj, feature_type = c("taxa", "pathways"), fix_effects = NULL, exclude_covariates = NULL, rand_effect = "study_name", reference_level = NULL, p_adj_method = "BH", prv_cut = 0.1, alpha = 0.05, pairwise = FALSE, struc_zero = TRUE, neg_lb = TRUE, pseudo_sens = TRUE, use_robust = TRUE, n_cores = 1, verbose = TRUE )
micara_obj |
An object of class |
feature_type |
Character vector specifying feature matrices to analyze:
|
fix_effects |
Character vector of metadata columns to include as fixed-effect
covariates. If |
exclude_covariates |
Character vector of covariate names to explicitly exclude from fixed effects. |
rand_effect |
Character string naming the metadata column for random intercepts
(default |
reference_level |
Character string defining the control or reference category
within |
p_adj_method |
Method for p-value adjustment passed to |
prv_cut |
Minimum prevalence threshold (0 to 1) for features to be retained prior to analysis (default 0). |
alpha |
Significance level threshold for q-values (default 0.05). |
pairwise |
Logical; whether to perform pairwise comparisons between all disease levels (default FALSE). |
struc_zero |
Logical; whether to detect structural zeros (default TRUE). |
neg_lb |
Logical; whether to apply a negative lower bound for asymptotic variance estimation (default TRUE). |
pseudo_sens |
Logical; whether to perform pseudo-count sensitivity analysis
(default TRUE). Automatically set to |
use_robust |
Logical; whether to use robust sensitivity flags
( |
n_cores |
Integer specifying the number of CPU cores for parallel processing (default 1). |
verbose |
Logical; print progress and summary report to console (default TRUE). |
Multi-Feature Execution:
When feature_type = c("taxa", "pathways"), the function iterates over
both datasets if present in micara_obj and returns a named list of
analysis objects.
Model Specification & Safeguards:
Fixed effects automatically incorporate retained host confounders (e.g., age, gender,
BMI) alongside disease. Variables with zero variance or missing values are
automatically flagged. The random effect (rand_effect = "study_name")
accounts for cohort-level batch variation and is automatically disabled if only a
single cohort/study is present in the dataset.
Sensitivity Flags:
By default (use_robust = TRUE), significance is defined using robust sensitivity
flags (diff_robust_disease...) calculated across pseudo-count additions,
providing high confidence against false positives in sparse microbiome data.
If a single feature_type is analyzed, an object of class
"micara_diffab". If multiple feature types are analyzed, a named list
of "micara_diffab" objects with class "micara_diffab_list".
set.seed(123) sample_ids <- paste0("Sample_", 1:20) # Create count matrices required for differential abundance modeling taxa_mat <- as.data.frame(matrix( rpois(100, lambda = 50), nrow = 5, ncol = 20, dimnames = list(paste0("Taxon_", 1:5), sample_ids) )) path_mat <- as.data.frame(matrix( rpois(100, lambda = 100), nrow = 5, ncol = 20, dimnames = list(paste0("Pathway_", 1:5), sample_ids) )) meta_df <- data.frame( sample_id = sample_ids, disease = rep(c("Control", "Disease"), each = 10), study_name = rep(c("Study1", "Study2"), each = 10), row.names = sample_ids ) validated_obj <- validate_inputs( taxa = taxa_mat, pathways = path_mat, metadata = meta_df, disease_col = "disease", disease_min_samples = 5, verbose = FALSE ) # Run differential abundance analysis (set n_cores = 1 for CRAN/Bioc compliance) diff_res <- run_diff_abundance( micara_obj = validated_obj, feature_type = "taxa", rand_effect = NULL, n_cores = 1, verbose = FALSE )set.seed(123) sample_ids <- paste0("Sample_", 1:20) # Create count matrices required for differential abundance modeling taxa_mat <- as.data.frame(matrix( rpois(100, lambda = 50), nrow = 5, ncol = 20, dimnames = list(paste0("Taxon_", 1:5), sample_ids) )) path_mat <- as.data.frame(matrix( rpois(100, lambda = 100), nrow = 5, ncol = 20, dimnames = list(paste0("Pathway_", 1:5), sample_ids) )) meta_df <- data.frame( sample_id = sample_ids, disease = rep(c("Control", "Disease"), each = 10), study_name = rep(c("Study1", "Study2"), each = 10), row.names = sample_ids ) validated_obj <- validate_inputs( taxa = taxa_mat, pathways = path_mat, metadata = meta_df, disease_col = "disease", disease_min_samples = 5, verbose = FALSE ) # Run differential abundance analysis (set n_cores = 1 for CRAN/Bioc compliance) diff_res <- run_diff_abundance( micara_obj = validated_obj, feature_type = "taxa", rand_effect = NULL, n_cores = 1, verbose = FALSE )
Performs quality control on taxonomic and functional pathway abundance tables and accompanying sample metadata.
validate_inputs( taxa, pathways, metadata, disease_col = "disease", disease_min_samples = 10, metadata_missing_cutoff = 0.3, normalise = TRUE, verbose = TRUE )validate_inputs( taxa, pathways, metadata, disease_col = "disease", disease_min_samples = 10, metadata_missing_cutoff = 0.3, normalise = TRUE, verbose = TRUE )
taxa |
Taxonomic abundance table. Must be a data.frame. |
pathways |
Functional pathway abundance table. Must be a data.frame. |
metadata |
Sample metadata. Must contain sample IDs and disease labels. |
disease_col |
Name of the disease column in metadata. Default "disease". |
disease_min_samples |
Minimum required samples per disease group. Default 10. |
metadata_missing_cutoff |
Allowed missing value fraction for covariates. Default 0.30. |
normalise |
Logical indicating whether feature normalization should be performed. |
verbose |
Logical; print QC summary. Default TRUE. |
An object of class "micara_input".
set.seed(123) sample_ids <- paste0("Sample_", 1:20) taxa_mat <- as.data.frame(matrix( rpois(100, lambda = 50), nrow = 5, ncol = 20, dimnames = list(paste0("Taxon_", 1:5), sample_ids) )) path_mat <- as.data.frame(matrix( rpois(100, lambda = 100), nrow = 5, ncol = 20, dimnames = list(paste0("Pathway_", 1:5), sample_ids) )) meta_df <- data.frame( sample_id = sample_ids, disease = rep(c("Control", "Disease"), each = 10), age = rnorm(20, mean = 40, sd = 5), row.names = sample_ids ) validated_obj <- validate_inputs( taxa = taxa_mat, pathways = path_mat, metadata = meta_df, disease_col = "disease", disease_min_samples = 5, verbose = FALSE )set.seed(123) sample_ids <- paste0("Sample_", 1:20) taxa_mat <- as.data.frame(matrix( rpois(100, lambda = 50), nrow = 5, ncol = 20, dimnames = list(paste0("Taxon_", 1:5), sample_ids) )) path_mat <- as.data.frame(matrix( rpois(100, lambda = 100), nrow = 5, ncol = 20, dimnames = list(paste0("Pathway_", 1:5), sample_ids) )) meta_df <- data.frame( sample_id = sample_ids, disease = rep(c("Control", "Disease"), each = 10), age = rnorm(20, mean = 40, sd = 5), row.names = sample_ids ) validated_obj <- validate_inputs( taxa = taxa_mat, pathways = path_mat, metadata = meta_df, disease_col = "disease", disease_min_samples = 5, verbose = FALSE )