Latest / Talk Python To Me / #237: A gut feeling about Python
Transcript
- 0:00Let's start this episode with a philosophical question.
- 0:03Are you human? Are you sure?
- 0:05We could begin to answer that question physically.
- 0:08Are you made up of cells that would typically be considered as belonging to the human body?
- 0:13It turns out the answer is, maybe.
- 0:16We have many ecosystems within us.
- 0:19Understanding them is essential to our own well-being.
- 0:22In this episode, you'll meet Sebastian Proust,
- 0:24who is using Python to study the bacteria in our world.
- 0:29This is Talk Python To Me, episode 237, recorded September 27th, 2019.
- 0:34Welcome to Talk Python To Me, a weekly podcast on Python,
- 0:51the language, the libraries, the ecosystem, and the personalities.
- 0:54This is your host, Michael Kennedy.
- 0:56Follow me on Twitter, where I'm @mkennedy.
- 0:58Keep up with the show and listen to past episodes at talkpython.fm,
- 1:01and follow the show on Twitter via at Talk Python.
- 1:04This episode is brought to you by Linode and Tidelift.
- 1:07Please check out what they're offering during their segments.
- 1:09It really helps support the show.
- 1:11Hey, folks, I want to tell you about a new course that we just launched over at Talk Python Training.
- 1:16This course lets you create web apps with pure Python.
- 1:20Now, you may be thinking, sure, I can use Flask and create web apps with pure Python now.
- 1:25No, I mean on the browser as well as on the back end.
- 1:30This course is about the Anvil platform, and the course is called Anvil Web Apps with nothing but Python.
- 1:35What's really cool is, yes, you have a back end.
- 1:37You can write Python code there, and that's cool.
- 1:39They manage the database.
- 1:41But also, they've set it up so you can write Python code and use a visual designer with events on the front end to create a single page app or a spa and write it entirely in Python.
- 1:53So if all the different technologies involved in building web apps are overwhelming to you, but you still need to build a web app, check out this course.
- 2:00It's a five-hour course, and it's even free.
- 2:02Just visit talkpython.fm/Anvil dash course, and it'll take you right there.
- 2:07Log in, click join this course, and you got it.
- 2:10Now let's get to that interview.
- 2:12Sebastian, welcome to Talk Python To Me.
- 2:14Hi, Michael.
- 2:15Thanks for having me.
- 2:16It's great to have you here.
- 2:17It's an honor.
- 2:17We're going to have so much fun talking about some very small things that have maybe a big impact on our world.
- 2:25Exactly, yeah.
- 2:26So we're going to talk about studying bacteria and communities of bacteria using Python, which is going to be fascinating.
- 2:33But before we get to that, let's start with your story.
- 2:35How did you get into programming in Python?
- 2:37So I actually got into programming about 20-something years ago.
- 2:40I was 12, and my favorite game was Quake at the time.
- 2:45And apart from the actual game, I also had a disk with all kinds of modifications.
- 2:49And on there was the source code for the game logic that you need to make your own modification and the QuakeC compiler.
- 2:58Now, the cool thing with QuakeC is that you can actually decompile the code from other modifications to readable code.
- 3:08So I was just like decompiling stuff I liked, trying to figure out how it worked, and then trying to basically come up with my own stuff.
- 3:16And I never really succeeded into making like the decisive version of Quake, but I did get a pretty good understanding of what's a function, what's a for loop, what's an if statement.
- 3:27So I really learned programming through that medium.
- 3:30I used to play Quake and Doom, and those were fun games.
- 3:34And I remember the mods.
- 3:35I think it was not Quake, but Doom, which was by the same software.
- 3:42It was the predecessor, right?
- 3:44Yeah.
- 3:44And you could change things up.
- 3:46I remember one we had was a Barney mod.
- 3:49Do you know Barney, the weird purple dinosaur?
- 3:54Yeah.
- 3:54It would replace all the characters with this dinosaur thing and different dinosaurs, and they made weird noises, and it was amazing.
- 4:02There was another one where it had these super scary creatures, and a friend of mine was playing it, and it was dark.
- 4:08And I spooked him from behind, right?
- 4:10As this creature from this mod came out, he got so scared, he ripped the keyboard drawer off of my desk.
- 4:16I thought, oh my gosh, I should have.
- 4:18It was just totally frightening.
- 4:19It was so, so funny.
- 4:20I really enjoyed those mods.
- 4:22Those are great.
- 4:23It's a really cool way to learn programming.
- 4:24Yeah.
- 4:25I had like a whole bunch of them, and some were like tiny.
- 4:27They were just like a secondary fire for one of the guns.
- 4:30Yeah.
- 4:31I was just looking for a way to combine them, because you could only load one at a time,
- 4:36and I wanted to have multiple running at the same time.
- 4:38And so after I played around with QuakeC for a while, I did pick up some proper programming languages through high school.
- 4:45But then ultimately, I went on and studied biology.
- 4:49I always was a bit in doubt whether it was the right choice or not.
- 4:52At the end of my biology degree, I noticed that there's something like bioinformatics.
- 4:56I was like, oh, that's great.
- 4:58It allows me to kind of combine the best of both worlds.
- 5:01And I started a PhD in bioinformatics.
- 5:03Now, at the time, we were using like a combination of Perl with some Java applets for our web stuff.
- 5:11There was also PHP in there.
- 5:13So it was kind of like...
- 5:15Early days.
- 5:16Yeah.
- 5:16It was kind of like a whole bunch of things glued together.
- 5:18So a couple of years later, when I had the opportunity to start like a new platform, I thought like, okay, I want to stick with like one language for the backend, one for the frontend.
- 5:28And that's how I basically discovered Python and Flask.
- 5:32Okay.
- 5:33And you haven't looked back ever since.
- 5:35It's just such a convenient way to develop things.
- 5:37Yeah.
- 5:38I got to think that the relevance of Python to biology is even more significant now than it was back then with all the data science developments and the other extra packages getting developed and all.
- 5:50Sure.
- 5:50So in the beginning, bioinformatics was really fueled by Perl.
- 5:54And just over the course of a couple of years, this has been completely taken over by Python.
- 6:00Yeah.
- 6:00I can imagine.
- 6:01Is it a lot?
- 6:02What kind of data files and stuff are you working with?
- 6:05Is it, you know, I imagine like a lot of, you know, genetic sequence character strings or like what kind of stuff are you working with when you're doing bioinformatics?
- 6:15Right.
- 6:15So this really is dependent on what field you're in.
- 6:17In my case, it's mostly sequence information.
- 6:19So that can be either raw sequences that come from a machine.
- 6:24So those are very, very short reads, about 20 to a couple hundred nucleotides and the quality scores for each of them, like how reliable they have been sequenced.
- 6:33Or it can also be like a full genome sequence, which is just a string of several millions of characters.
- 6:40Right.
- 6:41A lot of ACT and G in there.
- 6:42But they're like bioinformatics is a very, very broad field.
- 6:45So there are people that are doing completely different things with other types of data.
- 6:49If you look at metabolite data, those are like the chemical compounds that appear in a certain sample.
- 6:55That's a very different type of data entirely.
- 6:58Okay.
- 6:58It's super interesting.
- 6:59It sounds like a fun place to be working for sure.
- 7:02Biology is super cool.
- 7:03Now let's talk a little bit just at large about communities of bacteria.
- 7:08Because as humans, a lot of people are kind of creeped out by bacteria.
- 7:13The thought of like there's something on my finger or worse, if I go to like a school and I touch the handle to the door, you know, what other stuff came off of other people, you know, sniffly kids or whatever.
- 7:28Now I have this bacteria on me and probably it's actually viruses you care about, but whatever, right?
- 7:33People are freaked out about it.
- 7:34But it's a much more common and actually important part of life for all creatures, including humans, right?
- 7:42Like there's a really interesting TED talk, which I'll link to from your boss.
- 7:47And he starts the TED talk with something like, so you think you're a human, huh?
- 7:52Yes.
- 7:52So I might have to creep those people that are afraid of bacteria out a little bit more because basically for every cell that makes up your body, there is a bacteria somewhere on or in your body.
- 8:05And if you look at your genetic information, the number of genes that you have compared to the total number of genes those bacteria have, that's like almost a hundred fold higher for bacteria.
- 8:16Wow.
- 8:17So there's a hundred times more genetic information of bacteria on us.
- 8:21And we're about 50-50 in, maybe not in mass, but in terms of number of cells.
- 8:27Just half bacteria, half human cells.
- 8:30Exactly.
- 8:31That's going to take a moment to sink in.
- 8:33Now, I kind of knew that, but there's another stat that you threw out there that just numbers, I think this is an interesting topic partly because these numbers are so big and the things are so small that it's hard to have a concept around it.
- 8:46It's hard to conceptualize it.
- 8:48So you said that if you get, say, a gram of soil, that a gram, I mean, that's like tiny, right?
- 8:56Like a little sugar cube size bit of soil that has up to a billion bacteria in it.
- 9:03Just that little square, right?
- 9:04Yes.
- 9:05So it's like a very, very minute amount of material.
- 9:09And there's like a ton of bacteria in there.
- 9:11And if you look at the complexity or the number of different species in that sample, that's stellar.
- 9:17Like in that single gram of soil, you could easily have like 10,000 different kinds of bacteria.
- 9:22So it's a very, very complex environment.
- 9:24And that interacts really with, in case of soil, the roots of plants, right?
- 9:29On our body, there are so many different bacteria on our skin, but also on the inside in our gut.
- 9:35And they actually affect us.
- 9:37And it could be bad, but a lot of times it could be good, right?
- 9:40Like the bacteria in your gut has a lot to do with your health.
- 9:44You know, you hear about people taking antibiotics and it like killing out some of that stuff in their stomach.
- 9:50And they're not as healthy necessarily because of that, right?
- 9:53So yeah, it's crazy.
- 9:55We actually tend to think of bacteria as something that causes disease, that causes inflammation and infections, right?
- 10:02But a lot of bacteria can do exactly the opposite thing.
- 10:05A lot of the bacteria that are living kind of like as our symbionts, really,
- 10:10they're essential for our health.
- 10:11So they can really improve our quality of life.
- 10:14Right.
- 10:14Maybe they help you with digestion, like certain types of proteins or things can be broken down because they're there, right?
- 10:21Yeah, I can imagine so.
- 10:22So I'm mostly on like the computational part.
- 10:25So I'm not like microbiologist.
- 10:27So that's a bit farther off what I'm doing.
- 10:30Yeah, yeah, sure.
- 10:30But yeah, so there are tons of bacteria that are actually beneficial for us as well.
- 10:34So we really need them as much as they need us.
- 10:37Yeah, I think at least in the US, there's been a trend against things like antibacterial soap and stuff like that that tries to completely kill off bacteria.
- 10:45I think as much as it might creep people out, I think there's a realization that bacteria are important.
- 10:49Yeah, I think that's true, right?
- 10:52Like if you take antibiotics, you're killing off the bad guys.
- 10:54But if it's a broad spectrum of antibiotics, you're also killing some of like the healthy bacteria, the ones that you do need.
- 11:00And that actually has a long lasting effect on your microbiomes.
- 11:04It takes a while to recover from that.
- 11:06So people are really looking into like kind of like better ways to treat these infections.
- 11:11Yeah, for sure.
- 11:12So we had this quote or this number that there's a billion bacteria in a gram of soil and there's 10,000 different kinds of bacteria.
- 11:24So how do you come up with that?
- 11:26Do you like train grad students to recognize bacteria and they take notes?
- 11:30And they spin around.
- 11:31How do you come up with that number?
- 11:33It can't be counting it, right?
- 11:34Yeah.
- 11:35Usually when I tell people, like we look at the amount of bacteria and which bacteria are in like different samples,
- 11:40they think of me hunched over a microscope and just counting what I see.
- 11:44It doesn't quite work like that.
- 11:46So all bacteria in their DNA have like a small part.
- 11:51And it's kind of like similar enough that we can pick it up and copy it from all those different species of bacteria.
- 11:57But it's different enough that we can actually identify them to some extent.
- 12:02So there are like tiny differences in that sequence.
- 12:05And that allow us to kind of like see like, okay, this read is different from that.
- 12:08So what we do is we basically take the DNA, copy over that one part a bunch of times, and then sequence all the DNA in those copies.
- 12:18And it allows us to kind of like look in databases, like which part matches which bacteria.
- 12:23And we get more reads from one specific bacteria, then we know, okay, there's probably more of them in the sample than from another one where we see fewer reads.
- 12:31Right.
- 12:32You just basically count the number of matches of that species' DNA.
- 12:36And you say, well, that must be roughly representative of its ratio in the general population.
- 12:41Exactly right.
- 12:41But this is kind of like a fingerprint, if you want.
- 12:44So it tells us that certain bacteria with that sequence is in the sample, but it doesn't tell us all that much about the sequence, about the bacteria that we're looking at.
- 12:54There's also like a more modern version, if you want, where we really try to go in and sequence everything, all the genetic information in the sample.
- 13:01And that gives us much more detail about what those bacteria can do, because we get the full genome information for at least some of them.
- 13:08But for now, our research is mostly based on the fingerprint sequencing.
- 13:14Sure.
- 13:15So something I've always wondered about, just sequencing DNA in general, is you've got so many cells mixed in there.
- 13:22And especially in this case, you've got different species mixed in there.
- 13:25Like, how do you know that this part is all one species?
- 13:29How do you separate that?
- 13:31How does it not just look like a giant scramble of, you know, if everyone in a room took their name and put them into letters and just threw that into a bucket?
- 13:39Like, how do you know which goes right back to which, right?
- 13:43How does that happen?
- 13:44In case for the sequencing, the omplicon sequencing, it's kind of like built in the design that's designed to deal with that kind of information.
- 13:51If you really take like everything, then you need to sequence pretty deep.
- 13:56There's like some overlapping parts in there, and it allows you to assemble different genomes.
- 14:00But there are like other techniques that people use as well, looking at the number of times you see a certain copy, because that means that it needs to be from a bacteria that's equally abundant, give or take.
- 14:12Right?
- 14:13So that allows people to link certain parts together.
- 14:17But that's not something I've actively done myself yet.
- 14:20Sure.
- 14:21So I might actually be giving wrong information here to be a bit careful.
- 14:25Yeah, no worries.
- 14:26It just seems super interesting to me that we're able to do that with such certainty and accuracy, given like how messy that it seems, you know?
- 14:35So it's, I don't know, there's a lot about science.
- 14:37It's pretty amazing.
- 14:37Yes, absolutely.
- 14:38For sure.
- 14:39Let's go with the fingerprint side of things that you've been working on most recently.
- 14:43You've got some soil or some other area that you've gotten this bacteria from.
- 14:49You've done the sequencing.
- 14:50You have these ratios of different fingerprints.
- 14:52This is probably where you start using some Python to answer some questions, right?
- 14:57Exactly, right.
- 14:58So at that point, let's say you have about like a thousand different samples and you get like the relative abundance of 10,000, 20,000 different bacteria across all those samples.
- 15:08Then you need to start using Python or some other framework to make sense out of it.
- 15:13So normally, you should collect metadata for all your samples.
- 15:17So that describes how a sample was collected, right?
- 15:22So for soil, you might want to get the parameters of that soil, like the pH, nutrients that are in there, the place where you sample it, how much water is in there, right?
- 15:33If it's from a human, you might want to ask them some medical questions.
- 15:37You might want to get some information about their age, their body mass index, stuff like that, right?
- 15:43And you need to really pull all those things together to get some new insights in biology, microbiology.
- 15:50And to do that, Python is a great platform.
- 15:53Sure it is.
- 15:53That's awesome.
- 15:54So are there like packages or libraries specifically built to address those types of questions?
- 16:00There are some packages specifically for microbiology.
- 16:04I think Chime is one that's called.
- 16:06Also, Pandas, NumPy, like your traditional data science packages work really well for these kinds of questions.
- 16:13So yeah, if I need to do some very specific analysis, I like to fire up Jupyter notebook and just load everything in a data frame and start working with that.
- 16:23Yeah.
- 16:23Yeah.
- 16:24The problem is that's like your farther you are in your analysis, the more and more in-depth knowledge you need to have about microbiology or the specific environment you're looking at.
- 16:34And very often the biologists that have that knowledge, they don't have the computer skills to kind of like make sense of the ginormous matrix of abundances combined with metadata.
- 16:45And so what I try to do is actually develop a platform where we can upload those matrices with all the abundances.
- 16:53And then there's an interface hooked up to it that allows people without like the bioinformatic skills to just to also make sense from that data.
- 17:01How do they do it?
- 17:02Is that visually with like graphs and pictures or like heat maps or is that like CSVs and drop down into Excel or what do you end up giving them?
- 17:12So it's kind of like a combination of all of those things, right?
- 17:15So on the front page, there will be like a search button, very similar to what you will find on Google, right?
- 17:21So where you can just type the name of their favorite bacteria and just see how abundant it is across the different samples.
- 17:27And you can group samples based on different things in the metadata.
- 17:31There are also different tools that allow you to visualize bacteria that are very often found together in samples as a network.
- 17:40So that's an interactive people can drag and drop things, color code the nodes or the edges based on the properties that they want.
- 17:46And this is all a combination of basically Flask and Python in the backend and then some JavaScript on the front end.
- 17:53So it's all like online that they can basically use their browser as an interface to the data.
- 18:01This portion of Talk Python To Me is brought to you by Linode.
- 18:04Are you looking for hosting that's fast, simple, and incredibly affordable?
- 18:08Well, look past that bookstore and check out Linode at talkpython.fm/Linode.
- 18:13That's L-I-N-O-D-E.
- 18:15Plans start at just $5 a month for a dedicated server with a gig of RAM.
- 18:19They have 10 data centers across the globe.
- 18:21So no matter where you are or where your users are, there's a data center for you.
- 18:25Whether you want to run a Python web app, host a private Git server, or just a file server, you'll get native SSDs on all the machines, a newly upgraded 200 gigabit network, 24-7 friendly support, even on holidays, and a seven-day money-back guarantee.
- 18:40Need a little help with your infrastructure?
- 18:41They even offer professional services to help you with architecture, migrations, and more.
- 18:46Do you want a dedicated server for free for the next four months?
- 18:49Just visit talkpython.fm/Linode.
- 18:52Is this the thing called MetaConnect that you built?
- 18:57Exactly, yes.
- 18:57So it's not published yet, so it's not out there for people to look at, but I hope to get that done soon.
- 19:04Nice.
- 19:04So this is a website that you just described, written in Python and Flask.
- 19:08Is it tied to your university work or a company you work with?
- 19:13Or is this something that's open source and that's going to be coming out?
- 19:16Or what's its status?
- 19:17Initially, I created the website as a way to communicate results back to one of the companies for whom I'm analyzing data.
- 19:25So I quickly realized, like, okay, I can process all the data, but I'm not an expert in the field that they're active in.
- 19:31So I'm going to need some way to get the data to them in a way that's useful for them, right?
- 19:37So that's how it started, but we have lots and lots of different projects, also academic ones in the group.
- 19:44And one of them is the Flemish gut flora project, where we're trying to get, like, an impression of the bacteria that are resident in the gut of humans, mostly within the Flemish population.
- 19:57So Flanders is like the north part of Belgium.
- 20:00Yeah. So would you say that that is the most important or the most influential bacterial community that humans interact with or affect humans?
- 20:12Like, I mean, there's bacteria in our skin, it's in our hair, all over, and so on.
- 20:17But our stomach probably has a bigger effect than others.
- 20:21Well, there are quite a lot of bacteria in there, right?
- 20:23So if you take a stool sample, there's somewhere between a billion and a trillion bacteria in there, so even more than soil.
- 20:30And there are already some associations that we know of of those bacteria with our well-being.
- 20:37So a colleague of mine recently published an article where she could demonstrate that there's a link between some of the bacteria in your gut and your mental well-being.
- 20:46So we could see that some bacteria are less frequent in people that are actually struggling with mental problems.
- 20:52And there are associations with all kinds of diseases.
- 20:55Think about, like, irritable bowel syndrome and stuff like that.
- 20:59Wow. So this Flemish gut flora project is just collecting all of this data.
- 21:04And then do you guys use a similar analysis project and similar tools to study it, or is it different?
- 21:11A lot of the methods between studying something like soil samples and human samples are similar, right?
- 21:17So basically, you identify what's in there through sequencing.
- 21:20And then once you have sequences, the pipelines are very, very similar.
- 21:25We use, so there's not really a big difference between the methods that we use.
- 21:29Just the microbiology and the conclusions and all that, totally different, possibly, but not the way you get the frequency diagram or whatever it is.
- 21:38The biggest differences are in how the things are sampled and how the samples are processed, right?
- 21:45So once it's turned into sequences, then it kind of all becomes bytes.
- 21:48And then we start using some very similar workflows for different kinds of samples, yeah.
- 21:53Yeah. What's that workflow look like?
- 21:54It sounds like, you know, if you have 10,000 samples, that's a lot of work.
- 21:59It sounds like that needs some kind of automation.
- 22:01To some extent, yes, right?
- 22:02But of course, the work in the lab that precedes the analysis, that's something that has to happen to some extent manual.
- 22:09That's just a lot of hard work, right?
- 22:11Exactly, right.
- 22:11So there's like a whole logistics part before what I actually do.
- 22:16That's just a ton of work.
- 22:18And fortunately, we have some very talented lab technicians that take care of this process.
- 22:23Yeah, for sure.
- 22:24So another thing around this Gut Flora project that you were talking about is you have to do an online questionnaire because it's one thing to just go collect the samples from thousands of people.
- 22:35And the people who eat meat more often have this outcome or people who are vegan and don't have any dairy.
- 22:44They have that other outcome, right?
- 22:45So you actually had to set up a way to collect all that information as well, right?
- 22:50Yes.
- 22:51So we try to recruit volunteers to participate in this project through different channels.
- 22:57And the first thing I need to do is to kind of like fill in like a registration form where they say like, okay, I understand what's going on.
- 23:05There's a privacy statement in there.
- 23:08Also, they need to give informed consent that they know what they're volunteering to and that they can opt out at any point of the study.
- 23:14And then there's an intake questionnaire where people give us some information about their health, their lifestyle, and their diet.
- 23:22Now, this is done with commercial software, but it doesn't quite get us all the way there, right?
- 23:29So it does about 90% of the things we wanted to do.
- 23:31But then there are a few very specific things where we wanted to do something else.
- 23:35For instance, we sent sampling kits to all the participants.
- 23:40So we want to know that the address that they entered in the questionnaire actually exists.
- 23:45So when they're filling in their address, it will quickly use a Python web service that I created to check this against the vPost, so the Belgian post office website, to make sure that that address exists.
- 23:58And in case they might have made a typo, we will tell them like, oh, there's something wrong.
- 24:02Are you sure this is your address?
- 24:04Maybe like there's something off with it.
- 24:06Maybe you made a typo somewhere.
- 24:07Can you correct it?
- 24:08Also, as part of this process, people need to schedule a visit with their general practitioner.
- 24:15So to make it very easy for our participants, we made another web service that can kind of suggest the details for a general practitioner based on what they entered.
- 24:25So it's a little bit like this type of hat form.
- 24:27Once they start typing the last name of their doctor, it will immediately suggest like, okay, is it this doctor that you mean?
- 24:33Here's this address.
- 24:34And if they click it, it automatically completes the form.
- 24:36You know, I wish more sites were like that.
- 24:39It would be so nice to be so friendly and say, yeah, you've given us enough.
- 24:45Here's just click here.
- 24:47We got you.
- 24:47It's actually extremely important in this type of research because we're asking these people to basically give up some of their free time to help us out with our research.
- 24:56So we really are very grateful that people actually do this.
- 25:01Also, they need to take a stool sample, freeze it, and then bring it to like a drop-off point,
- 25:06which is usually a local pharmacy.
- 25:07But again, that's actually quite a lot of effort that you're asking of someone.
- 25:11So at least the parts that we can make easy for participants, we try to make as easy as possible.
- 25:15Yes.
- 25:16Yeah, yeah.
- 25:17This is an easy one.
- 25:17But definitely, I mean, there's so many places that could adopt that philosophy and just don't.
- 25:23One of the things that's interesting about this that I think is worth pointing out is you said this is a pre-packaged commercial questionnaire site company.
- 25:34Yeah, they take care of it, but they let you customize the page by putting in a little bit of JavaScript, right?
- 25:39Essentially, when they filled in their address and they click the next button, that's the point where we can fire a little bit of JavaScript.
- 25:46So mostly using jQuery to call the web service with the data they entered and then send a response back.
- 25:54Yes, this is valid or no, this is not valid.
- 25:56And then have the website respond appropriately according on that.
- 26:00I think that's a really interesting way to bring in the capabilities that you have using Python and Flask to something that is not really extensible, but it has this little tiny hook where it lets you just do just enough to get into the space.
- 26:16And, you know, it lets you not have to say, well, we either can use this the way it is or we can from scratch build our own questionnaire site, but we can just lay on top of it.
- 26:25It definitely feels a little bit like cheating, right?
- 26:28But yeah, especially because we're working with medical data, it's so important to get everything right in terms of security.
- 26:35You have to comply to GDPR and some other like regulations as well.
- 26:40So building our own platform would just be like a tremendous amount of work.
- 26:44So that's why we opted to go with this commercial platform.
- 26:48But indeed, we do need to use some tricks here and there to actually get it to do everything we want it to do.
- 26:53It makes sense because your goal is not to build a questionnaire site.
- 26:56Your goal is to get samples and information about bacteria colonies, right?
- 27:02If you could avoid building that site, like as much as you can, just avoid it, right?
- 27:06Absolutely, yes.
- 27:07Yeah, but the other one, the first one we talked about, the MetaConnect that the microbiologists can use to study and get the data back in the way they want it.
- 27:16That one sounds more core to your goals, right?
- 27:20So that one, you said you built that one from scratch with Flask, huh?
- 27:23It's actually something that has been going on for some time.
- 27:26So previously, it was used to study gene expression in different types of tissues of plants.
- 27:34But if you think of gene expression, so that's basically which genes are on or off and how much are they expressed in different tissues.
- 27:42It's also an abundance matrix.
- 27:44And so I kind of realized fairly early on when I started working on the microbial data that it's very, very similar.
- 27:50And a lot of the techniques and tools are the same.
- 27:54So I just forked the repository and started like making the necessary changes to actually support microbiome data as well.
- 28:01Yeah, sure.
- 28:01Get in there, change the title and just go from there.
- 28:04Nice.
- 28:05Yeah.
- 28:05Tell us about it.
- 28:06Tell us about some of the technologies that you used and stuff like that.
- 28:09Biological data is actually very well suited for relational databases.
- 28:12So usually you have like a species or a data set, and then there are sequences related with that.
- 28:18And with a sequence, you can have functional information.
- 28:21You can group sequences into clusters or gene families.
- 28:25So you kind of have this like structure that fits a hierarchical or a relational database very well.
- 28:32So there's definitely some MySQL connection there.
- 28:36And for that, I'm using all like the Flask packages.
- 28:38So just Flask MySQLAlchemy is in there when you're uploading the data through like an admin panel.
- 28:45So that's just Flask admin that I used.
- 28:47Users don't actually get to see that part.
- 28:49So it's a very standard interface.
- 28:51So through that interface, you can upload the data.
- 28:53So basically as a by-infantition, you processed all the reads that you got,
- 28:58and you have your abundance matrix and you upload it.
- 29:01So then there are some standard analyses that are just triggered on the server and just ran.
- 29:07As soon as you upload the data, it's being...
- 29:09Right.
- 29:10So some sort of like data ingestion.
- 29:12Yeah.
- 29:12It loads it up, converts it into the database format, things like that.
- 29:16Exactly right.
- 29:16And so it also does a couple of analyses immediately as you upload the data.
- 29:20And so for that part, I'm just using like Pandas, NumPy, and the scikit-learn to kind of do those kind of stuff.
- 29:26So just a whole lot of Flask going on there on the back.
- 29:30And it's cool that you're using Flask admin.
- 29:32And of course, if people don't have to, they don't see it.
- 29:34If it's just the admin see it, it could just, you know, admin panels are always like the worst looking part of the UI.
- 29:40Exactly right.
- 29:41So the parts that actually users get to see, that's something where I do spend a bit more time on how it actually looks.
- 29:47Nice.
- 29:48So this thing, the goal is going to be to open source it.
- 29:51Do you think that it makes sense?
- 29:53I guess probably it doesn't make sense to run it as like a service that people can generally use or does it?
- 30:00I'm thinking because of the privacy.
- 30:02But maybe if it's for things like plant data and stuff, like the plants don't have a GDPR.
- 30:06Yeah, that's true.
- 30:06Is it something that can be generally useful as a site or just as a project people could clone for their projects?
- 30:12So I kind of see a couple of different use cases for this.
- 30:14So one is communication, right?
- 30:16Let's say you did an awesome study with some microbiome data that you can make public.
- 30:20You could actually set up your own platform, upload all your data in there and use this kind of like a supplementary web page to your publication.
- 30:27So it's a great way for communicating things to other people that might not have the bioinformatics expertise to do that kind of analysis themselves.
- 30:37I also personally use a lot to just locally run it, upload the data set that I'm analyzing, and I just get like all those tools at the click of a button rather than using different scripts and making all those like one-off scripts to do some kind of analysis.
- 30:51It's almost like a GUI on top of the libraries that you guys are using to study the bacteria.
- 30:57It really simplifies analyzing the data.
- 31:00There are also now some students that are starting to use it in our group.
- 31:03So they have their project, they have their samples.
- 31:06They went through the learning curve to learn how to process the reads and get that abundance matrix.
- 31:11It's mostly done using our scripts.
- 31:13So at that point, it's kind of like nice if you can give them something that's nice and easy to finish up the rest of the analysis.
- 31:19And so that's also a use case we have.
- 31:22Yeah, you talked about having students maybe working on some new projects that are kicking off at the university there.
- 31:29For students out there listening, what kind of skills, you know, maybe they studied biology or maybe they just studied data science.
- 31:36What kind of skills do you look for for people to work on your projects?
- 31:41If it would be to extend something like MetaConnect, it would be nice to have someone that has some coding skills already.
- 31:48Right.
- 31:49So this semester there will be one student and he'll definitely be working a little bit on the code of MetaConnect.
- 31:55So then I'm looking for someone that has some coding skills.
- 31:58But also having some understanding of the biology is necessary.
- 32:02Right.
- 32:02You don't get that far if you don't understand any of the biology at all.
- 32:06So it's really like this combination.
- 32:08And bioinformatics is such an interesting and broad field that the amount you need of either the informatics or the biology can differ based on different projects.
- 32:17So projects that I would supervise, they would generally not include any work in a lab.
- 32:23But there are also people who are doing kind of like a combination of some lab work with some bioinformatics.
- 32:30That's also perfectly possible.
- 32:31Yeah, I'm sure it sounds fun.
- 32:32Students are always looking for research projects to be part of so that they can make those connections at universities.
- 32:39But it's interesting just to think about biology students trying to get into the software side, kind of like you did with bioinformatics or the reverse, right?
- 32:48Software people who are kind of interested in biology and whether they can cross over for that.
- 32:53Actually, I know people did it both ways, right?
- 32:56So there are plenty of bioinformaticians that have a background in biology.
- 33:00And then the first couple of years really struggled with the scripting, picking up those kind of skills.
- 33:05I don't know, people that have like a traditional CS degree and that way got into bioinformatics.
- 33:09So both are possible.
- 33:11Actually, it was a couple of years ago necessary to pick one part or the other because there was no formal master in bioinformatics at the university at the time.
- 33:20So now we actually have that kind of course at the university.
- 33:23So you can also decide to just do a bioinformatics master and then you kind of have the biology and the computer science in equal amounts.
- 33:31Yeah, that's great.
- 33:32One of the libraries that you said you're using on the MetaConnect is something called cytoscape.js.
- 33:41Well, it's actually a JavaScript library.
- 33:44So that's basically a library that allows you to visualize networks in the browser.
- 33:49And so I briefly mentioned it before.
- 33:51You can represent these communities of bacteria as networks.
- 33:54So think of it as a social network of bacteria, right?
- 33:58So bacteria that tend to appear across different samples, they're co-abundant.
- 34:04And could be that they're somehow related to each other.
- 34:07They're either dependent on each other or maybe they're dependent on the same other resource.
- 34:12But the thing is you spot them very often in the same samples.
- 34:15And so that allows you to kind of like represent the bacteria as nodes and draw an edge between them.
- 34:21Allows us to kind of study the communities of bacteria because we do expect that bacteria that are often in the same samples somehow need each other to do what they need.
- 34:34This portion of Talk Python To Me is brought to you by Tidelift.
- 34:37Tidelift is the first managed open source subscription, giving you commercial support and maintenance for the open source dependencies you use to build your applications.
- 34:46And with Tidelift, you not only get more dependable software, but you pay the maintainers of the exact packages you're using, which means your software will keep getting better.
- 34:55The Tidelift subscription covers millions of open source projects across Python, JavaScript, Java, PHP, Ruby, .NET, and more.
- 35:02And the subscription includes security updates, licensing, verification, and indemnification, maintenance and code improvements, package selection and version guidance, roadmap input, and tooling and cloud integration.
- 35:14The bottom line is you get the capabilities you'd expect and require from commercial software.
- 35:20But now, for all the key open source software you depend upon, just visit talkpython.fm/Tidelift to get started today.
- 35:30And I bring it up because it looks like such a cool library.
- 35:32Obviously, it just does graphing type stuff.
- 35:35But the variety of the visualizations there are super cool.
- 35:39So people who are looking to draw those types of relationships, I think there's a lot of stuff to take here.
- 35:46There's even one where it represents like different animals linked together and the vertices are actually pictures of animals and stuff like that.
- 35:54So it's a really nice library for that.
- 35:56Was it pretty easy to use?
- 35:57It's very, very performant in terms of drawing the graphs.
- 36:00Yeah.
- 36:01But you kind of have to build the interface around it.
- 36:04It just draws nodes and edges, gives you some functions to interact with them.
- 36:08But if you want to have like an option to change the color of the nodes, those little things you have to add yourself.
- 36:15So it's pretty straightforward once you have your data in the right format to visualize it using Cytoscape.js.
- 36:21I struggled quite a bit to build the interface and all the buttons that I required for my viewer to get them to link.
- 36:29To get it to behave just right.
- 36:31Exactly.
- 36:31Sure.
- 36:32It's one thing to draw and it's another to make it interactive.
- 36:35For sure.
- 36:36So one of the areas that I thought would be fun to talk about would be the pressures of being in an academic space and what counts as like merit and credit in that world versus industry.
- 36:48So it sounds like a lot of the work that you're doing is around academics, but you also have a little bit of industry experience going on at the same time.
- 36:58And, you know, with academics, it's all about the academic paper, right?
- 37:03Yes.
- 37:03Is that a challenge for my goal is to build this cool library in Python to help biologists, but I can't publish that.
- 37:10So what am I going to actually do along with that?
- 37:12What's the tension like there?
- 37:14I am analyzing some data for a company.
- 37:18And I think it's a really cool project, but it's their intellectual property.
- 37:21So I'm not talking too much about it.
- 37:23And so basically the findings there, that's all the company's thing.
- 37:27But so software that I'm designing, that's more the academic part.
- 37:30It's true that like in academia, basically your work is measured by the number of publications that you have.
- 37:36So I need to kind of keep a balance between them, right?
- 37:39So I need to make sure that I also get some publications for my resume.
- 37:43Do you think that the industry is going to, or academia, I guess, is going to change somewhat to recognize software contributions as part of research more?
- 37:53I mean, this is not a problem just focused on biology, right?
- 37:57This is a problem in physics and chemistry and mathematics and astronomy, right?
- 38:03Whatever, right?
- 38:03Anywhere where there's people building these great libraries, that's taking away from their time to do research, maybe.
- 38:09If you're really building like a library for other people to use, for sure, that's going to be an issue.
- 38:14I've mainly been developing applications.
- 38:17And so then the way we did it was we kind of released the application along with data sets.
- 38:23And then you can kind of do some research with that data set as well.
- 38:28So you kind of have done a combination of novel data sets with novel software.
- 38:33And people can start using it.
- 38:34And that can also become like a publication on its own.
- 38:37However, there it does make it challenging to keep on supporting the software.
- 38:41Because once the publication is out, right?
- 38:44You got what you need.
- 38:46There's no more reason to keep adding features to it or whatever, right?
- 38:50Yes.
- 38:50So then I need to continue basically building a larger data set in combination with better software to kind of keep it going.
- 38:59And so I think during my PhD, one of the projects I was working on,
- 39:02really were very successful in doing that.
- 39:04It was always a combination of like, here's an online platform with like a cool tool that we developed.
- 39:10But also each time, here's like a larger data set, more species.
- 39:14It certainly makes sense to build tools and applications to answer your questions, right?
- 39:19Because I've worked in research groups before.
- 39:22And a lot of the work was, we need to answer this question.
- 39:27We need to visualize this thing.
- 39:28We need to transform that data.
- 39:29And it was just writing software to do that.
- 39:32So have you heard about the Journal of Open Source Software, Joss?
- 39:36I have.
- 39:36I actually think it was through one of your podcasts that I learned about it.
- 39:40Yeah.
- 39:40Yeah.
- 39:40We had it on the show.
- 39:41Is that something relevant in your space?
- 39:44So far, I don't have any experience with it.
- 39:46But I do like the idea of breaking down these like big research projects into smaller components
- 39:53that can be reused, right?
- 39:55MetaConnect, for instance, is definitely a monolith.
- 39:57Yeah.
- 39:58It's like a whole package that does so many different things.
- 40:02It would be cool if I could basically take some components out of there and maybe get
- 40:07like a smaller publication out of it through Joss or some other journal.
- 40:10And it's something I've been trying to do recently, but so far, I haven't really been able to test
- 40:15it or to put it in practice.
- 40:16Yeah.
- 40:17I was just thinking, okay, it seems like some of your stuff that you're building, it repackaged
- 40:22correctly, it might fit in there, right?
- 40:23Yes.
- 40:24So for instance, we have a lot of metadata for the Flemish Gut Flora project.
- 40:28Right.
- 40:28So we have thousands of people and we have all this medical information, this information
- 40:33about their diet and their lifestyle.
- 40:34And I have a viewer for that.
- 40:36Now, that's something you can basically use across different disciplines, right?
- 40:40Every study where you have a ton of metadata would benefit from such a viewer.
- 40:45That's, for instance, one of the parts that I would like to kind of like separate into its
- 40:48own repository that could become its own project.
- 40:51Cool.
- 40:51Well, maybe I guess school has just started, so it's probably not the easiest time to find
- 40:56free time, but maybe next summer or something or over winter break.
- 40:59Yeah.
- 41:00I'll have a look at it once I have some free time on my hands to work on it.
- 41:04Absolutely.
- 41:04So where's this research going and what are you building next?
- 41:09Like what more analysis do you want to do?
- 41:11What more libraries or apps are you building?
- 41:13I'm actually quite happy with the microbiome studies.
- 41:16It's a very challenging field.
- 41:19And a lot of the things that we are doing now are association studies.
- 41:23So we look at the population and see like, okay, if you have more of this bacteria, then
- 41:28maybe there's a higher chance that you have certain disease.
- 41:32But that's just an association, right?
- 41:34It doesn't mean that having that bacteria will actually cause a disease.
- 41:37Correlation is not causation.
- 41:38Correlation or causation.
- 41:39Yep.
- 41:39Exactly.
- 41:40Exactly.
- 41:41And so right now we're moving also towards more like longitudinal studies, intervention
- 41:47studies to kind of like really establish those causal links.
- 41:51So that we can say like, yeah, it's really the bacteria that causes something or no, it's
- 41:55actually disease that causes the person to eat something differently or behave differently.
- 42:00And that is actually changing the microbes in the gut, for instance.
- 42:05Is it a signal or is it a cause?
- 42:06So that's now happening.
- 42:08And then of course, if you get like time resolved data, that's going to be like a next challenge,
- 42:12I think, to integrate in all of this.
- 42:13So it sounds like more data might be on hand and you already have a lot of data.
- 42:18Where does machine learning factor in your world?
- 42:22Have you tried to use like machine learning models to understand this and make these inferences?
- 42:27I know machine learning is extremely good at taking a picture and saying, oh, that means
- 42:32it's like this, but what about one of these like abundancy grids or something like that?
- 42:38One of the things that we noticed or that basically my colleagues noticed a couple of years ago
- 42:44is that we can kind of stratify the Flemish population into four different groups based
- 42:50on the bacteria that are in the gut.
- 42:52What is the distinctions there, the categories?
- 42:54Certain people just have like more of one kind of bacteria, right?
- 42:58And that seems to be kind of like one group and they're not distinct groups.
- 43:01It's more like a spectrum.
- 43:03So we noticed there are these four different groups, right?
- 43:07So one of the things that would be nice is if basically we could use some machine learning
- 43:12to automatically classify new samples into these different enterotypes.
- 43:16You could also start thinking of kind of trying to predict something based on the gut microbes.
- 43:22But I think that's still some ways off.
- 43:24It would be great if you could just look at the sample and say like, okay, this person is at
- 43:28risk for a certain disease.
- 43:29Maybe that will work.
- 43:31Maybe not.
- 43:32So that's still very vague right now, whether we'll be able to do that or not.
- 43:36But people are probably looking at it.
- 43:38Yeah, it sounds exciting.
- 43:39It doesn't sound out of reach at all.
- 43:41It really depends on like the data that we can generate.
- 43:44And yeah, we'll need to explore that.
- 43:46I guess it depends on how reliable the science is that says if it's like this, that means
- 43:52that, right?
- 43:53Because you've got to train the models to say, I don't know, maybe the models could make discoveries
- 43:58that people don't see.
- 43:58I don't know.
- 43:59I haven't done enough machine learning, but there's probably some really interesting things
- 44:03you could do with machine learning and that data.
- 44:05For sure.
- 44:05Yes.
- 44:06So, but whether or not we'll be able to make any kind of predictions towards health, that's
- 44:11something I'm very careful about.
- 44:12Categorization one sounds likely.
- 44:14That's something that will probably be possible based on what I've seen so far.
- 44:18And as we're generating more and more data, it would be very nice to just do that initial
- 44:22classification into the enter type in this automatic way.
- 44:26For sure.
- 44:26So, well, it sounds like you're making some cool use of Python to study these microbiomes.
- 44:31And they're just so fascinating because they're really out of reach for us in any way that
- 44:37we can conceive about it other than a very small view with a microscope.
- 44:41It's super interesting.
- 44:42I think so too.
- 44:42Hopefully that inspires the biologists out there to do more Python and things like that.
- 44:47Super cool.
- 44:49So thanks for sharing that with us.
- 44:51I think probably we'll leave it there for that conversation.
- 44:53But before you go, I do have the two questions for you.
- 44:57So if you're working on this project, you can write some Python code.
- 45:01What editor do you use?
- 45:02So if I'm working on MetaConnect or any kind of like large project, that would be PyCharm.
- 45:06If it's more like a very specific analysis, I'll fire up Jupyter Notebooks.
- 45:11Where do you make that tradeoff?
- 45:12Where do you say, okay, this is now it's too much for the Jupyter Notebook.
- 45:15I'm switching to PyCharm.
- 45:16Like when do you transition from one to the other?
- 45:19So I have like a couple projects and they really are from the beginning decided to be
- 45:23like an application I'm developing.
- 45:25And for that, it's automatically something I will do in PyCharm.
- 45:28If it's more like processing data, preparing it to do something else with it or something
- 45:33I just have to do once, maybe twice, then I'll go for the notebook.
- 45:37Also for reporting back something.
- 45:39I think the notebooks are really powerful.
- 45:41So you can just, you know, generate all the graphs, export it to PDF and say, here's the
- 45:45thing that you asked.
- 45:46Yeah, that's perfect.
- 45:47Super.
- 45:47And then notable PyPI package that makes your life better?
- 45:52One that I discovered recently that really like saved my day is something called UltraJSON.
- 45:57I think it's pip install ujson to get it.
- 46:00And it's basically a very performant version of the JSON library in the standard library.
- 46:07So I was developing an endpoint that had to like deserialize some JSON objects that were
- 46:12stored in the database, combine them and serialize them again to something I could then send to
- 46:17a viewer.
- 46:18And that's just made everything a couple hundred milliseconds faster, which made the website
- 46:23so much more responsive.
- 46:25Oh, that's super cool.
- 46:26Yeah.
- 46:26UltraJSON is a JSON encoder and decoder written in pure Python.
- 46:31I'm sorry, pure C with bindings for Python.
- 46:33Yeah, that's great.
- 46:34So you probably have a lot of data on those endpoints, right?
- 46:37Like the 10,000 measurements or whatever.
- 46:40Yeah, exactly.
- 46:41So if like I need to kind of like deserialize one of those complex objects, do something with
- 46:46it, combine it with like another one and serialize it again, very quickly takes seconds, which for
- 46:52a web interface is very slow.
- 46:53So everything that can just take like a couple hundred milliseconds off that time is really
- 46:59great.
- 46:59And is it the same API as regular JSON module?
- 47:02For the most of it, yeah.
- 47:04Pretty much everywhere in my code, I was able to just write import UJSON as JSON and it worked.
- 47:09That's sweet.
- 47:10All right.
- 47:10Well, that's a great suggestion then because it sounds so easy to adopt and will be helpful
- 47:14for a lot of folks.
- 47:15Cool.
- 47:16All right.
- 47:16Well, final call to action.
- 47:18People are out there interested in biology or biologists are out there interested in Python.
- 47:22when they want to get started, what do you say to them?
- 47:24Right.
- 47:24So definitely try some coding in Python.
- 47:28Even if you're mostly into biology, just knowing a little bit of the basics can make your life
- 47:33a lot easier.
- 47:33Just being able to automate something for a couple times can prove very useful, right?
- 47:40Yeah, absolutely.
- 47:40You know, escape Excel, right?
- 47:42Yes.
- 47:43Or MATLAB.
- 47:43One of the two.
- 47:44Yeah.
- 47:44Like we're collecting more and more data.
- 47:46So I encounter it so often that people were using Excel and at one point it just hit that
- 47:52wall and then, you know, Python, Panda, scikit-learn and help you break through that.
- 47:58So have a look at it if you need it.
- 48:00Cool.
- 48:00All right.
- 48:00Well, Sebastian, thanks for being on the show.
- 48:02It's great to chat with you.
- 48:03Yeah, it's great to chat with you as well, Michael.
- 48:04Thanks.
- 48:06This has been another episode of Talk Python To Me.
- 48:08Our guest in this episode was Sebastian Proust, and it's been brought to you by Linode and Tidelift.
- 48:14Linode is your go-to hosting for whatever you're building with Python.
- 48:18Get four months free at talkpython.fm/linode.
- 48:21That's L-I-N-O-D-E.
- 48:23If you run an open source project, Tidelift wants to help you get paid for keeping it going
- 48:28strong.
- 48:29Just visit talkpython.fm/Tidelift, search for your package, and get started today.
- 48:34Want to level up your Python?
- 48:37If you're just getting started, try my Python Jumpstart by Building 10 Apps course.
- 48:42Or if you're looking for something more advanced, check out our new async course that digs into
- 48:47all the different types of async programming you can do in Python.
- 48:50And of course, if you're interested in more than one of these, be sure to check out our
- 48:54Everything Bundle.
- 48:54It's like a subscription that never expires.
- 48:56Be sure to subscribe to the show.
- 48:58Open your favorite podcatcher and search for Python.
- 49:01We should be right at the top.
- 49:02You can also find the iTunes feed at /itunes, the Google Play feed at /play, and the
- 49:08direct RSS feed at /rss on talkpython.fm.
- 49:11This is your host, Michael Kennedy.
- 49:13Thanks so much for listening.
- 49:15I really appreciate it.
- 49:16Now get out there and write some Python code.
- 49:17I'll see you next time.
- 49:38Thank you.