Continuing from Pandas learning from chemoinformatics, "Matplotlib" is one of the representative libraries of Python with the theme of lipidomics (comprehensive analysis of lipids). I will explain about. We will mainly explain practical examples of chemoinformatics, so if you want to check the basics, please read the following article before reading this article.
Pharmaceutical researcher summarized Matplotlib
Matplotlib is a library for drawing graphs. It can be used to visualize trends in data.
First, load the library with ʻimport. If you are using Jupyter Notebook, you can draw a graph on your notebook by writing
% matplotlib inline`.
Now, let's consider analyzing the relationship between the number of carbon atoms and double bonds of fatty acids and their physical properties.
%matplotlib inline
import matplotlib.pyplot as plt
abbreviations = ['FA 12:0', 'FA 14:0', 'FA 16:0', 'FA 18:0', 'FA 20:0', 'FA 22:0'] #Abbreviation for fatty acid molecular species
Cns = [12, 14, 16, 18, 20, 22] #Number of carbon atoms (chain length) of fatty acid
logPs = [3.99, 4.77, 5.55, 6.33, 7.11, 7.89] #LogPow value of fatty acid molecular species
plt.scatter(Cns, logPs) #Creating a scatter plot
plt.xlabel('Cn') #x-axis label
plt.ylabel('logPow') #y-axis label
plt.savefig('logP_saturated-fatty-acids.png') #Save the scatter plot as an image file (PNG file)
plt.show() #Display the completed scatter plot
In the above example, the relationship between the number of carbon atoms Cns
and logPowlogPs
is illustrated for saturated fatty acids (fatty acid molecular species without double bonds in the carbon chain).
logPow is the "water octanol partition coefficient", which indicates the magnitude of hydrophobicity of a compound.
This time, the value of logPow referred to LIPID MAPS.
As you can see, as the number of carbon atoms increases, so does the value of logPow.
This indicates that as the number of carbon atoms increases, the hydrophobicity of the molecule increases.
Consider the same for unsaturated fatty acids (fatty acid molecular species with double bonds in the carbon chain).
%matplotlib inline
import matplotlib.pyplot as plt
abbreviations = ['FA 18:1', 'FA 18:2', 'FA 18:3', 'FA 18:4']
Uns = [1, 2, 3, 4] #Number of double bonds in the carbon chain of fatty acids (degree of unsaturation)
logPs = [6.11, 5.88, 5.66, 5.44]
plt.scatter(Uns, logPs)
plt.xlabel('Un')
plt.ylabel('logPow')
plt.savefig('logP_C18-fatty-acids.png')
plt.show()
This time, the number of carbon atoms is the same, and it shows how logPow changes when the number of double bonds (unsaturation) is changed. It can be seen that as the number of double bonds increases, the hydrophobicity of the molecule decreases.
Next, consider illustrating the intracellular fatty acid concentration in a * in vitro * experiment.
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
concs_ctrl = [0.1, 0.05] #Concentrations of arachidonic acid and docosahexaenoic acid in control experiments
concs_cmpd_low = [0.05, 0.07] #Concentrations of arachidonic acid and docosahexaenoic acid in compound addition (low dose) experiments
concs_cmpd_high = [0.01, 0.08] #Concentrations of arachidonic acid and docosahexaenoic acid in compound addition (high dose) experiments
x = np.arange(len(concs_ctrl)) #Number of fatty acids to display
bar_width = 0.3 #Bar graph width
plt.bar(x, concs_ctrl, width=bar_width, align='center') #Control condition bar graph
plt.bar(x+bar_width, concs_cmpd_low, width=bar_width, align='center') #Bar graph of conditions when compound is added (low dose)
plt.bar(x+bar_width*2, concs_cmpd_high, width=bar_width, align='center') #Bar graph of conditions when compound is added (high dose)
plt.xticks(x+bar_width, ['AA', 'DHA']) #x-axis data name
plt.ylabel('Concentration (uM)')
plt.legend(('Control', 'Compound X 0.1uM', 'Compound X 1 uM')) #Usage Guide
plt.savefig('fatty acid concs.png')
plt.show()
Here, we show how the intracellular concentrations of arachidonic acid (AA) and docosahexaenoic acid (DHA) change under three types of experimental conditions. By the way, in terms of the number of carbon atoms and the number of double bonds, AA is "FA 20: 4" and DHA is "FA 22: 6". You can see that when compound X is added to cells, AA production is suppressed and DHA production is gradually increased in a dose-dependent manner. In this example, the graph is created as experimental data with n = 1, and no error bar is attached.
Here, we have explained Matplotlib, focusing on practical knowledge that can be used in chemoinformatics. Let's review the main points again.
--You can use a scatter plot to analyze the correlation between two types of data, and you can draw it with matplotlib.pyplot.scatter
.
--A bar graph can be used to analyze the magnitude relationship of values, and can be drawn with matplotlib.pyplot.bar
.
Next, scikit-learn is explained in the following article.
Scikit-learn learned from chemoinformatics
What is the programming language Python? Can it be used for AI and machine learning?
Recommended Posts