면역원성(Immunogenicity) 예측하기

1. 면역원성(Immunogenicity) 예측

고분자 물질(예를 들면 단백질 의약품)이 체내에 들어왔을때 면역반응을 유발하는 성질을 면역원성 (immunogenicity)이라 합니다. 면역원성은 단백질 의약품의 약효뿐만 아니라 환자의 에도 문제를 일으킬수 있습니다. 따라서 재조합 단백질이나 항체와 같은 단백질 의약품 개발 시 면역원성을 사전에 예방하고 최소화하는 것이 반드시 필요하죠.

in silico 기술을 활용하여 기존의 알려진 DB를 검색하여 면역원성을 예측하는 방법을 알아 보겠습니다.

1.1. NetMHC 4.0 Server

MHC class I에 붙는 펩타이드를 예측해주는 프로그램입니다. 다음은 홈페이지의 소개 글입니다.

Prediction of peptide-MHC class I binding using artificial neural networks (ANNs). ANNs have been trained for 81 different Human MHC alleles including HLA-A, -B, -C and -E. Furthermore, predictions for 41 animal (Monkey, Cattle, Pig, and Mouse) alleles are available.

단백질 서열만 넣어주면 어느 부분이 MHC class I에 붙을지를 계산해 줍니다. 궁극적으로 이것을 통해 Immunogenicity를 예측 할 수 있습니다.

In [ ]:
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd

필요한 라이브러리를 불러오고, NetMHC 서버에서 나온 결과를 엑셀파일로 다운받아 로컬에 저장합니다.

In [ ]:
# parse the excel file
xls = pd.ExcelFile("G:\prediction.xlsx")  # 위치와 파일명은 변경해주세요.

# make dataframe from sheet
df_M113HC = xls.parse("M113 (HC)", index_col=0)
df_M113LC = xls.parse("M113 (LC)", index_col=0)
df_mAb2021HC = xls.parse("mAb2021 (HC)", index_col=0)
df_mAb2021LC = xls.parse("mAb2021 (LC)", index_col=0)
df_Bay_HC = xls.parse("Bay-B (HC)", index_col=0)
df_Bay_LC = xls.parse("Bay-B (LC)", index_col=0)

엑셀파일을 pandas 라이브러리를 통해 읽어들이고, 각각의 시트를 각각의 데이터프레임으로 만들었습니다. 잘 만들어 졌는지 하나의 데이터프레임을 표시해 보겠습니다.

In [ ]:
df_M113HC.head()
Out[ ]:
DRB1_0101 DRB1_0301 DRB1_0401 DRB1_0403 DRB1_0405 DRB1_0406 DRB1_0410 DRB1_0701 DRB1_0802 DRB1_0803 DRB1_0901 DRB1_1101 DRB1_1201 DRB1_1202 DRB1_1301 DRB1_1302 DRB1_1401 DRB1_1407 DRB1_1501 DRB1_1502
Peptide
EVQLVESGGGLVKPG 311.99 8664.84 3989.47 6338.94 5373.34 6338.94 2634.71 1082.11 5368.11 1715.37 714.05 5425.98 1391.91 2083.95 685.17 758.31 4138.06 6196.80 1946.21 3408.39
VQLVESGGGLVKPGG 350.21 9685.61 5547.56 8448.85 7251.92 8448.85 3781.46 1250.97 6269.37 2049.98 829.42 6173.44 1778.93 2698.32 831.89 893.20 4808.39 6974.27 2254.98 3797.98
QLVESGGGLVKPGGS 744.61 12900.80 8900.20 12395.21 10933.17 12395.21 6455.01 2376.86 8643.02 3217.39 1483.77 8500.01 2978.00 4274.31 1517.35 1651.02 7602.71 9759.88 3819.41 5610.82
LVESGGGLVKPGGSL 2031.56 19704.16 13747.03 17624.09 16544.21 17624.09 12547.56 5857.65 9547.54 4827.00 3480.35 10593.37 5764.85 7177.91 4684.63 5097.43 13908.77 14562.81 7342.24 8169.02
VESGGGLVKPGGSLR 1573.87 8900.58 12312.74 17260.07 16667.82 17260.07 11976.50 5182.46 8052.22 2695.43 3503.55 5319.49 2526.99 3082.52 5448.22 6827.86 8645.83 12890.06 5489.64 7360.93

df_M113HC 데이터프레임을 보면 인덱스로는 펩타이드 서열이 있고, 각각의 열은 alleles 를 나타냅니다. allele에 대해서는 위키피디아를 참고하세요. 숫자는 펩타이드가 붙을 확률을 나타냅니다. 숫자가 크면 가능성이 크고, 낮으면 적다고 볼 수 있습니다.

우리가 알고 싶은 것은 각각의 아미노산으로 유발되는 면역원성임으로 Peptide의 첫번째 아미노산만 남겨줍니다.

In [ ]:
def make_simple(df):
    """
    peptide의 맨 앞 아미노산만 남기기
    """
    df2 = df.rename(index=lambda x: x[:1])
    return df2


def make_seq(df):
    """
    peptide의 아미노산 서열을 리스트로 변환
    """
    df2 = df.rename(index=lambda x: list(x))
    return df2

1.2. 시각화하기

다음과 같이 히트맵을 그리는 기능을 만들어 사용하겠습니다.

In [ ]:
def drawing_plot(x):
    """
    그림 그리기
    """
    # 그림 사이즈 정하기
    plt.figure(figsize=(100, 5))
    # 컬러맵과 최대값과 최소값을 정하기
    sns.heatmap(make_seq(x).T, cmap="Blues_r", square=True, vmax=500, vmin=50)
    # 그림 저장 옵션
    plt.savefig(str(x) + ".png", dpi=120, format="png")

실제로는 아래와 같이 하드코딩을 통해서 진행을 해버렸습니다.

In [ ]:
# 플롯 그리기
plt.figure(figsize=(100, 5))
sns.heatmap(make_simple(df_M113HC).T, cmap="Blues_r", square=True, vmax=500, vmin=50)
plt.savefig("df_M113HC.png", dpi=120, format="png", bbox_inches="tight")
No description has been provided for this image
In [ ]:
# 플롯 그리기
plt.figure(figsize=(100, 5))
sns.heatmap(make_simple(df_M113LC).T, cmap="Blues_r", square=True, vmax=500, vmin=50)
plt.savefig("df_M113LC.png", dpi=120, format="png", bbox_inches="tight")
No description has been provided for this image
In [ ]:
# 플롯 그리기
plt.figure(figsize=(100, 5))
sns.heatmap(make_simple(df_mAb2021HC).T, cmap="Blues_r", square=True, vmax=500, vmin=50)
plt.savefig("df_mAb2021HC.png", dpi=120, format="png", bbox_inches="tight")
No description has been provided for this image
In [ ]:
# 플롯 그리기
plt.figure(figsize=(100, 5))
sns.heatmap(make_simple(df_mAb2021LC).T, cmap="Blues_r", square=True, vmax=500, vmin=50)
plt.savefig("df_mAb2021LC.png", dpi=120, format="png", bbox_inches="tight")
No description has been provided for this image
In [ ]:
# 플롯 그리기
plt.figure(figsize=(100, 5))
sns.heatmap(make_simple(df_Bay_HC).T, cmap="Blues_r", square=True, vmax=500, vmin=50)
plt.savefig("df_Bay_HC.png", dpi=120, format="png", bbox_inches="tight")
No description has been provided for this image
In [ ]:
# 플롯 그리기
plt.figure(figsize=(100, 5))
sns.heatmap(make_simple(df_Bay_LC).T, cmap="Blues_r", square=True, vmax=500, vmin=50)
plt.savefig("df_Bay_LC.png", dpi=120, format="png", bbox_inches="tight")
No description has been provided for this image

2. 마치며

총 6종류의 단백질에 대한 각각의 면역원성을 분석했습니다. allele에 따라 면역반응이 다르지만 전체적으로 파란색을 띄는 서열을 직관적으로 알 수 있습니다.

만약 인위적으로 넣은 서열이 매우 푸른색을 띈다면 피하는 편이 좋습니다.

Learn_Jupyter

노트북 소개

원래 ipython는 파이썬을 위한 향상된 대화형 커맨드라인 콘솔입니다. Jupyter notebook은 그것에서 보다 발전된 형태로 코딩문서화를 동시에 해서 생산성을 극대화 하는 도구입니다.

In [1]:
print("Hello!")
Hello!

매직 명령어(Magic commands)

파일 시스템과 상호작용을 할 수 있는 명령어로 % 기호로 시작합니다. 현재 디렉토리 위치를 출력해 보겠습니다.

In [2]:
%pwd
Out[2]:
'/home/partrita/Documents/blog/partrita.github.io/posts'

더 많은 매직 명령어는 %lsmagic으로 확인 할 수 있고, 각 명령어에 ?를 추가하면 추가 정보를 보여줍니다.

In [3]:
%lsmagic
Out[3]:
Available line magics:
%alias  %alias_magic  %autocall  %automagic  %autosave  %bookmark  %cat  %cd  %clear  %colors  %config  %connect_info  %cp  %debug  %dhist  %dirs  %doctest_mode  %ed  %edit  %env  %gui  %hist  %history  %killbgscripts  %ldir  %less  %lf  %lk  %ll  %load  %load_ext  %loadpy  %logoff  %logon  %logstart  %logstate  %logstop  %ls  %lsmagic  %lx  %macro  %magic  %man  %matplotlib  %mkdir  %more  %mv  %notebook  %page  %pastebin  %pdb  %pdef  %pdoc  %pfile  %pinfo  %pinfo2  %popd  %pprint  %precision  %profile  %prun  %psearch  %psource  %pushd  %pwd  %pycat  %pylab  %qtconsole  %quickref  %recall  %rehashx  %reload_ext  %rep  %rerun  %reset  %reset_selective  %rm  %rmdir  %run  %save  %sc  %set_env  %store  %sx  %system  %tb  %time  %timeit  %unalias  %unload_ext  %who  %who_ls  %whos  %xdel  %xmode

Available cell magics:
%%!  %%HTML  %%SVG  %%bash  %%capture  %%debug  %%file  %%html  %%javascript  %%js  %%latex  %%markdown  %%perl  %%prun  %%pypy  %%python  %%python2  %%python3  %%ruby  %%script  %%sh  %%svg  %%sx  %%system  %%time  %%timeit  %%writefile

Automagic is ON, % prefix IS NOT needed for line magics.

자동완성 (Tab completion)

자동완성은 믿을 수 없을 정도로 아주 유용한 기능입니다. 코딩을 하면서 모든 것을 타이핑하는것보다 tab키를 누르면 알아서 완성해주는 기능입니다.

노트북에 대화형 위젯 만들기

노트북에는 위젯이라는 대화형 요소를 지원합니다. 기본적인 예제를 살펴보겠습니다.

In [4]:
from IPython.display import YouTubeVideo

YouTubeVideo("J9YpkSX7NNM")  # 예제로 사용된 영상은 현재 재생이 되지 않습니다.
Out[4]:

Matplotlib 과 Seaborn

matplotlib은 파이썬의 중심 라이브러리입니다. 사용하기 복잡할 수 있지만 풍부하고 강력한 기능을 제공하죠. 다만 기본 스타일이 촌스럽게 느껴질수 있습니다. 그래서 seaborn이 만들어 졌죠. seaborn은 matplotlib 기반으로 사용하기 쉽고 통계적인 시각화를 제공합니다.

In [1]:
# 필요한 모듈을 임포트합니다.
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

%matplotlib inline
In [2]:
# matplotlib 으로 임의의 신호를 생성하고 그려보자
y = np.random.randn(1000)
plt.plot(y)
Out[2]:
[<matplotlib.lines.Line2D at 0xa591048>]
No description has been provided for this image
In [3]:
# 수학함수를 그래프로 그려보자
x = np.linspace(-10.0, 10.0, 1000)
y = np.sin(3 * x) * np.exp(-0.1, x**2)
plt.plot(x, y)
Out[3]:
[<matplotlib.lines.Line2D at 0xb5f5d68>]
No description has been provided for this image
In [4]:
# 산점도를 그려보자
x = np.random.randn(100)
y = x + np.random.randn(100)
plt.scatter(x, y)
Out[4]:
<matplotlib.collections.PathCollection at 0xb66f4a8>
No description has been provided for this image

Seaborn 시각화

seaborn은 사용하기 쉬운 발전된 기능을 제공 합니다.

In [5]:
# 예제에 사용될 데이터를 읽어오자
df = sns.load_dataset("iris")
df.head()  # 데이터의 모양을 확인
Out[5]:
sepal_length sepal_width petal_length petal_width species
0 5.1 3.5 1.4 0.2 setosa
1 4.9 3.0 1.4 0.2 setosa
2 4.7 3.2 1.3 0.2 setosa
3 4.6 3.1 1.5 0.2 setosa
4 5.0 3.6 1.4 0.2 setosa

사용한 데이터셋은 붓꽃(iris) 의 3가지 종(setosa, versicolor, virginica)에 대해 꽃받침(sepal)과 꽃잎(petal)의 넓이와 길이를 정리한 데이터입니다.

iris

위 그림을 참고하시면 이해가 되실 겁니다.

In [6]:
# pair plot을 그려본다
sns.pairplot(df, hue="species", size=2.5)
Out[6]:
<seaborn.axisgrid.PairGrid at 0xb63eb70>
No description has been provided for this image

각각의 붓꽃종에 따라 꽃받침(sepal)과 꽃잎(petal)에 어떠한 연관성이 있는 지 확인 할 수 있습니다. 예를 들면 꽃잎의 길이가 길면 넓이도 넓어지는것은 모든종에서 연관관계가 있는 것을 볼수 있습니다.