Early Diagnosis of Autism with Microbiome and Machine Learning
By: Mikey Taylor
Tags: Artificial Intelligence, Data Science, Technology, Science, Machine Learning

Early Diagnosis of Autism with Microbiome and Machine Learning

Building an autism diagnostic with gut microbiome data and machine learning

When I was around 8 years old, my cousin was diagnosed with autism.

I didn’t know much about autism at the time. To me, he was just a normal baby who wore diapers and cried.

However I do remember my parents saying how it was really good that my aunt and uncle “caught it early” — I think it was around his 1st birthday when he got the diagnosis.

I honestly didn’t think much of it when they said it. But recently, I’ve been thinking about it more.

A few things I’ve been thinking about: why was it good that they saw the signs early? What difference does it make? Why is it normally hard to diagnose autism? How can we fix this?

After finding the answers to these questions, I focused on ways to create earlier diagnostics and risk assessments for autism. Ultimately, I ended up making a machine learning algorithm to diagnose autism with gut microbiome data, which I’ll be explaining in this article :)

This article is broken down into 3 main sections:

Autism and Diagnosis The link between autism and the gut microbiome How I used machine learning on gut microbiome data

Autism and Diagnosis

According to the CDC, 1 in 54 children in America have autism spectrum disorder (ASD).

Autism is a neurodevelopmental disorder that impacts how one perceives and interacts with others and the environment, leading to problems in behavior and communication.

Autism is a spectrum

Like most disorders that affect the brain, there’s no one cause. Research suggests that autism develops from a combination of genetic and environmental factors.

These factors can increase the risk that a child will develop autism, which is not the same as the cause. For example, some gene changes associated with autism can also be found in people who don’t have the disorder. And autism affects children’s brains in several different ways — sometimes it’s individual brain cells, while other times it’s whole brain regions.

Given the heterogeneity of the disorder and the fact that it’s exhibited as a spectrum of closely related symptoms, autism can be very hard to accurately diagnose, especially at an early stage.

And it’s very important that autism be diagnosed as early in the child’s life as possible. Early intervention is imperative, largely due to a phenomenon known as neuroplasticity. Neuroplasticity is the brain’s ability to reorganize itself by forming new neural connections, called synapses, throughout life.

Neuroplasticity is exponentially higher in the early stages of development, which is why toddlers learn so quickly. Synapses aren’t actually significantly pruned, or eliminated, until around 4 years of age.

So, the earlier autism is diagnosed and thus treated, the more effective and long-lasting the effects are. Research has shown that if children get early intervention, it’s more likely that they won’t need intensive support in elementary school and beyond.

Essentially, early diagnosis of autism is a game changer for autistic children and their families. But again, it’s very difficult given its heterogeneity.

This is a problem I wanted to solve, and one place where I found a lot of opportunity was the gut microbiome.

The Link Between the Gut Microbiome and Autism

The gut microbiome is the collection of all of the microbes living in the gastrointestinal tract. Together, there are around 100 trillion (which oddly weigh as much as a mango).

Studies have actually found that gut microbiome composition is significantly correlated with a bunch of different diseases, like irritable bowel syndrome, obesity, diabetes and of interest to me, autism!

Research has shown that children with ASD have a mix of gut microbes that is distinct from that in children without the condition. As more research is conducted on this topic, more evidence bolsters the link between autism and the microbiome.

In fact, it was reported that germ-free mice — mice lacking the typical mix of gut microbes — avoided other mice, shunned new social situations and groomed themselves excessively. A few other notable (and totally mind-blowing) findings include:

Germ-free mice, given gut microbes from people with ASD, had offspring that socialized less and engaged in more repetitive behaviour. These mice also had lower levels of compounds produced by gut bacteria that affect brain function, particularly two metabolites known to increase activity of the brain’s γ-aminobutyric acid (GABA) receptors. Abnormalities in the GABA system have been noted in children with ASD. When the team gave the two missing metabolites to mice with autism-like symptoms, “they improved core deficits in social interaction and repetitive behaviour.”

These mice also had lower levels of compounds produced by gut bacteria that affect brain function, particularly two metabolites known to increase activity of the brain’s γ-aminobutyric acid (GABA) receptors. Abnormalities in the GABA system have been noted in children with ASD. When the team gave the two missing metabolites to mice with autism-like symptoms, “they improved core deficits in social interaction and repetitive behaviour.” Roughly 30–50% of all people with autism have chronic gastrointestinal problems, primarily constipation and/or diarrhea

primarily constipation and/or diarrhea In a study, children took a daily dose of microbes from people without ASD for 8 weeks. At two years post-treatment, most of the initial improvements in gut symptoms remained. In addition, parents reported a slow steady reduction of ASD symptoms during treatment and over the next two years. A professional evaluator found a 45% reduction in core ASD symptoms (language, social interaction and behavior) at two years post-treatment compared to before treatment began.

While there’s certainly a correlation, there’s still a lot of research to be done into the exact mechanisms by which gut microbes communicate with the brain, dubbed the microbiome-gut-brain axis.

The microbiome-gut-brain axis is the biochemical communication pathway between microbes in the gastrointestinal tract and the central nervous system, involving neural, immune and endocrine pathways. The axis is bidirectional, meaning that the brain can also affect gut microbiome composition itself.

Below is a schematic of the major ways by which gut microbes directly and indirectly communicate with the central nervous system:

Microbes interact with immune cells and cause them to release cytokines (signaling proteins secreted by cells of the immune system). The cytokines circulate from the blood to the brain. Microbes interact with enteroendochrine cells of the gut wall that produce neuroactive compounds. These compounds interact with the vagus nerve, the most complex cranial nerve in the human body, which sends signals to the brain. They interact with the vagus nerve via the enteric nervous system, a massive web spread over the entire digestive tract made up of more than 500 million neurons. An estimated 80 to 90 percent of the vagus nerve’s neurons transmit sensory information from the stomach and intestines to the brain. Microbes produce metabolites and neurotransmitters. These molecules circulate to the brain where some are small enough to enter through the blood-brain barrier. While this isn’t a direct pathway of communication, we have actually found human gut bacteria in brain tissue.

Another schematic from a similar study can be seen below:

More comprehensive microbiome-gut-brain axis

The proposed mechanisms by which bacteria access the brain and influence behavior in this diagram include:

Bacterial products that gain access to the brain via the bloodstream and the area postrema

Cytokine release from mucosal immune cells

Release of gut hormones such as serotonin, also known as 5‑hydroxytryptamine (5‑HT), from enteroendochrine cells

Afferent neural pathways, including the vagus nerve

Stress can influence the gut microbiome via the release of hormones and sympathetic neurotransmitters. Hormones like noradrenaline may influence bacterial gene expression or signaling between bacteria, changing gut microbiome composition and activity

When gut bacteria help to digest food, they generate a host of by-products that can affect thinking and behaviour. Clostridia bacterial pathogens, for instance, generate propionic acid in the gut — a short-chain fatty acid known to disrupt the production of neurotransmitters. Propionic acid also causes autism-like symptoms in rats, such as repetitive interests, unusual motor movements and atypical social interactions.

Additionally, when mice with an autism-like condition had lower levels of Bifidobacterium and Blautia gut bacteria, their guts made less tryptophan and bile acid — compounds needed to produce serotonin, a neurotransmitter which plays a role in mood regulation.

Machine Learning and Data Analysis for Diagnosis

Given the link between autism and the microbiome, I wanted to create a machine learning model to diagnose autism using gut microbiome data from subjects with and without ASD. And with the importance of early intervention that I previously discussed, the ultimate goal is to use such an algorithm for early risk assessment of autism.

Using 16S rRNA sequencing, around 150 genera of bacteria were measured in a stool sample from each subject in the dataset (n=40). The numerical abundances of each genera in subjects was found by using the SILVA database.

Principal Component Analysis

Before using machine learning, I wanted to visualize the data using principal component analysis (PCA) given the high-dimensionality of the data.

PCA is a technique used to reduce the dimensionality of data, increasing its interpretability while minimizing information loss. It accomplishes this by creating new, uncorrelated variables that maximize variance in the data.

In other words, it simplifies the complexity of data while retaining trends and patterns within it.

With Scikit-learn, I conducted a 2 component PCA, meaning I reduced the dataset to 2 dimensions. Some of my code can be seen below:

#Importing libraries

from sklearn.decomposition import PCA

from sklearn.preprocessing import StandardScaler #Scaling features

features = StandardScaler().fit_transform(features) #PCA

pca = PCA(n_components=2)

principalComponents = pca.fit_transform(features)

principalDf = pd.DataFrame(data=principalComponents, columns = ['Principal Component 1','Principal Component 2'])

Each subject in the dataset now has 2 variables (principal component 1 and principal component 2), which I then plotted:

The result is above. Each blue point is a subject with ASD, while each green point is a control subject. The difference between the groups can be seen clearly.

Random Forest Classifier

Given the smaller size of the dataset and task at hand, it made the most sense to use a random forest classifier (RFC) to predict autism. (Although I did benchmark it against other models like an SVM, neural network and k-nearest neighbors).

Before I go into what a random forest classifier is, we need to gain a basic understanding of decision trees.

At a high-level, decision trees classify data.

The decision tree above determines if a person is fit or unfit based on the particular person’s features. For example, the first node splits the person based on their age. This node is called the root node, although it’s ironically at the top of the tree.

As you can imagine, this decision tree could be organized in a variety of different ways. For example, “Exercises in the morning?” could be put in the position of “Age < 30?”

However, the reason “Age < 30?” is at the top is because it is the feature that splits the data into groups that are the most different from each other, in which the members of each group are the most similar to each other. In other words, it has the lowest Gini impurity.

Gini impurity is one way to assess how well a node separates classes, or how “impure” the node is:

Gini impurity formula

The formula can be seen above, in which (pi) is the probability of class i in a node. The lower the result, the better the node separates the data.

Using this formula, we can create a decision tree based on some data samples and features.

However, decision trees are only good at classifying data they have already seen before (which pretty much defeats the purpose). This is where the power of random forest comes in, combining the simplicity of decision trees with flexibility.

Random forest uses an ensemble of decision trees, therefore being considered a type of ensemble learning. Each decision tree is trained on a random subset of n features (with replacement). Most decision trees are thus not the same.

The most frequent prediction made by the decision trees, also called the mode or aggregate, is what a sample is classified as.

Decision tree vs. random forest

First, a bootstrapped dataset (the same size as the original) is created. To do this, we just randomly select samples from the original dataset (with replacement). Then, n random features from the dataset are selected to train the decision tree, the criterion being the Gini impurity.

This process is repeated until hundreds of decision trees are made, each using a bootstrapped dataset and random subset of features.

After the random forest is made, it can be used to classify samples it has not seen before. Whichever classification is made most often, perhaps “fit” or “unfit,” is the final classification. When we use the aggregate (most frequent classification) and bootstrap the data, it is called bagging, short for bootstrap-aggregation.

I used this technique to diagnose autism with the gut microbiome data, each feature being the relative abundance of all of the genera of bacteria measured. Some of my code can be seen below:

#Splitting data

x_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.2, random_state=42) #Scaling features

sc = StandardScaler()

x_train = sc.fit_transform(x_train)

x_test = sc.transform(x_test) #RFC

rfc = RandomForestClassifier(n_estimators=200)

rfc.fit(x_train, y_train)

pred_rfc = rfc.predict(x_test)

As can be seen above, the random forest I made has 200 decision trees. After hyperparameter tuning (specifically tuning the number of decision trees in the forest, the maximum depth of the trees, and the maximum amount of features), the result can be seen below:

The overall accuracy of the random forest classifier was 88%!

An advantage to using random forest is the interpretability of the model (in comparison to other models like neural networks). I was able to use Scikit-learn to actually print out what one of the decision trees in the forest looks like:

Each node determines the next node that the data will be passed to based on some threshold. For example, the node at the very top (root node) looks at the subject’s abundance of Veillonellaceae. If it is ≤ -0.2, then it will be passed to the left node, but if not, it will be passed to the leaf node on the right. Each leaf node classifies the subject as either autistic or not autistic.

The Future

In the future, I plan on contacting labs to aggregate more data to train machine learning models, as well as research the development of the gut microbiome.

In this way, I can figure out at what point in development it would make the most sense to sequence a baby’s gut microbiome for risk assessment of autism in its earliest stages, and hopefully other diseases as well!