Using genetic algorithms to manipulate DNA (experiment)

Daniel Bourke uses a genetic algorithm to evolve DNA sequences toward ATOH1, a gene critical for hearing. The algorithm finds the E-box motif CAGCTG in 36 generations, inspired by his friend's deaf newborn son Wilder, who will soon receive cochlear implants.
Chapters
Hey Google, 3-minute timer. Alright, 3 minutes starting now. As you probably gathered, your speakers aren't broken, but what I actually was saying at the start was, how would you describe sound to someone who's never heard before? Pretty difficult question. You got any ideas? Hey, How'd you get out there? Um, magic of cinematography. Let me show you what I've been up to. Whoa, look at that dude's hairdo. He looks like he just woke up. Oh yeah, that's right, 5:30 AM, me, groovy funky hairdo. But as you can see, I've been going through the Coursera bioinformatics specialization, which I've been loving. And just a heads up, Coursera are sponsoring this video, so Massive shout out to them. I absolutely love the platform. I plan on using it for, for a long time to come and have used it for a long time already. So if you want to check out the bioinformatics specialization— oh, big shout out to Dad, cheers for showing up to the video— or any other specialization that they offer in terms of health or computer science, I'll leave a link below. You can check them out. All right, back to bioinformatics. Most of my time has been spent inside Stepik, the interactive coding— I'm not sure what you actually call it, but it's like you can code, you can read, you can watch videos and stuff inside this platform, which is kind of like Coursera but a little external to Coursera. And just switching back and forth between there, VS Code, Jupyter Notebooks, and Stack Overflow, trying to solve these, these coding challenges that involve different sequences of DNA. And I failed the first quiz of week 1, I think once, or at least, yeah, at least once. But then you know the drill, if at first you fail, try again. Then I passed, 100% marks, oh yeah! And then I learned a lot about DNA, and I mean a lot. I watched several YouTube videos, and I found this one by Hank Green and Crash Course especially helpful. It's just beautiful, isn't it? It's, it's just, it's mesmerizing, it's, it's double heel exciting. And then I found out what the minimum skew is, spent much more time on Coursera. Again, minimum skew, by the way, is a section in bacterial DNA where the origin of— origin, I can't even say it, I've been studying it for the past few weeks— origin of replication is likely to occur. That means if a cell was to replicate, the sequence that initiates that replication will likely be around that minimum skew. But I'll leave a link below so you can research what that is. And again, spent much more time on Stack Overflow and the forums. I mean, this is what part of like working on a project is all about, is researching different ways to do it. And then I even had some marathon sessions where I was coding all the way from daylight into nighttime. You know when you're in the zone and you're just feeling the flow and riding the wave? I was riding the wave. Alright, so where we at now? Well, I've done a fair chunk of, of Part 1 of the Coursera Bioinformatics Specialization, but I wanted to start applying what I've learned. And the reason being is because I find I learn best when I've applied what I learned to something that's not exactly just continually going through coursework, like a real-life project. The thing is, I had no idea what I could apply it to, and so I did what I always do when I have no idea. I went for a walk. And so I'm trotting along the— my favorite place in the world, the Sandgate Waterfront, the 4017, and then I hit the tree. And then it hit me. Now you see, the thing about this tree, this one, where is it, right here, it's a pretty special tree. You know why? Because right there is where Dave told me that his partner, Talani, was pregnant. Wilder. Now continue the story. Alright, so who's Dave, Talani, and Wilder? Well, Dave's my best friend, Talani's his partner, and Wilder's their baby boy. Now you see, the reason why I asked you that question at the start of the video is how would you describe sound to someone who's never heard it before is because Wilder was born deaf. And now flashback to the start of the video where I was writing on the whiteboard early in the morning. That was a very special day because 3 down on that list, there was a line there that said, "Wilder's switch on at 9 AM." And what that means is we were going to— I was up so early because I wanted to study before going to the event where Wilder would have his cochlear implants turned on for the first time. So, that means he would be able to hear. That's what hit me when I walked past the tree is because that's where Dave told me about Wilder. And I wanted to see if I could apply what I'd been learning in bioinformatics to the DNA involved in hearing loss. So lying in bed that night, I was dreaming up different ways of doing it. As you saw, woke up the next morning and the first place I went to was the Cochlear Implant website. And here I found this really interesting diagram, and what that taught me is that hearing loss is usually due to the the fact that hair cells don't develop in the cochlea. What the hair cells do is they, they get sound waves and they transmute them into audio waves or electrical signals which the brain can recognize. And so I went to my friend Google: what gene is responsible for hair generation in the ear? And I found the ATOH1 gene. So naturally I went back to Google: what is the ATOH1 gene. And then I found a site with a whole bunch of fascinating stuff about genomes and genetics and whatnot, but a lot of it I didn't understand. So I went back to the, the previous page, and then for some reason I recognized the word FASTA, the acronym FASTA, F-A-S-T-A. Maybe I'd seen it before in some of the bioinformatics lectures. And then I found something I had seen before, a whole heap of A, C, Gs, and Ts. And these are nucleotides, and these are, these are what make up DNA. And so I thought, could I apply what I had done to Salmonella in the bioinformatics specialization, aka finding the DNA A box, which we look up on Google. DNA A box. What is a DNA A box? So the binding of DNA A protein to its DNA sites, binding sites, DNA A boxes in the chromosomal ORC, so origin of replication, is essential for initiation of chromosome replication, right? So it's very important for, for chromosome replication. Now I wanted to try and find the same part, so the DNA A box, in the new sequence that I had found, this one here. And well, I did. And it worked, but it turns out ATOH1 has an E-box rather than a DNA A-box. So I changed the parameters of my algorithms, and it turns out, well, it still worked. And so, now what? Well, genetic algorithms, of course. Alexa, 100-minute timer. 1 hour and 40 minutes, starting now. All right, so why a genetic algorithm? I'd heard of genetic algorithms before, but I'd never really used one, and I figured I was working with genes, why not try a genetic algorithm? Because I wanted to see if I could evolve from a random set of nucleotides, A, C, G, and T, to find the ideal sequence, the E-box, which we found before, the C-A-G-C-T-G sequence. And now, what is a genetic algorithm? What is a genetic algorithm? Well, according to Wikipedia, genetic algorithm is a computer science algorithm which aims to mimic the biological phenomena of natural selection. And now I need a genetic algorithm for my problem, which was working with strings and trying to find the ideal string, the C-A-G-C-T-G. So I went back to Google, genetic algorithm, algorithm for strings. And then I found this site where the code seemed pretty clean, and so I changed it from Python 2 to Python 3 and adjusted it for my DNA strings problem. Where the example that I, I used wanted to find any character, I only wanted to find A, C, G, T, or N, N being a wildcard. So how does the genetic algorithm work? Well, at a high level, you start with a random population of A's, C's, G's, and T's, and then you combine them by slicing them in half and adding them together. And then strings closest to the ideal string are given a fitness score, and those with a higher fitness score are more likely to make it to the next generation. And what this means is that after a certain number of generations, we should have our optimal string. All right, let's see if this code runs. I've got all that stuff that I just talked about, the genetic algorithm, lined up, ready to go. We're going to run it for 100 generations, and if it works— it does work, all right, I've already checked it— if it works, we should get a little surprise. You ready? Count down with me. 5, wow, 4, 3, 2, 1. Boom. Take 2. Just trust me that generations equals 100. We've got it, we've got it set up here as a global variable. Uh, generations. Boom. Okay, let's go. Once it matches up with the e-box situation, e-box sequence, a little surprise should happen. "I am your father." Boom! Yes! Let's see that again. "I am your father." Yeah! Alright, so what is actually happening there? We have this running through, the genetic algorithm starts with a random sequence of As, Cs, Gs, and Ts, and then it eventually finds the optimal sequence of CAGCTG after 36 generations and then plays a YouTube clip of— I am your father. Once the ideal sequence gets lined up, it plays a YouTube clip of Dave saying "DeWilder" for the first time. Time that I am your father. That's worthy of a dance. Future Dan, play that groovy track again. We did it! We did it! Okay, well yeah, I only really found 6 characters, so it's not too hard to find after 29 or so generations. What happens if I wanted to find the whole sequence of ATOH1 gene? I tried it for 100,000 generations. It took 45 minutes and the fitness score barely improved. Um, so the ideal fitness score would be 0. Maybe there's a better way to do it. I haven't figured it out yet. I'll put this code on GitHub. If you work out a better way of how to do it, let me know. Let's wrap this thing up. Most of what you've seen in this video has been branched off from what I've been learning in the, the Coursera Bioinformatics Specialization, and they've been so kind to, to sponsor this video. So if you want to check out anything that I've been learning, especially the Bioinformatics Specialization or any of other Coursera's amazing health or technology courses, check out the links below. Now, if you remember at the start of this video, I asked the question, "How would you describe sound to someone who's never heard before?" And I don't think we've done anything to actually answer that question. But thankfully, thanks to technology, Wilder has the rest of his life to try and answer it for himself. Keep learning. You are my sunshine on a rainy day. You are the one who takes my breath away. In the vast skies of love, I'm free.
More from Daniel

Small Language Models (SLMs) Are the Future: Fine-Tuning AI That Runs on Your iPhone

Introducing Sunny - A MedGemma-Powered Skin Health Tracking App (Kaggle Competition Entry)

Benchmarking: NVIDIA DGX Spark & NVIDIA RTX 4090 | Part 4 - Comparing the results

Benchmarking: NVIDIA DGX Spark & NVIDIA RTX 4090 | Part 3 - Running LLMs on the RTX 4090

Benchmarking: NVIDIA DGX Spark & NVIDIA RTX 4090 | Part 2 - Formalizing the tests

Benchmarking: NVIDIA DGX Spark & NVIDIA RTX 4090 | Part 1 - Creating a series of tests

Local Multimodal RAG on the NVIDIA DGX Spark | Part 4 - Publishing our demo to Hugging Face

Local Multimodal RAG on the NVIDIA DGX Spark | Part 3 - Putting it all together


