Clear Sky Science · en
Machine learning and the role of the vaginal and fecal microbiome in miscarriage: a matched case-control study
Why Tiny Organisms Matter in Pregnancy
Most people know that miscarriage is heartbreakingly common, but far fewer realize that the invisible life in and on our bodies might play a role. This study explores whether the communities of microbes in the vagina and gut, along with a common virus called HPV, can help explain why some pregnancies are lost while others continue. By combining microbial DNA data with computer models, the researchers ask a hopeful question: could we one day identify women at higher risk early enough to help them?

Looking Inside the Body’s Hidden Ecosystems
The team worked within a large Swedish pregnancy project where participants mailed in self-collected vaginal and stool samples and answered detailed online questionnaires early in pregnancy. Among hundreds of women, 79 later had a miscarriage; 34 of these had sent at least one microbiome sample before the loss, and 27 had provided both vaginal and fecal samples. Each miscarriage case was matched to women of similar age, body weight, and sampling time who later delivered at term, so that differences in microbes and background factors could be compared fairly.
The Vaginal Environment and Miscarriage Risk
In the vagina, communities of bacteria often group into recurring patterns known as “community state types.” Some are dominated by one species of Lactobacillus, while others are more mixed. The researchers found that women whose vaginal microbiome was dominated by less common Lactobacillus types (called CST-II) or by more diverse, less Lactobacillus-heavy communities (CST-IVB) early in pregnancy had a four- to six-fold higher chance of later miscarriage compared with women whose vagina was dominated by the typical Lactobacillus crispatus pattern (CST-I). Women infected with HPV types not covered by current vaccines also had about a four-fold higher miscarriage risk. By contrast, having regular menstrual cycles before pregnancy was linked with a lower risk.

The Gut Microbiome and a Role for Smart Algorithms
In the gut, the broad makeup of bacteria looked similar between women who miscarried and those who did not, at least by standard diversity measures. Yet more subtle patterns emerged when the researchers let machine learning algorithms sift through thousands of bacterial types together with questionnaire data. Several species from the bacterial class Clostridia in the gut repeatedly surfaced as important for distinguishing miscarriage cases from controls. When the team trained predictive models on different data sources separately, algorithms based on vaginal microbes, gut microbes, or questionnaire answers each reached performance levels that would be considered promising for a medical test. Combining the most informative features from all three sources produced a model that correctly separated many cases from controls, with high specificity (few false alarms) and good overall accuracy.
What the Numbers Can and Cannot Tell Us
Despite these encouraging signals, the authors stress that their study is still small, with only a few dozen miscarriage cases, which makes estimates uncertain. They could not account for whether the miscarriages were caused by chromosome problems, and some details about the exact timing of loss were missing. The women in this cohort were generally well educated and more likely to have a history of pregnancy complications than the general population, so the results may not apply everywhere. For now, the models are too complex and data-hungry for routine use in clinics, and microbiome testing itself remains expensive and technically demanding.
What This Means for Parents and Future Care
For lay readers, the take-home message is not that microbes “cause” miscarriage in a simple way, but that patterns in vaginal bacteria, gut bacteria, and HPV infection appear to be linked with risk. In particular, non-vaccine HPV types and certain less protective vaginal bacterial communities were associated with higher odds of miscarriage, while some gut bacteria and common health factors also contributed to risk profiles detected by machine learning. With larger and more diverse studies, these insights could guide new screening strategies and targeted treatments—such as better HPV prevention, or future microbiome-based therapies—to help protect pregnancies that might otherwise be lost.
Citation: Gudnadottir, U., Prast-Nielsen, S., Wagner, N. et al. Machine learning and the role of the vaginal and fecal microbiome in miscarriage: a matched case-control study. npj Biofilms Microbiomes 12, 66 (2026). https://doi.org/10.1038/s41522-026-00956-2
Keywords: miscarriage, vaginal microbiome, gut microbiome, HPV infection, machine learning