One day, a good friend of mine gave me some of her data to play with. These were measurements of neurite growth rate from wildtype and transgenic animals. To get this data, she had to do ‘live-imaging’ of neurons, meaning that she put neurons in a culture dish filled with nutrient broth, provided a nice warm moist environment while taking pictures of them every minute, for set periods of time, say a few hours. It takes patience and meticulousnous, as is true for a lot of biological experiments.
What I want to do with this data, is to be able to visualize neurite growth rate at different time intervals, and be able to see whether neurites from wildtype animals behave differently from those of transgenic animals. One way to do so is to plot the data in the form of heatmaps.
She provided me the data in the form of an excel file, so the first step is to import that into Python, in addition to importing modules that I’ll need:
Next is to set up the area, or the grid where I will plot the data points
Finally, plotting the data and showing it nicely
Note: Here I chose 5 as the the substitute value for null data points. I find it tricky in deciding what value to choose, as I cannot find an easier way to tell Python to simply ignore the null data points. Also, the value that I chose affects the scale of how the data will be presented (see later)
plt.pcolor(X, Y, Z, cmap=plt.get_cmap(‘PiYG’)) plt.subplots_adjust(left=0, right=2, bottom=0, top=2)
An alternatively way is simply using the Seaborn library
This is much easier, as only a few lines of codes needed.
Back to the problem about how to choose the fill value, if I were to choose a smaller number, 3:
Or if I choose a bigger number, 10:
I know there must be some other better way, but what I’m trying to do here is to have a nice-looking background color that contrasts well with the data themselves, and additionaly provide a good contrast among the data points as well.
Which heatmap do you like better? The longer code, or Seaborn?