Use AI To Visualize Organ Transplant Waitlist Size

This blog post shows how to use AI, like ChatGPT, to visualize organ transplant waitlist size by state. At the end of the post I’ll have created a data visualization to display the number of candidates that are currently on the organ transplant waitlist for all organs ordered from highest to lowest using ChatGPT.

This data from this blog post and report shows OPTN data for Waitlist : Count, Organ by Waiting Time, State of Center through December 7, 2023. OPTN Data is updated on a monthly basis.

Normally, there are two routes I’d take to get this data into a chart. The first would be the reusable method of taking the raw data set, manipulate it into a more simple format, load the data into a database, write an API then write a HighCharts front end to display the data. The other would be to use a tool like everviz, or Tableau if the data was a one off and I didn’t want to reuse it again for other similar data sets.

This time I just wanted to throw the data at AI to see what would happen and if it would be less or more work to get the data into a visualization.

Organ Transplant Waitlist Candidates by State
Final chart created by ChatGPT

Using the OPTN – Build advanced tool, I generated table showing what the current number of registrations and candidates are on organ transplant waitlists for each state in the United States (As of December 7th 2023). My goal is to tell which states had the most candidates on their respective organ transplant waitlists. This information is available using the OPTN tool, however the output is difficult to consumer and compare as it’s multiple large tables stacked on top of each other and the results are alphabetical without any ability to sort the results. Putting the data into a chart would be more clear to end users who are using the data.

I downloaded the full results and I asked ChatGPT to create a visualization of the current number of registrations and candidates on the waitlist for each state ordered by highest to lowest. Here’s how I used AI to visualize organ transplant waitlist size in the United States.

My first attempt was to upload the entire downloaded report right into ChatGPT to see if the system could figure out the visualizations without much of a prompt. ChatGPT wasn’t able to break apart the data and process it as you can see from the prompt history below:

This was a pretty hopeful experiment and with minimal prompting ChatGPT didn’t know how to parse out this large file. With more prompting and hand-holding I think I could have gotten the system to generate a visualization I wanted, working with AI systems is a process to get where we want to go.

On the next prompt I updated the file by removing the time frame breakdown and fixed the headers that were not exported to the CSV correctly and tried again. I also gave more direction of what was contained inside the file to help ChatGPT parse the file.

Organ Transplant Waitlist Registrations by State

This time I got results that were much better. Putting the data in a simpler format along with some more context really helped the system understand what the data was and how to come to the outcome that I was looking for. Next, let’s see this by candidates:

Organ Transplant Waitlist Candidates by State

This actually looks pretty good, but I know North Dakota has 117 records in this particular file but the chart looks like there isn’t a value. To be sure what the count was for each state, I prompted ChatGTP to show the results for each state at the end of the bar.

Yep, confirmed that the data is not correct. I didn’t dig into which columns or data was being returned but I did ask ChatGPT the question.

The system returned the updated chart below. This was pretty amazing given I didn’t prompt the system much but it was enough that the error was corrected and the correct data was returned.

Awesome, now just update the numeric formatting and I think it’s good to go.

Organ Transplant Waitlist Candidates by State

What’s even cooler about this process it that each time ChatGPT creates a chart image, it also gives you the code the system used to create the chart. Here is an example of the Python code used to create the final image. You’d need to know Python and what dependent libraries to use to implement this into a fully functioning program, but this is a great start.

# Creating the bar chart for candidates with numeric formatting for numbers over 999

plt.figure(figsize=(15, 10))
barplot_formatted = sns.barplot(x='Candidates', y='State', data=sorted_by_candidates_all_organs, palette="mako")

# Adding the number of candidates with numeric formatting at the top of each bar
for p in barplot_formatted.patches:
    width = p.get_width()    # Get the width of the bar
    label = f'{int(width):,}'  # The label text with numeric formatting
    plt.text(p.get_width(), p.get_y() + p.get_height() / 2, label, va='center')

plt.title('Organ Transplant Waitlist Candidates (All Organs) by State', fontsize=16)
plt.xlabel('Total Candidates (All Organs)', fontsize=14)
plt.ylabel('State', fontsize=14)
plt.xticks(fontsize=12)
plt.yticks(fontsize=12)
plt.tight_layout()

# Display the plot
plt.show()

In the end this entire process took about 10 minutes and delivered the graphic that I was looking for, which is pretty impressive if all you have is a spreadsheet and need to output a graphic. It’s not a beautiful interactive design, but it’s an informative data set that can be used on the fly without the need for a development staff to create.

There are a few downsides to this method, like we only see a graphic, there is no interactivity available to the end user and to modify the display a new image needs to be generated. To achieve that we’d need to wire the data up to a interactive charting library like HighCharts or D3. But this example shows the power AI has to be a valuable tool for healthcare staff and researchers without a deep technical bench.

Leave a Reply

Your email address will not be published. Required fields are marked *