R codes for Some Contributions to Cross-Domain Statistical Methods for Abundance Data Analysis: From Ecological Ordination to Microbiome Differential Abundance Analysis
R codes for Some Contributions to Cross-Domain Statistical Methods for Abundance Data Analysis: From Ecological Ordination to Microbiome Differential Abundance Analysis
Where did the research take place?
The study site has not been established. Author addresses may differ from where the research occurred.
A plain-language reading has not been prepared for this paper yet.
Original abstract
# R code accompanying the thesis This repository contains the R scripts used for the data summaries, ecological ordination analyses, microbiome differential-abundance (DA) benchmarking, result extraction, and figures reported in the thesis. The scripts are organised by thesis chapter: - `Ch1/`: descriptive summaries and heatmaps used in Chapter 1.- `Ch4/macrobiome/`: ecological ordination and transformation analyses.- `Ch4/microbiome/`: microbiome DA simulations, real-data analyses, summaries, and figures. ## Data sources ### Macrobiome and ordination datasets - The European bat and bird community datasets are available from the CESTES database under the code names `Charbonnier2016a` and `Charbonnier2016b`.- The Moroccan steppe grazing dataset is available from the CESTES database under the code name `Frenette2012b`.- The pre-processed bacterial-vaginosis microbiome dataset is available from https://github.com/ggloor/CJM_Supplement/tree/master/chunk.- The Chinese wetland soil microbiome dataset is distributed with the CRAN `microeco` package and is also available from https://github.com/ChiLiubio/microeco.- The synthetic abundance gradient reproduced in `simulated_data_complete.R` follows Legendre, P., & Gallagher, E. D. (2001). Ecologically meaningful transformations for ordination of species data. *Oecologia*, 129, 271–280. https://doi.org/10.1007/s004420100716. ### Empirical gut microbiome datasets Four datasets use the data/code names distributed with the study by Nearing et al. (2022): - `cdi_schubert`: Schubert diarrhoea/CDI dataset.- `dia_schneider`: Schneider diarrhoea dataset.- `ob_goodrich`: Goodrich obesity dataset.- `ob_zhu`: Zhu obesity dataset. Source: Nearing, J. T., Douglas, G. M., Hayes, M. G., MacDonald, J., Desai, D. K., Allward, N., Jones, C. M. A., Wright, R. J., Dhanani, A. S., Comeau, A. M., & Langille, M. G. I. (2022). Microbiome differential abundance methods produce different results across 38 datasets. *Nature Communications*, 13, 342. https://doi.org/10.1038/s41467-022-28034-z. The two Parkinson's disease datasets are represented by the following local code names: - `Burns_2017`: Hill–Burns Parkinson's disease dataset.- `Wallen_2020`: Wallen Parkinson's disease dataset. Source: Wallen, Z. D. (2021). Comparison study of sixteen differential abundance testing methods using two large Parkinson disease gut microbiome datasets. *BMC Bioinformatics*, 22, 265. https://doi.org/10.1186/s12859-021-04193-6. ### Pseudo-data The main simulation study uses pseudo-data generated with SimulateMSeq, MIDASim, and metaSPARSim. The shared method-specific DA scripts are supplied for SimulateMSeq pseudo-data as concise demonstrations of the analysis workflow. The additional benchmark uses pseudo-data from Cappellato, M., Baruzzo, G., & Di Camillo, B. (2022). Investigating differential abundance methods in microbiome data: A benchmark study. *PLoS Computational Biology*, 18(9), e1010467. https://doi.org/10.1371/journal.pcbi.1010467. These pseudo-data were converted with author-written preprocessing into the object and naming structure required by the present DA analysis pipeline; the Cappellato summary and figure scripts process the resulting DA output files. ## Code inventory ### `Ch1/` - `heatmap_plants_soil_thesis_combined.R` — prepares the Moroccan plant and Chinese wetland soil abundance data, clusters taxa using Hellinger distances and Ward linkage, and produces the paired abundance/zero-percentage heatmaps used in the thesis.- `plants data summary for thesis.R` — calculates the dimensions, zero structure, sparsity, dominance/unevenness, overdispersion, and compositional summaries of the Moroccan plant dataset.- `soil data summary for thesis.R` — prepares the `microeco` soil data and calculates the corresponding dimensions, zero structure, sparsity, dominance, overdispersion, and compositional summaries. ### `Ch4/macrobiome/` - `simulated_data_complete.R` — reconstructs the Legendre–Gallagher synthetic abundance gradient and runs the complete transformation and ordination workflow, including biplots, heatmaps, transformed matrices, site scores, loadings, and variance summaries.- `Charbonnier2016a_bats_complete.R` — runs the complete transformation, ordination, plotting, and export workflow for the European bat dataset.- `Charbonnier2016b_birds_complete.R` — runs the corresponding complete workflow for the European bird dataset.- `Frenette2012b_plants_complete.R` — runs the corresponding complete workflow for the Moroccan steppe grazing plant dataset.- `human_microbiome_complete.R` — analyses the paired bacterial-vaginosis microbiome samples with the same ordination/transformation framework and exports figures and numerical results.- `soil_microbiome_complete.R` — prepares the Chinese wetland soil microbiome data and runs the complete ordination/transformation, plotting, and export workflow.- `procrustes_analysis_combined.R` — combines site scores across datasets and methods, calculates Procrustes agreement relative to the Hellinger configuration, and exports cross-dataset summaries.- `fido_prior_sensitivity_testing.R` — assesses the sensitivity of the fido-based MLN-CLR workflow to alternative priors and random seeds and produces the robustness figure. ### `Ch4/microbiome/`: simulation generation and post-processing - `generate data with simulator_SimulateMSeq.R` — generates SimulateMSeq phyloseq pseudo-data over the specified sample sizes, DA proportions, numbers of taxa, and abundance conditions; its `Class` values are `"TRUE"` and `"FALSE"`.- `generate_data_with_simulator_MIDAS.R` — uses the SimulateMSeq designs to preserve selected taxa and DA directions, generates matched pseudo-data with MIDASim, and saves shared design information for metaSPARSim.- `generate_data_with_simulator_metaSPARSim.R` — uses the design information produced by the MIDASim script, estimates metaSPARSim parameters, and generates matched phyloseq pseudo-data. The scripts in `Ch4/microbiome/DA code_SimulatedMSeq/` are provided as method-specific demonstrations using pseudo-data generated by **SimulateMSeq**. They are not a single turnkey pipeline for every simulator. In the stored `Class` field, SimulateMSeq identifies truly DA and non-DA taxa as `"TRUE"` and `"FALSE"`, whereas the later MIDASim and metaSPARSim generators identify them as `"DA"` and `"NOT_DA"`. ### `Ch4/microbiome/DA code_SimulatedMSeq/` These scripts demonstrate individual DA methods on SimulateMSeq pseudo-data, compare detected taxa with the known SimulateMSeq truth labels, calculate confusion-matrix-derived performance measures, record run time, and save replicate-level CSV results. - `ALDEx2_Welch.R` — runs ALDEx2 with Welch's t test.- `ALDEx2_Wilcoxon.R` — runs ALDEx2 with the Wilcoxon rank-sum test.- `ANCOMBC.R` — runs the updated ANCOM-BC2 workflow and records the detected taxa and simulation performance.- `DESeq2.R` — runs DESeq2 using positive-count size-factor estimation and BH-adjusted results.- `edgeR_RLE.R` — runs edgeR with relative log-expression (RLE) normalisation.- `edgeR_TMM.R` — runs edgeR with trimmed mean of M-values (TMM) normalisation.- `ZicoSeq.R` — runs ZicoSeq and records detected taxa and simulation performance.- `CAC.Shrinkage_t.DA.BH.R` — applies the CAC transformation followed by a shrinkage t test and BH adjustment.- `CAC.Welch_t.DA.BH.R` — applies the CAC transformation followed by Welch's t test and BH adjustment.- `CAC.Wilcoxon.DA.BH.R` — applies the CAC transformation followed by a Wilcoxon test and BH adjustment.- `chord.Shrinkage_t.DA.BH.R` — applies the chord transformation followed by a shrinkage t test and BH adjustment.- `chord.Welch_t.DA.BH.R` — applies the chord transformation followed by Welch's t test and BH adjustment.- `chord.Wilcoxon.DA.BH.R` — applies the chord transformation followed by a Wilcoxon test and BH adjustment.- `Hellinger.Shrinkage_t.DA.BH.R` — applies the Hellinger transformation followed by a shrinkage t test and BH adjustment.- `Hellinger.Welch_t.DA.BH.R` — applies the Hellinger transformation followed by Welch's t test and BH adjustment.- `Hellinger.Wilcoxon.DA.BH.R` — applies the Hellinger transformation followed by a Wilcoxon test and BH adjustment.- `simple_CLR.Shrinkage_t.DA.BH.R` — applies the simple CLR transformation followed by a shrinkage t test and BH adjustment.- `simple_CLR.Welch_t.DA.BH.R` — applies the simple CLR transformation followed by Welch's t test and BH adjustment.- `simple_CLR.Wilcoxon.DA.BH.R` — applies the simple CLR transformation followed by a Wilcoxon test and BH adjustment. - `simulation summary SimulateMSeq,MIDAS,metaSPARSim.R` — extracts replicate-level DA results from the three simulators, calculates average performance measures, and writes simulator-specific summary tables.- `simulation summary Cappellato.R` — extracts and averages method results for the converted Cappellato pseudo-data across datasets, sample sizes, and DA percentages.- `simulation_summary_helper.R` — provides shared method labels, truth look-up tables, result-completion and summarisation functions, performance metrics, rankings, and plotting helpers for the three-simulator and Cappellato analyses.- `Simulation_Figures_SimulateMSeq,MIDAS,metaSPRASim.R` — creates the combined SimulateMSeq, MIDASim, and metaSPARSim performance summaries, method rankings, and dot-plot figures. The filename retains the historical spelling `metaSPRASim`.- `Cappellato_Figures.R` — creates Cappellato benchmark summary tables, method rankings, and dataset/DA-percentage dot plots with sample-size overlays. ### `Ch4/microbiome/`: real-data summaries and Parkinson's disease comparisons - `microbiome_realdata_venn_summary.R` — loads the six empirical gut microbiome datasets and their DA summaries, produces method-overlap Venn diagrams and dataset summaries, and reports taxa uniquely detected by selected transformations/tests.- `compare_OTU_and_ASV_gut_PD_hist.R` — harmonises genus names between the two Parkinson's disease datasets, identifies common detected genera, and compares their raw and transformed abundance distributions by case/control status.- `compare_OTU_and_ASV_gut_PD_fittest.R` — evaluates negative-binomial fits to raw counts and skew-normal fits to CLR-transformed values for features in the two Parkinson's disease datasets and writes detailed and summary fit tables. ### `Ch4/microbiome/DA code real data/` Each dataset-specific script prepares genus-level data, applies the real-data DA workflow, records detected taxa and execution times, and writes a result-summary file. - `Burns2017_testing.R` — performs the full real-data DA analysis for the `Burns_2017` Hill–Burns Parkinson's disease dataset.- `Wallen2020_testing.R` — performs the full real-data DA analysis for the `Wallen_2020` Wallen Parkinson's disease dataset.- `cdi_schubert_testing.R` — prepares and analyses the `cdi_schubert` Schubert diarrhoea/CDI dataset.- `dia_schneider_testing.R` — prepares and analyses the `dia_schneider` Schneider diarrhoea dataset.- `ob_goodrich_testing.R` — prepares and analyses the `ob_goodrich` Goodrich obesity dataset.- `ob_zhu_testing.R` — prepares and analyses the `ob_zhu` Zhu obesity dataset.- `CAC_realdata.R` — applies the CAC transformation with Wilcoxon, Welch t, and shrinkage t tests to all six empirical datasets and appends the CAC results to their existing DA summary files.