# LE
import math
with open('REFINED_Coordinates.pickle', 'rb') as file:
    gene_names_LE, coords_LE, map_in_int_LE = pickle.load(file)

#%% importing tensorflow
import tensorflow as tf
from tensorflow.keras import layers, models
from tensorflow.keras.callbacks import EarlyStopping
Results_Data = np.zeros((5, 4))
nn = 26
cnt = 0  # Image size = sqrt(#features (drug descriptors))

# Convert data into images using the coordinates generated by REFINED

X_Train_REFINED = REFINED_Im_Gen(X_Train, nn, map_in_int_LE, gene_names_LE,
                                 coords_LE)
X_Val_REFINED = REFINED_Im_Gen(X_Validation, nn, map_in_int_LE, gene_names_LE,
                               coords_LE)
X_Test_REFINED = REFINED_Im_Gen(X_Test, nn, map_in_int_LE, gene_names_LE,
                                coords_LE)

sz = X_Train_REFINED.shape
#Width = int(math.sqrt(sz[1]))
#Height = int(math.sqrt(sz[1]))
Width = 26
Height = 26

X_Train_REFINED = X_Train_REFINED.reshape(-1, Width, Height, 1)
X_Val_REFINED = X_Val_REFINED.reshape(-1, Width, Height, 1)
X_Test_REFINED = X_Test_REFINED.reshape(-1, Width, Height, 1)
    gene_names_MDS, coords_MDS, map_in_int_MDS = pickle.load(file)

#%% importing tensorflow
import tensorflow as tf
from tensorflow.keras import layers, models
from tensorflow.keras.callbacks import EarlyStopping
from tqdm import tqdm
Results_Data = np.zeros((5, 4))
nn = 26
cnt = 0  # Image size = sqrt(#features (drug descriptors))

X_Train_D1_REFINED = np.zeros((X_Train_D1.shape[0], nn**2, 4))
X_Val_D1_REFINED = np.zeros((X_Val_D1.shape[0], nn**2, 4))
X_Test_D1_REFINED = np.zeros((X_Test_D1.shape[0], nn**2, 4))

X_Train_D1_REFINED[:, :, 0] = REFINED_Im_Gen(X_Train_D1, nn, map_in_int_ISO,
                                             gene_names_ISO, coords_ISO)
X_Val_D1_REFINED[:, :, 0] = REFINED_Im_Gen(X_Val_D1, nn, map_in_int_ISO,
                                           gene_names_ISO, coords_ISO)
X_Test_D1_REFINED[:, :, 0] = REFINED_Im_Gen(X_Test_D1, nn, map_in_int_ISO,
                                            gene_names_ISO, coords_ISO)

X_Train_D1_REFINED[:, :, 1] = REFINED_Im_Gen(X_Train_D1, nn, map_in_int_MDS,
                                             gene_names_MDS, coords_MDS)
X_Val_D1_REFINED[:, :, 1] = REFINED_Im_Gen(X_Val_D1, nn, map_in_int_MDS,
                                           gene_names_MDS, coords_MDS)
X_Test_D1_REFINED[:, :, 1] = REFINED_Im_Gen(X_Test_D1, nn, map_in_int_MDS,
                                            gene_names_MDS, coords_MDS)

X_Train_D1_REFINED[:, :, 2] = REFINED_Im_Gen(X_Train_D1, nn, map_in_int_LE,
                                             gene_names_LE, coords_LE)
X_Val_D1_REFINED[:, :, 2] = REFINED_Im_Gen(X_Val_D1, nn, map_in_int_LE,
Exemplo n.º 3
0
    X_Dummy = X_Validation_Raw.values
    X_Validation = X_Dummy[:, 2:]
    X_Dummy = X_Test_Raw.values
    X_Test = X_Dummy[:, 2:]

    ################
    ##   REFINED  ##
    ################
    from Toolbox import REFINED_Im_Gen
    with open('/nfs/home/jaclyns/REFINED/Mapping_REFINED.pickle',
              'rb') as file:
        gene_names, coords, map_in_int = pickle.load(file)

    nn = math.ceil(np.sqrt(X_Train.shape[1]))
    print("this is nn " + str(nn))
    X_Train_REFINED = REFINED_Im_Gen(X_Train, nn, map_in_int, gene_names,
                                     coords)
    X_Val_REFINED = REFINED_Im_Gen(X_Validation, nn, map_in_int, gene_names,
                                   coords)
    X_Test_REFINED = REFINED_Im_Gen(X_Test, nn, map_in_int, gene_names, coords)

    #####################
    ###    CNN Model  ###
    #####################
    import keras
    import tensorflow as tf
    from tensorflow.keras import layers, models
    from tensorflow.keras.callbacks import EarlyStopping
    from sklearn.preprocessing import OneHotEncoder
    onehot_encoder = OneHotEncoder(sparse=False)
    Y_Train_Class = Y_Train_Class.reshape(-1, 1)
    Y_Validation_Class = Y_Validation_Class.reshape(-1, 1)
        gene_names_MDS, coords_MDS, map_in_int_MDS = pickle.load(file)

    #%% importing tensorflow
    import tensorflow as tf
    from tensorflow.keras import layers, models
    from tensorflow.keras.callbacks import EarlyStopping
    Model_Names = ["VOLUMETRIC"]
    Results_Data = np.zeros((1, 5))
    nn = 26
    cnt = 0  # Image size = sqrt(#features (drug descriptors))
    for modell in Model_Names:
        X_Train_REFINED = np.zeros((X_Train.shape[0], nn**2, 4))
        X_Val_REFINED = np.zeros((X_Validation.shape[0], nn**2, 4))
        X_Test_REFINED = np.zeros((X_Test.shape[0], nn**2, 4))

        Temp_Train = REFINED_Im_Gen(X_Train, nn, map_in_int_ISO,
                                    gene_names_ISO, coords_ISO)
        X_Train_REFINED[:, :, 0] = REFINED_Im_Gen(X_Train, nn, map_in_int_ISO,
                                                  gene_names_ISO, coords_ISO)
        X_Val_REFINED[:, :,
                      0] = REFINED_Im_Gen(X_Validation, nn, map_in_int_ISO,
                                          gene_names_ISO, coords_ISO)
        X_Test_REFINED[:, :, 0] = REFINED_Im_Gen(X_Test, nn, map_in_int_ISO,
                                                 gene_names_ISO, coords_ISO)

        X_Train_REFINED[:, :, 1] = REFINED_Im_Gen(X_Train, nn, map_in_int_MDS,
                                                  gene_names_MDS, coords_MDS)
        X_Val_REFINED[:, :,
                      1] = REFINED_Im_Gen(X_Validation, nn, map_in_int_MDS,
                                          gene_names_MDS, coords_MDS)
        X_Test_REFINED[:, :, 1] = REFINED_Im_Gen(X_Test, nn, map_in_int_MDS,
                                                 gene_names_MDS, coords_MDS)
Exemplo n.º 5
0
            'C:\\Users\\obazgir\\Desktop\\REFINED project\\Volumetric REFINED\\theMapping_REFINED_5.pickle',
            'rb') as file:
        gene_names_MDS, coords_MDS, map_in_int_MDS = pickle.load(file)

    #%% importing tensorflow
    import tensorflow as tf
    from tensorflow.keras import layers, models
    from tensorflow.keras.callbacks import EarlyStopping
    Results_Data = np.zeros((4, 5))
    nn = 26
    cnt = 0  # Image size = sqrt(#features (drug descriptors))

    MODELS = ["LE", "LLE", "MDS", "ISO"]
    for mdl in MODELS:
        if mdl == "LE":
            X_Train_D1_REFINED = REFINED_Im_Gen(X_Train_D1, nn, map_in_int_LE,
                                                gene_names_LE, coords_LE)
            X_Val_D1_REFINED = REFINED_Im_Gen(X_Val_D1, nn, map_in_int_LE,
                                              gene_names_LE, coords_LE)
            X_Test_D1_REFINED = REFINED_Im_Gen(X_Test_D1, nn, map_in_int_LE,
                                               gene_names_LE, coords_LE)

            X_Train_D2_REFINED = REFINED_Im_Gen(X_Train_D2, nn, map_in_int_LE,
                                                gene_names_LE, coords_LE)
            X_Val_D2_REFINED = REFINED_Im_Gen(X_Val_D2, nn, map_in_int_LE,
                                              gene_names_LE, coords_LE)
            X_Test_D2_REFINED = REFINED_Im_Gen(X_Test_D2, nn, map_in_int_LE,
                                               gene_names_LE, coords_LE)

        elif mdl == "MDS":

            X_Train_D1_REFINED = REFINED_Im_Gen(X_Train_D1, nn, map_in_int_MDS,
import pickle

# Arithmetic
with open('REFINED_Coordinates.pickle', 'rb') as file:
    gene_names_AR, coords_AR, map_in_int_AR = pickle.load(file)

#%% importing tensorflow
import tensorflow as tf
from tensorflow.keras import layers, models
from tensorflow.keras.callbacks import EarlyStopping
from tqdm import tqdm
Results_Data = np.zeros((5, 4))
nn = 26
cnt = 0  # Image size = sqrt(#features (drug descriptors))

X_Train_D1_REFINED = REFINED_Im_Gen(X_Train_D1, nn, map_in_int_AR,
                                    gene_names_AR, coords_AR)
X_Val_D1_REFINED = REFINED_Im_Gen(X_Val_D1, nn, map_in_int_AR, gene_names_AR,
                                  coords_AR)
X_Test_D1_REFINED = REFINED_Im_Gen(X_Test_D1, nn, map_in_int_AR, gene_names_AR,
                                   coords_AR)

X_Train_D2_REFINED = REFINED_Im_Gen(X_Train_D2, nn, map_in_int_AR,
                                    gene_names_AR, coords_AR)
X_Val_D2_REFINED = REFINED_Im_Gen(X_Val_D2, nn, map_in_int_AR, gene_names_AR,
                                  coords_AR)
X_Test_D2_REFINED = REFINED_Im_Gen(X_Test_D2, nn, map_in_int_AR, gene_names_AR,
                                   coords_AR)

sz = X_Train_D1_REFINED.shape
Width = int(math.sqrt(sz[1]))
Height = int(math.sqrt(sz[1]))
            'rb') as file:
        gene_names_MDS, coords_MDS, map_in_int_MDS = pickle.load(file)

    #%% importing tensorflow
    import tensorflow as tf
    from tensorflow.keras import layers, models
    from tensorflow.keras.callbacks import EarlyStopping
    Model_Names = ["MDS", "LE", "LLE", "ISO", "VOLUMETRIC"]
    Results_Data = np.zeros((5, 4))
    nn = 26
    cnt = 0  # Image size = sqrt(#features (drug descriptors))
    for modell in Model_Names:

        # Convert data into images using the coordinates generated by REFINED
        if modell == "MDS":
            X_Train_REFINED = REFINED_Im_Gen(X_Train, nn, map_in_int_MDS,
                                             gene_names_MDS, coords_MDS)
            X_Val_REFINED = REFINED_Im_Gen(X_Validation, nn, map_in_int_MDS,
                                           gene_names_MDS, coords_MDS)
            X_Test_REFINED = REFINED_Im_Gen(X_Test, nn, map_in_int_MDS,
                                            gene_names_MDS, coords_MDS)
        elif modell == "LE":
            X_Train_REFINED = REFINED_Im_Gen(X_Train, nn, map_in_int_LE,
                                             gene_names_LE, coords_LE)
            X_Val_REFINED = REFINED_Im_Gen(X_Validation, nn, map_in_int_LE,
                                           gene_names_LE, coords_LE)
            X_Test_REFINED = REFINED_Im_Gen(X_Test, nn, map_in_int_LE,
                                            gene_names_LE, coords_LE)
        elif modell == "LLE":
            X_Train_REFINED = REFINED_Im_Gen(X_Train, nn, map_in_int_LLE,
                                             gene_names_LLE, coords_LLE)
            X_Val_REFINED = REFINED_Im_Gen(X_Validation, nn, map_in_int_LLE,
Exemplo n.º 8
0
X_Drug_Train_PCA = Random_Image_Gen(X_Drug_Train, pca_xy_Drug)
X_Drug_Val_PCA = Random_Image_Gen(X_Drug_Val, pca_xy_Drug)
X_Drug_Test_PCA = Random_Image_Gen(X_Drug_Test, pca_xy_Drug)

#################
##   REFINED   ##
#################
# The REFINED coordinates generated using the mpiHill_Hardcoded.py will be saved and loaded as pickle file then thos coordinates will be used for training, validation and test set to create the REFINED images.
# Note that, the REFINED coordinates of the Cell line data and Drug data are different. Therefore, they have to be loaded and used separately, as the REFINED CNN model has two separate arms, where one of them handles
# the cell line data and the other one handles the drug data.
# Cell
with open('REFINED_GDSC_Cell_1212.pickle', 'rb') as file:
    gene_names_cell, coords_cell, map_in_int_cell = pickle.load(file)

nn = math.ceil(np.sqrt(X_Cell_Train.shape[1]))
X_Cell_Train_REFINED = REFINED_Im_Gen(X_Cell_Train, nn, map_in_int_cell,
                                      gene_names_cell, coords_cell)
X_Cell_Val_REFINED = REFINED_Im_Gen(X_Cell_Val, nn, map_in_int_cell,
                                    gene_names_cell, coords_cell)
X_Cell_Test_REFINED = REFINED_Im_Gen(X_Cell_Test, nn, map_in_int_cell,
                                     gene_names_cell, coords_cell)
# Drug
with open('REFINED_GDSC_Drug.pickle', 'rb') as file:
    gene_names_drug, coords_drug, map_in_int_drug = pickle.load(file)

nn = math.ceil(np.sqrt(X_Drug_Train.shape[1]))
X_Drug_Train_REFINED = REFINED_Im_Gen(X_Drug_Train, nn, map_in_int_drug,
                                      gene_names_drug, coords_drug)
X_Drug_Val_REFINED = REFINED_Im_Gen(X_Drug_Val, nn, map_in_int_drug,
                                    gene_names_drug, coords_drug)
X_Drug_Test_REFINED = REFINED_Im_Gen(X_Drug_Test, nn, map_in_int_drug,
                                     gene_names_drug, coords_drug)