Learn with Cheminformatics Matplotlib

Introduction

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

Scatter plot

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

logP_saturated-fatty-acids.png

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()

logP_C18-fatty-acids.png

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.

bar graph

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()

fatty acid concs.png

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.

Summary

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

Reference materials / links

What is the programming language Python? Can it be used for AI and machine learning?

Recommended Posts

Learn with Cheminformatics Matplotlib
Learn Pandas with Cheminformatics
Learn with Cheminformatics NumPy
Animation with matplotlib
Japanese with matplotlib
Animation with matplotlib
Histogram with matplotlib
Animate with matplotlib
2-axis plot with Matplotlib
Learn Python with ChemTHEATER
Learn Zundokokiyoshi with LSTM
Learn with chemoinformatics scikit-learn
Heatmap with Python + matplotlib
Band graph with matplotlib
Real-time drawing with matplotlib
Various colorbars with Matplotlib
3D plot with matplotlib
DCGAN with TF Learn
Adjust axes with matplotlib
Learn Pendulum-v0 with DDPG
Learn librosa with a tutorial 1
Learn elliptical orbits with Chainer
Graph drawing method with matplotlib
Learn new data with PaintsChainer
Graph Excel data with matplotlib (2)
Stackable bar plot with matplotlib
Python Iteration Learning with Cheminformatics
Gradient color selection with matplotlib
Animate multiple graphs with matplotlib
Learn algorithms with Go @ recursive call
Create plot animation with Python + Matplotlib
A python graphing manual with Matplotlib.
Inference & result display with Tensorflow + matplotlib
Japaneseize Matplotlib with Alpine using Docker
[Python] font family and font with matplotlib
Learn with Causal ML Package Meta-Learner
Learn with FizzBuzz Iterator, Generator, Decorator
Learn with PyTorch Graph Convolutional Networks
[TensorFlow 2] Learn RNN with CTC Loss
Draw Japanese with matplotlib on Ubuntu
Let's learn Deep SEA with Selene
Learn search with Python # 2bit search, permutation search
Draw a loose graph with matplotlib
Versatile data plotting with pandas + matplotlib
Learn document categorization with spaCy CLI
Heatmap with Dendrogram in Python + matplotlib
Easy Japanese font setting with matplotlib
Easy to draw graphs with matplotlib
Continuously color with matplotlib scatter plot
Draw Lyapunov Fractal with Python, matplotlib
When matplotlib doesn't work with python2.7
Lognormal probability plot with Python, matplotlib
Easy animation with matplotlib (mp4, gif)
Write a stacked histogram with matplotlib
Implement "Data Visualization Design # 2" with matplotlib
How to title multiple figures with matplotlib
[Python] Set the graph range with matplotlib
Adjust the spacing between figures with Matplotlib
Learn to colorize monochrome images with Chainer
Align the size of the colorbar with matplotlib
Learn data distributed with TensorFlow Y = 2X