Predicting oxygen levels in microbial habitats using a metagenome-based approach Authors: Clifton P. Bueno de Mesquita, Elías Stallard-Olivera, Noah Fierer Published: 2026 ABSTRACT ABSTRACTOxygen is a primary driver of the distribution and activity of microbial life. Since oxygen levels are often difficult to measure in situ, one potential solution is to use bacteria as bioindicators of oxygen levels. As bacteria range from obligate aerobes to obligate anaerobes, quantification of bacterial community oxygen preferences could be used to infer variation in oxygen levels and bacterial metabolic strategies. After using ensemble machine learning to select the 20 most important genes that predict oxygen tolerances in individual bacteria, we established a relationship between the abundance ratio of aerobic:anaerobic indicator genes and the proportional abundance of aerobic bacteria using simulated metagenomes with varying ratios of known aerobes and anaerobes. We developed a tool, OxyMetaG, that takes metagenomic reads as input, extracts bacterial reads, maps reads to the 20 genes, and predicts oxygen availability in any sample on a scale from 0% to 100% (completely anoxic to completely oxic). We tested OxyMetaG on a suite of metagenomes with measured or inferred oxygen levels across a variety of environmental and host-associated samples. To demonstrate its utility, we applied OxyMetaG to 540 surface soils, showing that surface soils are predominantly oxic, but wetter sites with finer textures have relatively less oxygen. Finally, we applied OxyMetaG to 73 human gut samples, showing that in the first 3 years of life, human guts progress from oxygen levels as high as 61% down to 0%. We expect OxyMetaG to have broad utility for characterizing oxygen levels in both modern and ancient microbial habitats.IMPORTANCEOxygen is one of the most important environmental variables affecting microbial activity and composition, but is often difficult to measure in situ. We developed a tool, OxyMetaG, that leverages differences in bacterial gene content across known aerobic and anaerobic taxa to predict the oxygen level of a given sample directly from shotgun metagenomic reads. OxyMetaG works on samples with low sequencing depth and avoids computationally expensive genome assembly, which often captures only a fraction of the microbial community in a given environment. With OxyMetaG, bacteria can be used as bioindicators of oxygen availability over broader time scales than just a single measurement and provide crucial environmental context in cases where oxygen has not been or cannot be measured. OxyMetaG is publicly available and can be used to answer a wide variety of ecological questions in both environmental and host-associated systems. INTRODUCTION Throughout geologic history, atmospheric oxygen levels have been variable. For the first ~1.5 billion years that life likely existed on Earth, atmospheric oxygen was limited, and anaerobic bacteria predominated (1). Only following the Great Oxidation Event (2) did the atmosphere become oxygenated, with levels over the past ~2.4 billion years ranging from 15% to 35% before reaching the current concentration of 21% (3). Even across modern environments, oxygen concentrations can be highly variable (e.g., waterlogged hypoxic wetland sediments to oxic surface ocean water). This spatial and temporal variation in oxygen concentrations is often a primary determinant of bacterial distributions and their metabolic activities. Bacteria can differ widely with respect to their oxygen tolerances and preferences, with the oxygen levels in any given environment dictating which taxa can thrive in that environment and their potential metabolic strategies. We sought to take advantage of these patterns to develop a predictive tool that can work directly on metagenomic reads (avoiding computationally expensive assembly, binning, and annotation) to predict the oxygen level (on a scale from 0% to 100%) in any given environmental or host-associated sample based on known proportions of aerobic and anaerobic bacterial indicator genes. Bacterial oxygen preferences range from obligate anaerobes that are unable to grow in the presence of oxygen and instead generate energy via fermentation or anaerobic respiration to obligate aerobes that require atmospheric levels of oxygen to sustain growth. Between these end members exist facultative aerobes/anaerobes that can tolerate oxygen or a lack of oxygen and switch their metabolisms accordingly, and microaerophiles, which are defined as organisms that grow at low (below atmospheric, usually 2%–10%) oxygen levels (4). In short, bacterial oxygen preferences span a spectrum, and for most cultivated bacteria, we know from experimental assays where they fall along this spectrum. Even for the majority of bacteria that are resistant to cultivation and have not been studied in vitro, oxygen preferences can often be inferred from genome-based models, including models that rely on specific sets of genes (5–14) or other genomic attributes such as amino acid frequencies (15, 16). While such genome-based models enable inferences of oxygen preferences for individual taxa, inferring community-level oxygen preferences would require having high-quality genomes for the majority of taxa in a given community, a challenging task in many systems with high levels of bacterial diversity (17). We thus sought to develop a metagenome-based tool that could work directly on metagenomic reads to predict a sample’s general oxygen levels scaled from 0-100% (completely anoxic to completely oxic), based on the known proportions of aerobic and anaerobic bacterial indicator genes. Not only would such a metagenome-based model make it possible to quantify oxygen preferences as a community-aggregated trait (18), but also we could use inferred community-level oxygen preferences as a means to quantify the oxygen level of individual samples, assuming that the oxygen preferences of bacterial communities should, over time, reflect oxygen availability. In this way, microbes would be used as bioindicators of oxygen availability, as has been done previously for other important but hard-to-measure variables such as phosphorus availability (19), heavy metal contamination, and fecal contamination (20). Despite its importance, oxygen is notoriously hard to measure in environmental and host-associated samples due to a combination of methodological constraints and the fact that oxygen concentrations are often highly variable across space and time. Take, for example, soils, where oxygen concentrations can vary at the millimeter scale between oxic pore spaces and neighboring anoxic microsites in aggregates (21). Soil oxygen concentrations are also constantly in flux as oxygen is consumed by microbial respiration and supplied by diffusion from the atmosphere. However, understanding soil oxygen is important for understanding microbial ecology, soil health, and soil biogeochemical process rates (22, 23). As another example, measuring oxygen concentrations in vertebrate guts is notoriously challenging as sensors must be placed inside the individual (24). Yet understanding both human and non-human animal gut oxygen concentrations is crucial for understanding digestion, metabolism, and disease (25–27). Thus, it would be beneficial to infer relative oxygen levels in soils, vertebrate guts, and other environmental or host-associated samples directly from the ever-expanding metagenomic data sets now available. Here, we describe the development, validation, and application of the new tool OxyMetaG (Fig. 1). Our goal was to identify a narrow set of genes with high predictive power at the genome level and then use a read-mapping and abundance-ratio methodology to rapidly profile the raw reads of metagenomes, thereby avoiding the limitations of having to assemble high-quality genomes from metagenomes. After comprehensive validation using simulated metagenomes, we tested OxyMetaG on a wide variety of environmental and host-associated sample types that capture broad gradients in oxygen availability, including a subset of samples with measured oxygen concentrations. We then present two example case studies of how OxyMetaG can be used to answer ecological questions in one environmental system (surface soils) and one host-associated system (human guts). For surface soils, we demonstrate how OxyMetaG can be used to quantify continental-scale variation in predicted oxygen levels and the climate or edaphic variables associated with this variation. For human guts, we used metagenomic data from selected individuals sampled over time to quantify how predicted oxygen levels change during the first 3 years of life. Together, these examples demonstrate how OxyMetaG can be used to identify community-level shifts in bacterial oxygen preferences directly from metagenomic data and infer differences in oxygen availability within and across environments. Overview of the development and use of OxyMetaG. Twenty predictive bacterial Pfams were first selected using a genome-level ensemble machine learning model (random forest, CatBoost, and XGBoost) that utilized oxygen tolerance information from BacDive. Then, a relationship between the ratio of selected aerobic indicator genes (n = 13) and anaerobic indicator genes (n = 7) was built based on simulated metagenomes with varying levels of known aerobes and anaerobes. Finally, the tool was tested on 203 metagenomes from various habitats with known or inferred differences in oxygen levels, as well as on 331 surface soil metagenomes from Australia, 209 surface soil metagenomes from the United States, and 73 human gut metagenomes from Finland and Russia. The steps of extracting bacterial reads, running DIAMOND BLASTX, and predicting the percent oxygen level are implemented in the standalone Python package OxyMetaG, with the functions oxymetag extract, oxymetag profile, and oxymetag predict. RESULTS We identified a set of 20 genes that were highly predictive of bacterial oxygen tolerance, including 13 genes associated with aerobes and 7 genes associated with anaerobes (Table 1; Fig. S1). The classification model of oxygen tolerance using just those 20 genes had high precision, recall, and F1 score (Table 2), and this was true when tested on all taxa, the four main phyla (Pseudomonadota, Actinomycetota, Bacillota, and Bacteroidota) combined, on each of the main four phyla individually, and on all other rare phyla combined (Table S1). Accuracy per phylum was >85% for all 31 phyla, and >93% for 29 of 31 phyla (Table S2). TABLE 1The 20 Pfams selected for predicting the oxygen tolerance of individual isolates in BacDive, as well as the Pfam name, whether it is indicative of aerobic or anaerobic metabolism, the percent prevalence in 4,227 aerobic bacteria, the percent prevalence in 1,293 anaerobic bacteria, and the aggregated SHAP feature importance (FI) scorePfamNameOxygenAerobe prev.Anaerobe prev.FIPF00510Cytochrome c oxidase subunit IIIAerobic94.5812.220.155PF00296Luciferase-like monooxygenaseAerobic89.2113.920.060PF168702-Oxoglutarate dehydrogenase C-terminalAerobic96.5917.630.038PF00116Cytochrome c oxidase subunit II, periplasmic domainAerobic94.4214.230.038PF01521Iron-sulfur cluster biosynthesisAerobic98.7731.250.028PF05425Copper resistance protein DAerobic77.889.590.023PF17773UPF0176 acylphosphatase-like domainAerobic66.576.190.022PF00115Cytochrome c and quinol oxidase polypeptide IAerobic98.1123.280.020PF00916Sulfate permease familyAerobic90.5147.100.019PF08530X-Pro dipeptidyl-peptidase C-terminal non-catalytic domainAerobic54.6716.710.019PF01152Bacterial-like globinAerobic74.506.110.018PF05721Phytanoyl-CoA dioxygenase (PhyH)Aerobic60.702.240.017PF00042GlobinAerobic53.585.490.016PF01871AMMECR1Anaerobic3.3850.660.074PF10371EKRAnaerobic6.6065.820.058PF17910FeoB cytosolic helical domainAnaerobic10.3474.250.043PF02579Dinitrogenase iron-molybdenum cofactorAnaerobic7.5564.890.041PF13597Anaerobic ribonucleoside-triphosphate reductaseAnaerobic16.8788.860.032PF03063Prismane/CO dehydrogenase familyAnaerobic6.5368.990.028PF02906Iron-only hydrogenase large subunit, C-terminal domainAnaerobic1.1458.620.018 The 20 Pfams selected for predicting the oxygen tolerance of individual isolates in BacDive, as well as the Pfam name, whether it is indicative of aerobic or anaerobic metabolism, the percent prevalence in 4,227 aerobic bacteria, the percent prevalence in 1,293 anaerobic bacteria, and the aggregated SHAP feature importance (FI) score TABLE 2Ensemble model statistics on the 20% holdout test data setPrecisionRecallF1-scoreSupportAerobe0.970.980.97845Anaerobe0.920.900.91259Accuracy0.961,104Macro avg0.940.940.941,104Weighted avg0.960.960.961,104 Ensemble model statistics on the 20% holdout test data set In simulated metagenomes with known amounts of aerobic and anaerobic bacterial genomes, the ratio of the summed RPK abundance of the 13 aerobic indicator genes to the seven anaerobic indicator genes was well correlated with the percent of aerobic bacterial taxa, regardless of sequencing depth (Fig. S2). The relationship was non-linear, and a generalized additive model was fit to the data (F = 1605, R2 = 0.99, P < 0.001) that was then used to make oxygen level predictions on real metagenomes with unknown proportions of aerobic, anaerobic, and facultative bacteria. Additional simulations with known amounts of aerobic, anaerobic, and facultative taxa demonstrated how different combinations of those three types of bacteria impacted the predicted oxygen levels (Fig. 2). For example, a hypothetical case with 100% facultative taxa yielded an oxygen level of 64%. Oxygen level predictions of 100% or 0% (completely oxic or anoxic) were only achieved with 100% aerobic genomes or 100% anaerobic genomes, respectively. A simulation with 90% aerobic genomes and 10% facultative genomes demonstrated that the oxygen level prediction drops substantially from 100% down to 91%. The simulations also show the different ternary combinations that can lead to various intermediate oxygen level predictions. For example, there are seven ternary combinations that could yield a result of 80% oxygen level (e.g., 80% aerobes, 20% anaerobes, 0% facultative; 60% aerobes, 10% anaerobes, 30% facultative; Fig. 2). Ternary plot of predicted oxygen levels in simulated metagenomes with 66 different combinations of aerobe, anaerobe, and facultative taxa genomes at 10% intervals. The triangle axes are the percent (out of 500 genomes) of each type of genome that were used as inputs into simulated metagenomes. White text shows the exact outputs for each of the 66 combinations, while shading shows interpolated oxygen levels. To pinpoint the output of a specific ternary combination on the plot, readers are advised to draw imaginary lines according to the angle of the text in the axis labels (i.e., going diagonally down and to the right for aerobes, going diagonally up and to the right for facultative, and going straight across to the left for anaerobes); 100% and 0% oxygen levels indicate completely oxic and completely anoxic environments, respectively. The predicted oxygen levels closely matched the expected differences in oxygen availability across different habitat types. Samples from cattle rumen, human gut, and marine sediments had the lowest predicted oxygen levels, while surface ocean, grassland soil, and forest soil had significantly higher inferred oxygen levels (Tukey post hoc, P < 0.05; Fig. 3). Irrigated temperate cropland soils and tropical forest soils had lower predicted oxygen levels than any of the upland soil habitats, potentially reflecting greater soil moisture content and consequently lower oxygen concentrations in those soils. Furthermore, in the three data sets where metagenomic data were available with corresponding measurements of oxygen concentrations (Baltic Sea sediment, Black Sea water, and Lake Tanganyika water), the predicted oxygen levels increased with measured oxygen concentrations (Fig. 4). The results were similar when comparing the default cutoffs (percent identity ≥60, e-value <0.001, and bitscore ≥50) and more stringent cutoffs (percent identity ≥60, e-value <1e−10, bitscore ≥60, and amino acid alignment length ≥40) (Fig. S3). Predicted oxygen levels across 16 habitat types. The x-axis is sorted from left to right according to mean predicted percent oxygen levels, with 100% and 0% oxygen levels indicating completely oxic and completely anoxic environments, respectively. Different letters represent significant differences (Tukey post hoc, P < 0.05). Predicted oxygen levels significantly increased (a) with increasing ratio of oxygen to hydrogen sulfide across the Black Sea water depth gradient (GAM, P < 0.05), (b) with increasing oxygen levels across sediments from the Baltic Sea (linear regression, P < 0.05), and (c) in surface waters compared to deeper hypoxic waters in Lake Tanganyika (t-test, P < 0.05). Shown are a loess function in panel a, a linear model in panel b, and different letters representing a significant difference according to a t-test in panel c; 100% and 0% oxygen levels indicate completely oxic and completely anoxic environments, respectively. Next, we tested OxyMetaG across surface soils that are generally considered to be oxic but can have variable oxygen concentrations depending on moisture and texture, with some surface soils harboring anaerobes in microsites (21). Across 331 Australian soils, ranging from arid sites in western Australia to humid sites in Tasmania and northeastern Australia, the predicted oxygen levels ranged from 60% to 100% (mean = 95%, SD = 9%, median = 100%). The majority of these soils were dominated by aerobic bacteria, with 204 samples predicted to have oxygen levels of 100% (completely oxic) and 127 samples predicted to have some anaerobes and/or facultative taxa, resulting in predicted oxygen levels below 100%. Across 209 soils collected from 26 sites across the United States, ranging from tropical to subarctic climates, the predicted oxygen levels ranged from 40% to 100% (mean = 95%, SD = 10%, median = 100%). Similar to Australian soils, most U.S. soils were inferred to be completely oxic, with 145 samples predicted to be completely oxic (100% oxygen levels) and 64 samples predicted to have some anaerobes and/or facultative taxa, resulting in predicted oxygen levels below 100%. Ecosystem type significantly affected the predicted oxygen levels in Australia (ZIBR, P < 0.001) but not in the United States (ZIBR, P = 0.22) (Fig. 5). Climate class did not significantly affect the predicted oxygen levels in Australia (ZIBR, P = 0.13) or the United States (ZIBR, P = 0.96) (Fig. S4). As for continuous soil and climate variables, gravimetric water content was the only variable included in our models that was significantly associated with the predicted oxygen levels in both data sets (Table S3; Fig. S5). Sand content, organic carbon content, and mean annual temperature were also significantly associated with the predicted oxygen levels in the Australian data set (Table S3). Predicted oxygen levels across habitats in (a) Australia and (b) the United States. The x-axis within each panel is sorted from left to right by mean predicted percent oxygen levels. Insets show histograms; note the difference in axes scales between panels. Grassland, forest, and shrubland habitats were shared between the two datasets, while only Australia had dune samples, and only the United States had wetland samples. Habitat significantly affected the predicted oxygen level in Australia (ZIBR, P = 0.0002) but not in the United States (ZIBR, P = 0.22); 100% and 0% oxygen levels indicate completely oxic and completely anoxic environments, respectively. Finally, we tested OxyMetaG with metagenomes from the human gut, which is generally considered to be anoxic but can be oxic in the first few months of life (28). Across the 73 metagenomes tested, the predicted oxygen levels ranged from 0 (completely anoxic) to 61%. Predicted oxygen levels declined significantly with time after birth (LMER, χ² =18.9, P < 0.001), but there was considerable variation across individuals (Fig. 6), with the model including random slopes and intercepts for subject IDs significantly outperforming the model with only random intercepts (ANOVA, χ² = 7.3, P = 0.03). All individuals eventually had 0% predicted oxygen levels, indicative of complete anoxia by the later time points, but the time point at which this occurred varied, with one individual still having non-zero oxygen levels indicative of the presence of oxygen required to sustain aerobic bacterial growth, past day 600 (Fig. 6). Predicted oxygen levels over time across nine individuals from the DIABIMMUNE cohort study (29). The predicted oxygen level significantly decreased over time (LMER, χ² = 18.9, P < 0.001); 100% and 0% oxygen levels indicate completely oxic and completely anoxic environments, respectively. DISCUSSION We developed a metagenome-based tool, OxyMetaG, that uses a gene abundance ratio to infer oxygen levels on a scale from 0-100% in a wide variety of environmental samples. We identified 20 genes whose presence or absence could accurately predict whether a given bacterial taxon was aerobic or anaerobic across the majority of bacterial phyla (Fig. S1; Table S1). These 20 genes are typically involved in various pathways of aerobic or anaerobic metabolic processes or in free radical scavenging, with a subset of these genes (9 of 20) having also been identified as predictors of bacterial oxygen tolerance in previous studies (6, 12–14). The gene abundance ratio was strongly related to the relative abundance of known aerobic bacteria in simulated metagenomes (Fig. S2), while facultative taxa had intermediate abundance ratios and were indicative of intermediate oxygen levels (Fig. 2), demonstrating the predictive power and versatility of this metric. We first tested OxyMetaG on a diverse set of 203 terrestrial, aquatic, marine, and host-associated metagenomes. We then used OxyMetaG on 540 surface soils across two continents to investigate how the predicted oxygen levels vary across surface soil bacterial communities and on 73 infant to toddler-age human gut samples to investigate patterns in oxygen levels in the gut over time. OxyMetaG accurately captured expected differences in environmental oxygen levels, predicting a dominance of anaerobes in known hypoxic to anoxic environments such as cattle rumens, human guts, anaerobic digesters, and wetland sediments, and a dominance of aerobes in environments that we typically consider to be oxic, such as surface soils and surface marine and freshwater samples (Fig. 3). These results were similar to those obtained using other tools that rely on classifying individual genomes from those sample types (15, 16). One advantage of OxyMetaG compared to genome-based approaches is that it works on raw reads and does not require genome assembly, which can be a major limitation in many samples where obtaining metagenome-assembled genomes (MAGs) can be difficult or when the MAGs that are obtained only represent a fraction of the diversity (17). Furthermore, in metagenomes from the Black Sea, the Baltic Sea, and Lake Tanganyika, the inferred changes in oxygen levels within environments were well correlated with known oxygen gradients (30) (Fig. 4). Together, these validation tests demonstrated how the OxyMetaG output (predicted oxygen levels) can be used for broad comparisons among sample types as well as more specific comparisons within sample types collected across gradients. As a test case for demonstrating the utility of OxyMetaG for predicting oxygen levels across environmental gradients, we analyzed 540 metagenomes representing a broad range of soil types, habitat types, and climate conditions across Australia and the United States. Most samples (74%) across both data sets were predicted to have an oxygen level of 100% (fully oxic), suggesting that they are overwhelmingly dominated by aerobes. This result was driven by high ratios of the abundance of the aerobe indicator genes to anaerobe indicator genes, rather than the absence of anaerobe indicator genes (a minimum of 2 anaerobe indicator genes were detected in all samples). While these samples may in fact harbor a small proportion of anaerobic taxa, the high ratio (> 30) of aerobic indicator genes to anaerobic indicator genes in these samples suggests that any anaerobes may be relatively rare and temporally transient. We note that a gene ratio >30 is indicative of a 100% oxygen level based on simulations (Fig. S2). These results suggest that, despite the presence of anaerobic microsites, surface soils generally select for, and are dominated by, aerobic bacteria. Simulations with varying levels of known aerobes, anaerobes, and facultative taxa support this conclusion, as simulations with 90% aerobes and 10% anaerobes resulted in a predicted oxygen level of 82% and simulations with 90% aerobes and 10% facultative taxa resulted in a predicted oxygen level of 91% (Fig. 2). In line with predictions (21), soil moisture was the top variable associated with the predicted oxygen levels in both data sets (Table S3), with wetter soils having slower diffusion of atmospheric oxygen (Fig. S5). Still, the variation explained by soil moisture was low (Table S3), likely due to moisture being a single time-of-sampling measurement and the complexity of variables that influence soil oxygen availability. As a second test case for OxyMetaG, we analyzed 73 human gut metagenomes, focusing on individuals that were sampled repeatedly over their first 3 years of life. Prior work using 16S rRNA marker gene sequencing combined with trait databases (matched by genus and species name or with hidden state prediction algorithms) showed that the abundance-weighted mean oxygen tolerance decreased markedly from months 3 to 15 (28). The results from our metagenome-based approach generally support the idea of elevated oxygen availability in the gut during infancy (31), with a trend towards anaerobic dominance by year 3 that is likely driven by increases in Bifidobacterium and members of Bacillota such as Clostridiaceae (32, 33). Importantly, our data show a greater degree of variation than the prior work, likely due to the fact that OxyMetaG considers all bacterial reads, and the gene-abundance-based method does not rely on trait databases biased toward well-characterized taxa. One limitation of OxyMetaG is that we do not know the temporal scale that is integrated by our metagenome-based metrics. Standard metagenomic sequencing approaches do not discriminate between live and dead cells (34) nor do they capture variation in taxon-specific growth rates (35). Thus, OxyMetaG-based predictions of oxygen levels likely integrate over longer time periods that reflect both current conditions at the time of sampling and past conditions. This is beneficial in that OxyMetaG predictions are more representative of the sample history and general sample conditions, not just the single sampling moment, and the predictions are likely more robust to rapid variations in oxygen levels. The downside is that OxyMetaG would not be useful for studying changes in oxygen availability over short time scales, and the presence of stable relic DNA from a previous state could misrepresent current oxygen availability. Although we currently do not know the exact time period that is integrated, as this will depend on community turnover rates, future work could investigate the temporal changes in aerobe versus anaerobe ratios in communities sampled over time, where oxygen levels are experimentally manipulated. Another limitation of the gene-based approach of OxyMetaG is that the genes could potentially be involved in general stress responses (e.g., oxidative stress response). While this potential issue is likely mostly mitigated by summing the abundances of multiple genes, OxyMetaG results could be skewed in environments where oxygen is not the sole oxidizing agent. We have presented the results from OxyMetaG for a total of 816 modern metagenomic samples and expect OxyMetaG to be useful for inferring oxygen levels and answering ecological questions in more studies on modern metagenomes. Additionally, we also suggest that OxyMetaG could be useful in ancient metagenomic studies, where past oxygen levels are unknown and can only be inferred using geochemical proxies. OxyMetaG could be used in concert with other geochemical paleo-oxybarometers (36) for more robust inference about sample history. In a first pilot study on ancient metagenomes, OxyMetaG predictions were in line with isotopic data and helped identify two clusters of communities (aerobic and anaerobic) in subglacial lake samples from Antarctica (37). OxyMetaG could contribute to the toolkit of paleo-oxygen proxies in that it is universal (as long as the sample has bacterial reads) and does not need to be calibrated on each individual sample or sample type. However, OxyMetaG still requires further tuning and optimization to handle issues specific to ancient DNA analyses, such as DNA damage and shorter fragment lengths; such improvements will be released in future updates to OxyMetaG. We hope OxyMetaG is ultimately useful and contributes to a better understanding of both microbial ecology and environmental conditions in general. MATERIALS AND METHODS Our workflow consisted of first modeling oxygen tolerance at the genome level to identify key genes that are highly predictive of oxygen tolerance (“indicator genes”), then using simulated metagenomes with known percentages of aerobic bacteria to establish a relationship between the percentage of aerobic bacteria and the ratio of aerobic indicator genes to anaerobic indicator genes, and then testing with actual metagenomes both for validation and application (Fig. 1; Fig. S2). We first downloaded 5,520 bacterial genomes from 31 different phyla that had oxygen tolerance information available in BacDive in June 2025 (38) (Table S4; Fig. S6). Since our goal was to identify the most important genes associated with clearly aerobic and anaerobic bacteria, we only used taxa classified as “obligate aerobe” or “aerobe” (which we combined into an “aerobe” category), and “anaerobe” or “obligate anaerobe” (which we combined into an “anaerobe” category), and omitted taxa classified as “facultative aerobe,” “facultative anaerobe,” or “microaerophile.” However, taxa classified as “facultative aerobe” and “facultative anaerobe” were used in later simulations to test their impact on OxyMetaG output. There were 4,427 “aerobic” genomes, 1,293 “anaerobic” genomes, and 1,655 “facultative” genomes (1,586 “facultative anaerobe" and 69 “facultative aerobe” (Fig. S7). We acquired additional information about the genomes, including taxonomic information, by matching accessions to GTDB r226 (39). We used HMMER v3.4 (40) to annotate the genomes with the Pfam v37.3 database (41). We then used an ensemble machine learning approach to select the top 20 genes most predictive of oxygen tolerance. This approach uses CatBoost, XGBoost, and RandomForests, an 80:20 ratio of training to testing data, and SHAP scores to assess variable importance (42). After building the best model using all genes, the model was rerun with just the top 20 genes with the highest SHAP scores. The model with only 20 genes performed as well as the model with all genes, in terms of precision, recall, and F1-score (weighted averages all 0.96 for both models), identifying 13 genes associated with aerobes and 7 with anaerobes (Table 1; Fig. S1). The prevalence of the 13 aerobic indicator genes ranged from 54% to 99% in aerobic taxa and from 2% to 47% in anaerobic taxa, while the prevalence of the 7 anaerobic indicator genes ranged from 51% to 89% in anaerobic taxa and 1% to 17% in aerobic taxa (Table 1). Furthermore, the accuracy of the model was high even when tested on individual phyla (F1 >0.90). Tests were conducted on each of the four phyla with the most genomes (Pseudomonadota, Actinomycetota, Bacillota, and Bacteroidota), as well as on all of the remaining 27 phyla combined. Furthermore, the accuracy of the main model (trained using all phyla, tested using all phyla) was assessed for each phylum to quantify model performance per phylum. The scripts to implement our approach are publicly available on Zenodo (https://doi.org/10.5281/zenodo.18331946). We then used ART (43) to simulate metagenomes (Illumina, 150 bp) using 500 randomly selected genomes from the original set of 5,520 genomes. To test for any effect of sequencing depth, simulations were done using fold coverages of 0.5 and 2.5, which generated 5–8 million reads and 26–41 million reads, respectively, depending on the randomly selected subset of genomes used in the simulation. We used a gradient of 0%, 20%, 40%, 60%, 80%, and 100% of the genomes as aerobes. We used three replicates per aerobe percentage, with the specified number of aerobic and anaerobic genomes randomly selected from the available pool of 5,520 genomes. Reads were trimmed and quality filtered with Trimmomatic v0.39 to remove Illumina adapters and retain reads with Q ≥ 20 and length ≥100 bp (44). We then downloaded all of the reviewed protein sequences for each Pfam as a fasta file from the Pfam website, concatenated them into a single fasta file, and generated a DIAMOND database with DIAMOND v2.1.13 (45). We then used DIAMOND BLASTX to calculate the abundance of the 20 genes in the metagenomes. We retained hits with percent identity ≥60, e-value <0.001, and bitscore ≥50 (46). We then normalized by mean Pfam length (the mean length of the reviewed sequences of that Pfam) to calculate reads per kilobase (RPK) for each Pfam. We summed the RPK of the 13 aerobic genes and the 7 anaerobic genes and then calculated the aerobic: anaerobic gene RPK ratio. Because the relationship was nonlinear, we fit a generalized additive model (GAM) of the relationship between the percent aerobe genomes and the ratio (Fig. S2) using the mgcv R package (47). The model relationship was highly similar across the two sequencing depths tested (Fig. S2). To test the effects of the presence of facultative taxa and aid in the interpretation of the OxyMetaG output, we repeated the above simulation procedure, but with 66 ternary combinations of aerobe, anaerobe, and facultative taxa genomes at 10% intervals. The output predictions were interpolated with the geometry R package (48) and plotted with the ggtern R package (49) (Fig. 2). We then validated the model on 203 modern metagenomes that we expected to capture broad differences in oxygen concentrations, including a subset of samples with paired measurements of oxygen concentrations. The 203 metagenomes spanned 16 distinct environments, including cattle rumen (50), human gut (51), surface ocean water (top 5 m) (52), Black Sea water (surface and deep) (53), Baltic Sea sediment (0-2 cm below sea floor) (54), anaerobic sludge digester (publicly available but unpublished), wetland sediment (55), freshwater lake water (surface and >150 m deep) (30), surface soil (0-10 cm) from arid grasslands in Australia (56), surface soil (0-10 cm) from tropical forests in Panama (57), other soils ranging from 0 to 70 cm depth from temperate forests, grasslands, and meadows (58), and surface bulk and rhizosphere soil from maize crops (59). Approximately 15 samples were selected from each study (Table S5). For further validation, we conducted additional analyses on a subset of samples with measured gradients in oxygen concentrations. We compared 15 metagenomes from the Black Sea that spanned a depth profile from 50 m to 2,000 m, with measured oxygen and hydrogen sulfide concentrations (53), 15 metagenomes from Baltic Sea sediments that spanned dissolved oxygen levels from 0.13 to 12.45 mg L−1 (54), and 15 freshwater lake metagenomes ranging from 0 m to 1,200 m depth with oxygen saturation levels ranging from 1.3% to 91.4% (30). We downloaded raw metagenomic data from the NCBI SRA and trimmed and filtered the reads with Trimmomatic as above. Because not all of the 20 predictor Pfams are exclusive to bacteria, we extracted only bacterial reads from the metagenomes, as hits to archaeal or eukaryotic reads could introduce errors in our model. We used Kraken2 v2.1.3 with the “Standard” database (60) to classify all of the quality-filtered metagenomic reads and then KrakenTools (61) to extract only the bacterial reads from each metagenome. The number of bacterial reads per metagenome averaged 10.9 million, with only four samples below 256,000 reads. Then, as above, we used DIAMOND BLASTX to calculate the abundances of each Pfam and then calculated the RPK ratio of aerobic indicator genes to anaerobic indicator genes to predict the oxygen level in the sample. Predictions over 100% were set to 100%, predictions below 0% were set to 0%, and any ratios above 30 (the maximum value in simulations) were set to 100%, as simulations showed that ratios above 30 are a result of having 100% aerobes. OxyMetaG is implemented as a Python package with three main functions, one for each of the steps outlined above. The “extract” function is a wrapper for Kraken2 and KrakenTools, which together classify each read and then extract reads classified as bacterial. The ‘profile’ function takes the bacterial reads as input, runs DIAMOND BLASTX on the database of the 20 Pfams, and records the information about hits for each sample. Finally, the “predict” function takes the DIAMOND output files, filters them to the top significant hit per read, calculates the summed aerobic: anaerobic RPK ratio, and predicts the oxygen level using the GAM established with the simulated metagenomes. While we used cutoffs of percent identity ≥60, e-value <0.001, and bitscore ≥50, users can also specify their own percent identity, e-value, and bitscore cutoffs based on their specific data characteristics, such as read length, and desired balance in sensitivity and specificity (62). This mode also enables users to test for consistency of results across multiple tested cutoff values. To test the effect of sequencing depth on the predictions, we chose one oxic sample, one anoxic sample, and one mixed sample that each had high sequencing depth (>32 million reads per sample). We randomly subsampled each of the three metagenomes to 16 different sequencing depths (ranging from 0.001 to 32.768 million reads) and ran OxyMetaG separately at each sequencing depth. The predicted oxygen level stabilized at only 256,000 reads, demonstrating the utility of this method for analyzing metagenomes with relatively low sequencing depths that would preclude assembling genomes (Fig. S8). This was also the point at which there were anaerobic genes detected in the oxic sample, enabling the ratio to be calculated and the prediction to be made (Fig. S8). Therefore, we recommend a minimum of 256,000 reads for the most robust and consistent OxyMetaG results. Lower sequencing depths could lead to many of the indicator Pfams not being detected, even if they are actually present. Users are always encouraged to inspect how many aerobe and anaerobe indicators Pfams were detected in each sample, which is presented alongside the oxygen level prediction. After validation, we applied OxyMetaG on soil and human gut data sets to answer ecological questions in those systems. First, we used 331 surface soil (0–10 cm) metagenomes collected using standardized methodology from across Australia (56). These metagenomes have been previously used in other research (63) and were selected because they are from natural areas, have at least 10 million reads per metagenome, and have defined upland vegetation types. Quality-filtered shotgun metagenomes (150 bp) and metadata (Table S6) were downloaded from the Bioplatforms Australia data portal (https://data.bioplatforms.com/bpa/otu/metagenome). Mean annual precipitation and mean annual temperature were determined for each sample using the WorldClim2 database (64), and the aridity index was determined using the Global Aridity Database version 3 map at 30 arc-second resolution (65). The number of bacterial reads in these Australian metagenomes ranged from 3 to 19 million (mean = 7.9 million). For comparison and to include more humid sites, we used an additional, independent data set of 209 surface soil (0–30 cm) shotgun metagenomes (Table S7) collected by the National Ecological Observatory Network (NEON) using standardized methodology from 26 sites across the United States. We used samples collected in 2023 and sequenced at the U.S. Department of Energy Joint Genome Institute (JGI). Because OxyMetaG is assembly-free and does not require high sequencing depth (Fig. S8), we subsampled all metagenomes down to 5 million reads before running OxyMetaG to reduce computational costs. The number of bacterial reads ranged from ~1.1 to 2.2 million reads (mean = 1.7 million), which was enough to detect anaerobic indicator Pfams in all samples. Climate, soil, and other general metadata associated with each metagenome were downloaded using a combination of the phyloNEON R package (66) and neonUtilities R package (67). For statistical analyses, we converted the percent oxygen level values, which had a highly skewed distribution toward 100% values, to an inverse proportion oxygen level value for use as a response in zero-inflated beta regression (ZIBR), where the response must be bounded between 0 and 1 (68). Relationships between the inverse oxygen level and ecosystem type, climate class, and continuous climate (mean annual precipitation and temperature, aridity index) and soil variables (gravimetric water content, pH, total carbon, total nitrogen, carbon: nitrogen ratio, nitrate, phosphorus, and percent sand) were tested with ZIBR implemented in the gamlss R package (69). Models including each predictor variable were compared to a null model with the likelihood ratio test. Second, we used 73 human gut metagenomes from Russia and Finland collected with standardized methodology for the DIABIMMUNE cohort study (29). From all of the available metagenomes in the study, we selected metagenomes from nine individuals that were sampled across at least seven time points, had the first sample before the 93rd day of life (minimum days after birth was 43), and had a sampling time range of at least 634 days (maximum day after birth was 1,111) (Table S8). These metagenomes had an average of 1.5 million bacterial reads. We ran linear mixed effect regression (LMER) models in the lme4 R package (70) between predicted relative abundance of aerobic bacteria and days after birth. We compared two models with the “anova” function in R: one that only allowed random intercepts for each subject ID, and one that allowed random intercepts and slopes for each subject ID. This enabled us to assess the effect of time (days since birth) and subject ID on predicted oxygen levels. All downstream statistical and graphical analyses were performed in R 4.5.1 (71). Supplementary Material Reviewer comments