Building a Django-Powered LIMS for the Genomics Era

This video features Isaiah Olatunbosun at DjangoCon Europe 2024 in Vigo, Spain.

Building a Django-Powered LIMS for the Genomics Era
0:16:36
Published July 11, 2024
361 views

Talk: Building a Django-Powered Laboratory Information Management Systems (LIMS) for the Genomics Era by Isaiah Olatunbosun

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.

Key takeaways

  • A LIMS can replace fragmented spreadsheets, databases, paper records, and manual processes with one auditable workflow.
  • Barcode scanning lets the system validate sample metadata, identify its source, and assign it to a precise rack and well.
  • Django validation handles constraints such as unique sample IDs, family relationships, problem samples, and correct rack operations.
  • Plating logic prevents samples from the same patient or family from being placed too close together when required by laboratory rules.
  • Scheduled Python jobs generate and send CSV-based laboratory messages automatically, removing the need for repeated manual emails.
  • Database relationship queries help staff locate samples quickly and track their rack, well, and processing status.

Summarised automatically from the transcript.

Transcript

2,641 words · auto-generated Show

Automatically transcribed, so expect mistakes in names and technical terms.

0:00

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 uh all the process easier. So today I'll be talking about uh We can use Django to build a laboratory information management system. So let me start by uh sharing some of the challenges that prompt us to build a LINKS. So, first thing, uh 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

0:47

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 uh another lab for analysis 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 particular sample is in this particular odin rack and is in this particular well

1:32

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

the the other challenge we face was systems. How do we improve the current systems? Because uh 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

3:05

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 uh 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 uh

3:51

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 uh genetics is a different uh 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 uh 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 uh 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

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 sent this data. So Then we have to verify that we have the correct information. So once we scan the that uh sample we send a post request to the server that stores all this information for you and we also create a sales referral. Uh let me just show us a simple code. that we use for acknowledging uh sample. So uh yeah so using a jungle generic view Then your uh form

5:23

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 uh validation? Is the data like an let's say for example we have the large uh is 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 uh patients, we're also doing testing for patients uh for their family members, brothers, sisters, mother, maybe they've had cancer in the past.

6:13

So So you need to check uh is the group existing, and when you are sending the data out to the lab, you need to go with the family uh 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

7:00

like We have uh multiple samples from uh 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 uh three columns in between uh multiple sample from the same Patient. So these are some of the uh things we follow when plating. Then when sending this sample out, we need to plate uh we have like a validation where we check uh if We have samples from other family member of the particular patient also. So this just like a sample of our

7:45

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 uh thing we're able to do is so sample audit is simply looking for where is your sample stored So it's like uh 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 uh this was achieved was using the prefetch audit, uh sorry, prefetch related. So basically You can which prefetch related we can query multiple

8:31

search fields. We can have uh participant ID, group ID, rack holding ID, you can have Um sorry, I can't remember all of them, but perhaps other parameters that you can use to search with. Then uh the pref prefect related allows you to query multiple relationship backwards. So instead of running uh your lab sample from multiple table you I mean from uh multiple queries at different times but with jungle prefecture related you can query your sample ID from all this table at once. So we have prefect related, we have uh select related but we decide to go with prefect related because I found this uh picture

9:17

online that kind of summarize what preferred uh related is all about so basically you're querying multiple uh 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 uh multiple queries so uh 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 uh protocols so the We call it gel one thousand and four message. So what's gel one thousand and four message is more

10:02

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 um things that we do. So what does uh so the first message they send in gel 1005 1004 message. That is we've sent this sample to you and that's the uh 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

10:48

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 uh labs and other people we need to communicate so 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

11:34

our gel 1005 message. So Uh it's ever it's been automated around every hour. Then uh 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 uh 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. Um the other aspects of so why do we need to use a laboratory information management system? The first thing for all says

12:19

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 uh 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.

13:05

It gives you the location and it also checks the We are not merging that the uh 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 uh 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 uh if you discover that this particular sample is is

13:50

faulty and it has implated already, you need to change it, move it from this particular rack uh 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 uh in this particular uh 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 uh what is a way for you to mark this problem as uh a problem rack then another uh error that we're able to

14:35

reduce is uh sorry i just forgot that mat is actually between so uh 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 uh we use Django Get request to check if this particular Lab uh 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 uh advantage that we

15:20

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 uh the sample has been scanned we create CSV file that has been stored in a particular so uh folder, then the cron jobs that was uh 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 uh other laboratories. So yeah, uh that's the end of my talk. Uh it's a short one. Thank you so much. I'd like to say a big thank you to the DjangoCon

16:07

community because uh 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

Questions this talk answers

What is a laboratory information management system (LIMS), and what does it do?

A LIMS is software that streamlines and automates laboratory processes, stores sample and result data, and records metadata such as sample type and quantity. Its goal is to reduce processing and waiting times while making laboratory work more efficient.

Discussed at 3:05

How can Django validate and register samples in a laboratory system?

When a sample barcode is scanned, the system sends its information to the server, checks fields such as quantity, sample type, and sending laboratory, and applies form and regular-expression validation. It also checks related patient or family-group data before the sample is accepted.

Discussed at 4:37

How do you organize multiple patient samples into a 96-well rack?

The system combines samples from different laboratories into a single rack and applies plating rules, including spacing multiple samples from the same patient across rows and columns. It also checks for relevant family-member samples before the rack is sent for analysis.

Discussed at 6:13

How can a LIMS track where a sample is stored?

A sample audit queries the database for a sample’s location, including its rack and well. Django’s `prefetch_related` can retrieve related records across the relevant relationships in fewer queries, using fields such as participant ID, group ID, and rack ID.

Discussed at 7:45

How can Django automate communication between laboratories?

After samples are scanned, the system stores their metadata and generates CSV files. A Python cron job checks the folder every 15 minutes, sends new files to the relevant laboratories, and moves successfully processed files after receiving a response.

Discussed at 10:48

How does a LIMS reduce errors in laboratory sample handling?

It directs technologists to the correct rack location, prevents invalid sample moves, flags problem racks, and checks that imported sample IDs are unique. These validations reduce mistakes that might otherwise occur during plating, returns, and data entry.

Discussed at 13:05

Note: We understand that names change, people change, and bodies change. We respect each individual's journey and privacy. If you have any concerns about a video or need us to remove content, please don't hesitate to contact us. We will handle your request with care and promptly address any issues.

More videos from DjangoCon Europe