Ejemplo n.º 1
0
    os.makedirs(dir_results)

DTCR = DeepTCR_SS('alpha_v_beta_SS')

antigens = ['ATP6AP1-KLG_G3W', 'GNL3L-R4C', 'MART1-A2L', 'YFV-LLW']

opt = ['alpha', 'beta', 'alpha_beta']

for a in antigens:
    y_pred_list = []
    y_test_list = []
    for o in opt:
        if o == 'alpha':
            DTCR = DeepTCR_SS('alpha_v_beta_SS')
            DTCR.Get_Data(directory='../../Data/Zhang/' + a,
                          aa_column_alpha=0,
                          p=p)
        elif o == 'beta':
            DTCR = DeepTCR_SS('alpha_v_beta_SS')
            DTCR.Get_Data(directory='../../Data/Zhang/' + a,
                          aa_column_beta=1,
                          p=p)
        elif o == 'alpha_beta':
            DTCR = DeepTCR_SS('alpha_v_beta_SS')
            DTCR.Get_Data(directory='../../Data/Zhang/' + a,
                          aa_column_alpha=0,
                          aa_column_beta=1,
                          p=p)

        DTCR.Monte_Carlo_CrossVal(folds=50, weight_by_class=True)
        y_pred_list.append(DTCR.y_pred)
Ejemplo n.º 2
0
                                    DTCRU.class_id,
                                    dir_results,
                                    metrics=['AUC'])

df_u = pd.DataFrame()
df_u['Class'] = df_metrics['Classes']
df_u['AUC'] = df_metrics['Value']
df_u['Method'] = df_metrics['Algorithm']
df_u['Type'] = 'Unsupervised'

#Run Supervised Sequence Classifier
DTCRS = DeepTCR_SS('Sequence_C', device=1)
DTCRS.Get_Data(directory='../../Data/Murine_Antigens',
               Load_Prev_Data=True,
               aggregate_by_aa=True,
               aa_column_beta=0,
               count_column=1,
               v_beta_column=2,
               j_beta_column=3)

AUC = []
Class = []
Method = []
folds = 100
seeds = np.array(range(folds))
for i in range(folds):
    np.random.seed(seeds[i])
    DTCRS.Get_Train_Valid_Test()
    DTCRS.Train(graph_seed=graph_seed)
    DTCRS.AUC_Curve(plot=False)
    AUC.extend(DTCRS.AUC_DF['AUC'].tolist())
Ejemplo n.º 3
0
from DeepTCR.DeepTCR import DeepTCR_SS
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from scipy.spatial.distance import pdist, squareform
from scipy.stats import spearmanr
import seaborn as sns
import pickle
import os
import matplotlib
matplotlib.rc('font', family='Arial')

#Instantiate training object
DTCRU = DeepTCR_SS('Murine_Sup')
#Load Data
DTCRU.Get_Data(directory='../../Data/Murine_Antigens',
               Load_Prev_Data=False,
               aa_column_beta=0,
               count_column=1,
               v_beta_column=2,
               j_beta_column=3,
               classes=['Db-F2', 'Db-M45', 'Db-NP', 'Db-PA', 'Db-PB1'])
Ejemplo n.º 4
0
"""Figure 3B"""
"""This script is used to train both the sequence and repertoire classifier on the
Rudqvist_2017 dataset and compare their performances."""

from DeepTCR.DeepTCR import DeepTCR_SS, DeepTCR_WF
from sklearn.metrics import roc_curve, roc_auc_score
import numpy as np
from matplotlib import pyplot as plt

#Train Sequence Classifier
DTCR_SS = DeepTCR_SS('Rudqvist_SS', device='/device:GPU:0')
DTCR_SS.Get_Data(directory='../../Data/Rudqvist',
                 Load_Prev_Data=False,
                 aa_column_beta=1,
                 count_column=2,
                 v_beta_column=7,
                 d_beta_column=14,
                 j_beta_column=21)

DTCR_SS.K_Fold_CrossVal(folds=5)

#Train Repertoire Classifier
folds = 100
LOO = 4
epochs_min = 10
size_of_net = 'small'
num_concepts = 64
hinge_loss_t = 0.1
train_loss_min = 0.1
seeds = np.array(range(folds))
graph_seed = 0
Ejemplo n.º 5
0
matplotlib.rc('font', family='Arial')

#Instantiate training object
DTCRU = DeepTCR_SS('Murine_Sup')
#Load Data
# DTCRU.Get_Data(directory='../../Data/Murine_Antigens',Load_Prev_Data=False,
#                aa_column_beta=0,count_column=1,v_beta_column=2,j_beta_column=3,
#                classes=['Db-F2', 'Db-M45', 'Db-NP', 'Db-PA', 'Db-PB1'])
# DTCRU.Monte_Carlo_CrossVal(folds=5)

DTCR_inf = DeepTCR_SS('load')
DTCR_inf.Get_Data(directory='../../Data/Murine_Antigens',
                  Load_Prev_Data=False,
                  aa_column_beta=0,
                  count_column=1,
                  v_beta_column=2,
                  j_beta_column=3,
                  classes=['Kb-M38', 'Kb-SIY', 'Kb-TRP2', 'Kb-m139'])

beta_sequences = DTCR_inf.beta_sequences
v_beta = DTCR_inf.v_beta
j_beta = DTCR_inf.j_beta

out = DTCRU.Sequence_Inference(beta_sequences=beta_sequences,
                               v_beta=v_beta,
                               j_beta=j_beta)
out2 = DTCRU.Sequence_Inference(beta_sequences=beta_sequences,
                                v_beta=v_beta,
                                j_beta=j_beta)