Building a Django-Powered LIMS for the Genomics Era
Transcript
By Isaiah Olatunbosun. From DjangoCon Europe 2024. Published July 11, 2024.
Watch the video Markdown version 2,641 words · auto-generated · en
Summary
Isaiah Olatunbosun explains how his laboratory uses Django and Python to build a laboratory information management system (LIMS) for handling large volumes of genomic samples. The system scans barcodes, validates sample and family-group data, places samples according to plating rules in 96-well racks, and lets staff audit each sample’s location and status. It also automates communication with other laboratories through generated CSV files, scheduled jobs, and standard GEL messages, reducing manual work, processing errors, duplicate samples, and delays.
Transcript
Automatically transcribed, so expect mistakes in names and technical terms. Filler words are removed.
0:00 Laboratory Challenges
and everybody lives easier. So for example when you call oh I want to do this test analysis we have to build internal tools we have to use Django C S We have to use Python and other technologies to make all the process easier. So today I'll be talking about We can use Django to build a laboratory information management system. So let me start by sharing some of the challenges that prompt us to build a LINKS. So, first thing, my labs with serve like 11 million peoples and we receive samples from a lot of genomic laboratory labs that we first as GLH in the months we could receive thousands of
Samples so we need to find a way to merge all these samples together into a single odin rack where before sending it to the another lab for analysis. So basically Lab A can send two samples, lab B can send three samples, and that lab can send ten samples. So we have to find a way to manage all this samples and organize them into a single ordinary rack of ninety six samples that before going for analysis. The other challenge we face is how do we audit each sample. So we should be able to know okay, this particular sample is in this particular odin rack and is in this particular well
maybe the well is labeled the odd rack is labeled A to H and A to twelve so we need to know okay this particular sample is in Well, B two, C four, E twelve, so we need to find a way to audit our sample to know their location and their rack and other information about them, whether it's a problem sample, is not a problem sample. So we need to find the other thing is automated communication because we're receiving sample from other GLH we need to be able to communicate with gel and we're going to be able to communicate with other lab. So we need to have a way where Our data are being sent automatically without having to send emails for every samples or every communication that we need to do.
2:19 Laboratory Information Management Systems
the other challenge we face was systems. How do we improve the current systems? Because before limbs organizations use database systems, some people use Excel, some people use Access, some people use Virus, some people use paper. So these are some of the challenges that these are some of the process that can be improved with ellipses. So this process improvement is A general challenge that has been faced by many people and many organizations. So, how do we solve all this problem? We can solve all this problem by building a lead that's laboratory information management system. And what is Laboratory information management system. Some people will see laboratory information management system in different ways based on what
they want to use it for. But I find this very interesting. So laboratory information management system is a software. That is designed to streamline and automate lab processes. So basically, you should be able to improve your processes. So you'll be able to cut down your time Work faster and so when you call your GP they don't tell you, oh sorry, your results will be ready in six months time or your results will be ready in three weeks time. How can you be the software that can use to improve your waiting time, that can help you improve your results analysis period? So it a link should be also be able to store data. Okay, this sample from patient A, yeah. cancer, he has
rare disease, he has what was the result analysis. Like in pathology they can it's easier for them to tell you, okay, the result is A B C but for genetics is a different ball game so it's able to store your results analysis and it should have the sample metadata so for each sample you should have to know okay the quantity you should be able to know the sample type maybe is blood, maybe is tumor, maybe is saliva, whichever sample type. So those information should be stored in a limbs for your sample. So let's look at the implementation. How are we able to solve these challenges? So the first thing we did to for each sample we receive, we
4:37 Sample Intake and Validation
It comes in a tube and they have a barcode that contains so you need to scan it. So once you scan it, we're doing so many work in Django. We have to Check the quantity. We have to check the sample type. We have to check the GLH. Okay, which library sent this data. So Then we have to verify that we have the correct information. So once we scan the that sample we send a post request to the server that stores all this information for you and we also create a sales referral. Let me just show us a simple code. that we use for acknowledging sample. So yeah so using a Django generic view Then your form
valid method you can override the form actually come a bit the form valid method where you have samples of object. create, then you have the check participants. So this check participants Is it meeting the validation? Is the data like an let's say for example we have the large is it the participants are is it like integer? You have to use regular expression So these are some of the validations that we're able to achieve with Django. I don't know where this is coming from. Another thing that we have to check, okay, what do you go? Because we're as we're receiving a sample from a patient you are checking, you're also receiving the sample from their family members. So we are not just doing testing for some patients, we're also doing testing for patients for their family members, brothers, sisters, mother, maybe they've had cancer in the past.
6:13 Sample Plating
So you need to check is the group existing, and when you are sending the data out to the lab, you need to go with the family data. So we have other validations that will do in that Then plating. This is the most interesting part of the project. So platin is where we mix all these samples together. So we have a odding rack So this is an example of a holding rack. We have H to H, then we have 1 to 12. So the green cycle represents a single patient. Let's say patient A. then X or the X sample represents other patients B, C, D, E, F. So we have to follow some platin rules and regulation
like We have multiple samples from patients. If you look at patient A1, I mean well A1 and well B4, these are samples from the same patient. So we need to put like two rows and took three columns in between multiple sample from the same Patient. So these are some of the things we follow when plating. Then when sending this sample out, we need to plate we have like a validation where we check if We have samples from other family member of the particular patient also. So this just like a sample of our
7:45 Sample Auditing
Iraq looks like at the end of the day. So this is not the exact one. I got this from on Splash. So we have like all your samples arranged in a holding rack. and we'll send this out maybe back over here also Mr. Sample back over here. So the other thing we're able to do is so sample audit is simply looking for where is your sample stored So it's like you re send the request, okay, I want to query my database and know where This sample is stored and the easiest way to do that one of the way this was achieved was using the prefetch audit, sorry, prefetch related. So basically You can which prefetch related we can query multiple
search fields. We can have participant ID, group ID, rack holding ID, you can have sorry, I can't remember all of them, but perhaps other parameters that you can use to search with. Then the pref prefect related allows you to query multiple relationship backwards. So instead of running your lab sample from multiple table you I mean from multiple queries at different times but with Django prefecture related you can query your sample ID from all this table at once. So we have prefect related, we have select related but we decide to go with prefect related because I found this picture
9:17 Automated Laboratory Communication
online that kind of summarize what preferred related is all about so basically you're querying multiple that 's more like a foreign sorry multiple tables more like a foreign key relationship mini to mini one to one sorry mini to mini relationship that will give you all your results so as this reduce your query time and multiple queries so let's talk about communication So communication is more like once we receive a sample from a laboratory it we have to follow some standard protocols so the We call it gel one thousand and four message. So what's gel one thousand and four message is more
like okay I have this sample that I want to analyze, I want to Check whether this patient has cancer or this patient has a rare disease. So these are the two major things that we do. So what does so the first message they send in gel 1005 1004 message. That is we've sent this sample to you and that's the sample in a tube more like in a cooler with storage and everything. So once we confirm that, so what we'll do is We scan the backcode in the lab. We store the metadata in a database. This also generates a CSV file that is being stored in a particular folder. So once we confirm all this information, we send a gel
1005 message back to them. And this is being achieved using a cron job. So basically We have a cron job that scan that runs every 15 minutes past the hour. So it checks for any CS file in a particular folder. Once it discovers that there's a CS file, it will send it to the labs and other people we need to communicate so after it's receiving a response of like 200 once we get the two hundred it's Move that particular CSV file into a processed CSV. So every 15 minutes past the hour, it checks for is there any new Is there any new CSV file that has been stored? So that's how we sent
our gel 1005 message. So it's ever it's been automated around every hour. Then we also send the gel one thousand and eight message. General one thousand and eight message means that we are done plating all these samples into the old enrack. So basically we are sending this, these are the samples. That we are sending for analysis to the lab. So the labs will take care of it. So just like these are the information that we are sending to you. So that is being handled by the cron job Also, yes, so that 's how we're able to do our communications with other laboratory. The other aspects of so why do we need to use a laboratory information management system? The first thing for all says
12:19 Workflow Organization
how do we serve our patients effectively? How do we organize our samples So by building a laboratory information management system, we merge all the samples together. So samples can come in on Monday, on Tuesday. We have to store them in a store route then take them in storage called the old our waiting rack so once we receive them we pick the scanner once you scan it will tell you This sample put it in well before let me just share the old internet So once you scan the sample, it tells you put this patient sample in FO4.
It gives you the location and it also checks the We are not merging that the two samples from the same patients are not beside each other. So that's one of the advantages of building laboratory process management system for us. We were able to Organize our sample in a stress-free and seamless way. All the technologists in the lab, all they have to do is just okay, know the location of where they need to add the sample. Then the other advantage for using a laboratory for in our lab is to reduce errors so Like if you discover that this particular sample is
13:45 Error Reduction
faulty and it has implated already, you need to change it, move it from this particular rack to another rack so we're able to do some data validation that you have the right sample picks If the system check that okay, the sample you want to return is not in this particular old in rack, it's going to give you an error. Sorry, you cannot return this particular sample. And you also have some system where maybe the GLH didn't remember to mark this sample as problem Iraq. Our assistant can easily tell you okay you need to mark what is a way for you to mark this problem as a problem rack then another error that we're able to
reduce is sorry i just forgot that mat is actually between so The other issue where we 're able to fix due to human error maybe your sample is this is a repeat sample. And it's is in our system because each sample needs to be unique. So we check our system as we are importing the data. We check we use Django Get request to check if this particular Lab sample ID exists in the database already. So that's how we were able to reduce error to be sure that each sample we are importing into our system is actually a unique sample The other advantage that we
15:20 Automated Communications and Closing
have by using a limbs is all our communication are automated So we don't have to worry. Oh, I forgot to send this email or I forgot to send this data to this particular laboratory. So once the sample has been scanned we create CSV file that has been stored in a particular so folder, then the cron jobs that was built in Python will Scan that particular folder every nine fifteen, ten fifteen, every fifteen minute past the hour. So that's one of the ways we're able to achieve the automated communications with other laboratories. So yeah, that's the end of my talk. It's a short one. Thank you so much. I'd like to say a big thank you to the DjangoCon
community because without the awesome community of developers we will not be here and I'll not be here today. So thank you for the privilege and to all my team member that works in the laboratory that helped me to prepare this slide on say big thank you and Yes, so if you can connect with me on Twitter and LinkedIn. I don't know if there's any question from anybody