├── LICENSE ├── README.md ├── code ├── data_loading.py ├── data_loading.pyc ├── inner_loop.py ├── inner_loop.pyc ├── layers.py ├── layers.pyc ├── meta_learner_cv.py ├── meta_learner_cv.pyc ├── mlp.py ├── mlp.pyc ├── score.py ├── score.pyc ├── simple_mlp.py ├── tcrp_cv.py ├── tcrp_train.py ├── utils.py └── utils.pyc ├── data ├── Sorafenib │ ├── NS_Sorafenib_feature.npy │ ├── NS_Sorafenib_label.npy │ ├── NS_feature_description.npy │ ├── PDTC_Sorafenib_feature.npy │ ├── PDTC_Sorafenib_label.npy │ ├── adrenal_gland_Sorafenib_feature.npy │ ├── adrenal_gland_Sorafenib_label.npy │ ├── adrenal_gland_feature_description.npy │ ├── autonomic_ganglia_Sorafenib_feature.npy │ ├── autonomic_ganglia_Sorafenib_label.npy │ ├── autonomic_ganglia_feature_description.npy │ ├── biliary_tract_Sorafenib_feature.npy │ ├── biliary_tract_Sorafenib_label.npy │ ├── biliary_tract_feature_description.npy │ ├── bone_Sorafenib_feature.npy │ ├── bone_Sorafenib_label.npy │ ├── bone_feature_description.npy │ ├── breast_Sorafenib_feature.npy │ ├── breast_Sorafenib_label.npy │ ├── breast_feature_description.npy │ ├── central_nervous_system_Sorafenib_feature.npy │ ├── central_nervous_system_Sorafenib_label.npy │ ├── central_nervous_system_feature_description.npy │ ├── cervix_Sorafenib_feature.npy │ ├── cervix_Sorafenib_label.npy │ ├── cervix_feature_description.npy │ ├── endometrium_Sorafenib_feature.npy │ ├── endometrium_Sorafenib_label.npy │ ├── endometrium_feature_description.npy │ ├── haematopoietic_and_lymphoid_tissue_Sorafenib_feature.npy │ ├── haematopoietic_and_lymphoid_tissue_Sorafenib_label.npy │ ├── haematopoietic_and_lymphoid_tissue_feature_description.npy │ ├── kidney_Sorafenib_feature.npy │ ├── kidney_Sorafenib_label.npy │ ├── kidney_feature_description.npy │ ├── large_intestine_Sorafenib_feature.npy │ ├── large_intestine_Sorafenib_label.npy │ ├── large_intestine_feature_description.npy │ ├── liver_Sorafenib_feature.npy │ ├── liver_Sorafenib_label.npy │ ├── liver_feature_description.npy │ ├── lung_Sorafenib_feature.npy │ ├── lung_Sorafenib_label.npy │ ├── lung_feature_description.npy │ ├── oesophagus_Sorafenib_feature.npy │ ├── oesophagus_Sorafenib_label.npy │ ├── oesophagus_feature_description.npy │ ├── ovary_Sorafenib_feature.npy │ ├── ovary_Sorafenib_label.npy │ ├── ovary_feature_description.npy │ ├── pancreas_Sorafenib_feature.npy │ ├── pancreas_Sorafenib_label.npy │ ├── pancreas_feature_description.npy │ ├── placenta_Sorafenib_feature.npy │ ├── placenta_Sorafenib_label.npy │ ├── placenta_feature_description.npy │ ├── pleura_Sorafenib_feature.npy │ ├── pleura_Sorafenib_label.npy │ ├── pleura_feature_description.npy │ ├── prostate_Sorafenib_feature.npy │ ├── prostate_Sorafenib_label.npy │ ├── prostate_feature_description.npy │ ├── salivary_gland_Sorafenib_feature.npy │ ├── salivary_gland_Sorafenib_label.npy │ ├── salivary_gland_feature_description.npy │ ├── skin_Sorafenib_feature.npy │ ├── skin_Sorafenib_label.npy │ ├── skin_feature_description.npy │ ├── small_intestine_Sorafenib_feature.npy │ ├── small_intestine_Sorafenib_label.npy │ ├── small_intestine_feature_description.npy │ ├── soft_tissue_Sorafenib_feature.npy │ ├── soft_tissue_Sorafenib_label.npy │ ├── soft_tissue_feature_description.npy │ ├── stomach_Sorafenib_feature.npy │ ├── stomach_Sorafenib_label.npy │ ├── stomach_feature_description.npy │ ├── testis_Sorafenib_feature.npy │ ├── testis_Sorafenib_label.npy │ ├── testis_feature_description.npy │ ├── thyroid_Sorafenib_feature.npy │ ├── thyroid_Sorafenib_label.npy │ ├── thyroid_feature_description.npy │ ├── upper_aerodigestive_tract_Sorafenib_feature.npy │ ├── upper_aerodigestive_tract_Sorafenib_label.npy │ ├── upper_aerodigestive_tract_feature_description.npy │ ├── urinary_tract_Sorafenib_feature.npy │ ├── urinary_tract_Sorafenib_label.npy │ ├── urinary_tract_feature_description.npy │ ├── vulva_Sorafenib_feature.npy │ ├── vulva_Sorafenib_label.npy │ └── vulva_feature_description.npy └── Sorafenib_tissue_map.pkl └── images └── Figure1_github-01.png /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 UC, San Diego Trey Ideker Lab 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | TCRP (Transfer of Cellular Response Prediction) is a few-shot machine learning algorithm to perform transfer learning for drug response predictions in cancer. It is used to train a neural network model using data in one experimental context (e.g. cell lines) that can be readily tuned to new contexts (e.g. patients) using few additional samples. In pilot experiments, the model has been shown to quickly adapt when switching among different tissue types and in moving from cell-line models to clinical contexts, including patient-derived tumor cells and patient-derived xenografts. 4 | 5 | This GitHub repository provides an implementation of TCRP as an easy-to-use Python program. 6 | 7 | **A refactored version of this code is being worked on [here](https://github.com/shfong/tcrp-reproduce)**. This refactorization makes the package installable and provides detailed examples. 8 | 9 | # Frequently Asked Questions 10 | 11 | [Click here for a list of FAQs](https://github.com/shfong/tcrp-reproduce/blob/public/tcrp-faq.md). 12 | 13 | # Publication 14 | 15 | Ma J, Fong SH, Luo Y., Bakkenist CJ, Shen JP, Mourragui S, Wessels LFA, Hafner M, Sharan R, Peng J, Ideker T. Few-shot learning creates predictive models of drug response that translate from high-throughput screens to individual patients. Nat Cancer. 2021 Feb;2(2):233-244. doi: 10.1038/s43018-020-00169-2. Epub 2021 Jan 25. PMID: 34223192 [Pubmed](https://pubmed.ncbi.nlm.nih.gov/34223192/) 16 | 17 | # Model Access 18 | 19 | The model can be downloaded here: https://idekerlab.ucsd.edu/projects/tcrp/tcrp_model.tar.gz 20 | 21 | # Model Overview 22 | Model overview 23 | 24 | # Directory Structure 25 | 26 | *code*: folder containing Python code for both neural network training and prediction. 27 | *data*: Training and testing data. We include the training data for the drug Sorafenib as an example. 28 | 29 | # Dependencies 30 | 31 | The code is developed under Python 2.7 and PyTorch 0.4.1.post2. See [here](https://pytorch.org/) for installation and basic tutorials. No other dependencies are required. 32 | 33 | # Data Preparations 34 | 35 | For the pre-training phase, please prepare the feature and label files for each task in the same folder. For the few-shot learning phase, please prepare the feature and label files for the target domain in the same folder used for pre-training. Use the option ‘-feature_dic’ to specify the name of the folder. These names can be changed in the ‘load_data’ and ‘load_data_PDTC’ functions in the util.py file. An example file, ‘Sorafenib_tissue_map.pkl’, is included in the data/ folder. Please use option ‘-tissue_list’ to specify the file to use. 36 | Please also prepare a ‘task list’ file to store the detailed information of each sub-task in the pre-training phase. It is a Python dictionary stored in a pickle file. The key of that dictionary is the name of the sub-task, which should be the same as the feature and label file. For example, if the sub-task is called ‘lung’, then the corresponding feature and label files should be ‘lung_Sorafenib_feature.npy’ and ‘large_Sorafenib_label.npy’, respectively. 37 | 38 | # Demo 39 | 40 | ## Run Command: 41 | 42 | ```python tcrp_train.py --drug Sorafenib --tissue_num 12 --meta_batch_size 10 --meta_lr 0.001 --inner_lr 0.001 --layer 1 --hidden 20 --K 1``` 43 | 44 | ## Output: 45 | 46 | The model trained for each epoch will be saved in the ‘--model_dic’ folder. Please modify the code in line 96 of tcrp_train.py if another location is desired for storing the models. 47 | 48 | ## Data Availability: 49 | 50 | The gene expression and somatic mutation profiles used in the paper for each cell line are from the Cancer Cell Line Encyclopedia (CCLE) project. These data can be downloaded from the DepMap website: http://depmap.org/portal/download/. 51 | The drug response data used in the paper for each cell line can be downloaded from the GDSC 1000 website: http://www.cancerrxgene.org/gdsc1000/GDSC1000_WebResources/. 52 | 53 | Expression data, somatic mutations and drug responses for the analysis of Patient-Derived Tumor Cells (PDTC) reported in the paper can be downloaded from the following URL: http://figshare.com/articles/Bruna_et_al_A_biobank_of_breast_cancer_explants_with_preserved_intra-tumor_heterogeneity_to_screen_anticancer_compounds_Cell_2016/2069274. 54 | 55 | All relevant data for the Patient Derived Xenograft (PDX) models can be extracted from Supplementary Table 1 of the paper ‘High-throughput screening using patient-derived tumor xenografts to predict clinical trial drug response.’ 56 | -------------------------------------------------------------------------------- /code/data_loading.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import random 3 | import copy 4 | import torch 5 | import torch.utils.data as du 6 | 7 | ''' 8 | def get_unseen_data_loader( feature, label, cat_label, K ): 9 | 10 | num_sample = feature.shape[0] 11 | index_list = np.random.permutation( num_sample ) 12 | 13 | train_index_list = index_list[0:K] 14 | test_index_list = index_list[K:] 15 | 16 | train_feature = torch.FloatTensor( feature[train_index_list,:] ) 17 | train_label = torch.FloatTensor( label[train_index_list,:] ) 18 | 19 | test_feature = torch.FloatTensor( feature[test_index_list,:] ) 20 | test_label = torch.FloatTensor( label[test_index_list,:] ) 21 | cat_test_label = torch.FloatTensor( cat_label[test_index_list,:] ) 22 | 23 | train_dataset = du.TensorDataset( train_feature.cuda(), train_label.cuda() ) 24 | train_loader = du.DataLoader( train_dataset, batch_size=train_feature.size(0)) 25 | 26 | test_dataset = du.TensorDataset( test_feature.cuda(), test_label.cuda(), cat_test_label.cuda() ) 27 | test_loader = du.DataLoader( test_dataset, batch_size=test_feature.size(0)) 28 | 29 | return train_loader, test_loader 30 | ''' 31 | def get_observed_data_loader(feature, label, tissue_index_list, K, batch_size, tissue_num): 32 | 33 | index_list = copy.deepcopy(tissue_index_list) 34 | train_sampled_index_list, test_sampled_index_list = [], [] 35 | 36 | #print 'tissue index list..', len(tissue_index_list) 37 | 38 | random_tissue_index = np.random.permutation( len(tissue_index_list) ) 39 | 40 | train_tissue_index_list = random_tissue_index[0:tissue_num] 41 | #train_tissue_index_list = random_tissue_index[0:-1] 42 | 43 | test_tissue_index_list = random_tissue_index[tissue_num:tissue_num*2] 44 | #test_tissue_index_list = [random_tissue_index[-1]] 45 | 46 | #print train_tissue_index_list 47 | #print test_tissue_index_list 48 | 49 | for tissue_index in train_tissue_index_list: 50 | 51 | sub_list = index_list[tissue_index] 52 | random.shuffle(sub_list) 53 | 54 | train_sampled_index_list += sub_list[0:K] 55 | 56 | for tissue_index in test_tissue_index_list: 57 | 58 | sub_list = index_list[tissue_index] 59 | random.shuffle(sub_list) 60 | 61 | test_sampled_index_list += sub_list[0:K] 62 | 63 | random.shuffle( train_sampled_index_list ) 64 | random.shuffle( test_sampled_index_list ) 65 | 66 | #print '===', train_sampled_index_list 67 | train_feature = torch.FloatTensor( feature[train_sampled_index_list,:] ) 68 | train_label = torch.FloatTensor( label[train_sampled_index_list,:] ) 69 | 70 | dataset = du.TensorDataset(train_feature, train_label) 71 | loader = du.DataLoader( dataset, batch_size=batch_size, pin_memory=True ) 72 | 73 | train_data_list = [] 74 | for batch_feature, batch_label in loader: 75 | if batch_feature.size()[0] == 1: 76 | continue 77 | train_data_list.append( (batch_feature.cuda(), batch_label.cuda()) ) 78 | 79 | #print '===', test_sampled_index_list,feature.shape 80 | test_feature = torch.FloatTensor( feature[test_sampled_index_list,:] ) 81 | test_label = torch.FloatTensor( label[test_sampled_index_list,:] ) 82 | 83 | dataset = du.TensorDataset( test_feature, test_label ) 84 | loader = du.DataLoader( dataset, batch_size=batch_size, pin_memory=True ) 85 | 86 | test_data_list = [] 87 | for batch_feature, batch_label in loader: 88 | if batch_feature.size()[0] == 1: 89 | continue 90 | test_data_list.append( (batch_feature.cuda(), batch_label.cuda()) ) 91 | 92 | return train_data_list, test_data_list 93 | 94 | def get_observed_data_loader2(feature, label, tissue_index_list, K, batch_size): 95 | 96 | index_list = copy.deepcopy(tissue_index_list) 97 | train_sampled_index_list, test_sampled_index_list = [], [] 98 | 99 | for index, sub_list in enumerate(index_list): 100 | 101 | random.shuffle(sub_list) 102 | 103 | if 2*K < len(sub_list): 104 | train_sampled_index_list += sub_list[0:K] 105 | test_sampled_index_list += sub_list[K:2*K] 106 | 107 | elif K < len(sub_list): 108 | train_sampled_index_list += sub_list[0:K] 109 | random.shuffle(sub_list) 110 | test_sampled_index_list += sub_list[0:K] 111 | 112 | else: 113 | train_sampled_index_list += sub_list 114 | test_sampled_index_list += sub_list 115 | 116 | random.shuffle( train_sampled_index_list ) 117 | random.shuffle( test_sampled_index_list ) 118 | 119 | train_feature = torch.FloatTensor( feature[train_sampled_index_list,:] ) 120 | train_label = torch.FloatTensor( label[train_sampled_index_list,:] ) 121 | 122 | dataset = du.TensorDataset(train_feature, train_label) 123 | loader = du.DataLoader( dataset, batch_size=batch_size, pin_memory=True ) 124 | 125 | train_data_list = [] 126 | for batch_feature, batch_label in loader: 127 | train_data_list.append( (batch_feature.cuda(), batch_label.cuda()) ) 128 | 129 | test_feature = torch.FloatTensor( feature[test_sampled_index_list,:] ) 130 | test_label = torch.FloatTensor( label[test_sampled_index_list,:] ) 131 | 132 | dataset = du.TensorDataset( test_feature, test_label ) 133 | loader = du.DataLoader( dataset, batch_size=batch_size, pin_memory=True ) 134 | 135 | test_data_list = [] 136 | for batch_feature, batch_label in loader: 137 | test_data_list.append( (batch_feature.cuda(), batch_label.cuda()) ) 138 | 139 | return train_data_list, test_data_list 140 | 141 | def load_unseen_data_loader(train_index_file, test_index_file, feature, label, K, trial, batch_size=1): 142 | 143 | train_index_list = np.load( train_index_file ) 144 | test_index_list = np.load( test_index_file ) 145 | 146 | train_feature = torch.FloatTensor( feature[train_index_list,:] ) 147 | train_label = torch.FloatTensor( label[train_index_list,] ) 148 | 149 | test_feature = torch.FloatTensor( feature[test_index_list,:] ) 150 | test_label = torch.FloatTensor( label[test_index_list,] ) 151 | 152 | train_dataset = du.TensorDataset( train_feature, train_label ) 153 | test_dataset = du.TensorDataset( test_feature, test_label ) 154 | 155 | train_loader = du.DataLoader(train_dataset, batch_size=1) 156 | train_data_list = [] 157 | for batch_feature, batch_label in train_loader: 158 | train_data_list.append((batch_feature.cuda(), batch_label.cuda())) 159 | 160 | test_loader = du.DataLoader(test_dataset, batch_size=batch_size) 161 | test_data_list = [] 162 | for batch_feature, batch_label in test_loader: 163 | test_data_list.append((batch_feature.cuda(), batch_label.cuda())) 164 | 165 | return train_data_list, test_data_list 166 | 167 | def get_unseen_data_loader(feature, label, K, batch_size=1): 168 | 169 | index_list = np.random.permutation(feature.shape[0]) 170 | 171 | train_index_list = index_list[0:K] 172 | test_index_list = index_list[K:] 173 | 174 | train_feature = torch.FloatTensor( feature[train_index_list,:] ) 175 | train_label = torch.FloatTensor( label[train_index_list,] ) 176 | 177 | test_feature = torch.FloatTensor( feature[test_index_list,:] ) 178 | test_label = torch.FloatTensor( label[test_index_list,] ) 179 | 180 | train_dataset = du.TensorDataset( train_feature, train_label ) 181 | test_dataset = du.TensorDataset( test_feature, test_label ) 182 | 183 | train_loader = du.DataLoader(train_dataset, batch_size=batch_size) 184 | train_data_list = [] 185 | for batch_feature, batch_label in train_loader: 186 | train_data_list.append((batch_feature.cuda(), batch_label.cuda())) 187 | 188 | test_loader = du.DataLoader(test_dataset, batch_size=batch_size) 189 | test_data_list = [] 190 | for batch_feature, batch_label in test_loader: 191 | test_data_list.append((batch_feature.cuda(), batch_label.cuda())) 192 | 193 | return train_data_list, test_data_list 194 | -------------------------------------------------------------------------------- /code/data_loading.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/code/data_loading.pyc -------------------------------------------------------------------------------- /code/inner_loop.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from collections import OrderedDict 3 | 4 | import torch 5 | import torch.nn as nn 6 | from torch.autograd import Variable 7 | 8 | from layers import * 9 | from score import * 10 | from data_loading import * 11 | from mlp import mlp 12 | 13 | class InnerLoop(mlp): 14 | # This module performs the inner loop of MAML 15 | # The forward method updates weights with gradient steps on training data, 16 | # then computes and returns a meta-gradient w.r.t. validation data 17 | 18 | def __init__(self, num_updates, step_size, feature_dim, layer, hidden): 19 | 20 | super(InnerLoop, self).__init__(feature_dim, layer, hidden) 21 | # Number of updates to be taken 22 | self.num_updates = num_updates 23 | 24 | # Step size for the updates 25 | self.step_size = step_size 26 | 27 | self.loss_fn = nn.MSELoss() 28 | 29 | def net_forward(self, x, weights=None): 30 | return super(InnerLoop, self).forward(x, weights) 31 | 32 | def forward_pass(self, in_, target, weights=None): 33 | 34 | # Run data through net, return loss and output 35 | input_var = torch.autograd.Variable(in_) 36 | target_var = torch.autograd.Variable(target) 37 | # Run the batch through the net, compute loss 38 | 39 | out, _ = self.net_forward(input_var, weights) 40 | loss = self.loss_fn(out, target_var) 41 | 42 | return loss, out 43 | 44 | def forward(self, train_loader, val_loader): 45 | 46 | ##### Test net before training, should be random accuracy #### 47 | #tr_pre_loss, tr_pre_acc = evaluate(self, train_loader) 48 | #val_pre_loss, val_pre_acc = evaluate(self, val_loader) 49 | 50 | fast_weights = OrderedDict((name, param) for (name, param) in self.named_parameters()) 51 | 52 | for i in range(self.num_updates): 53 | 54 | #print 'inner step', i, 55 | in_, target = train_loader.__iter__().next() 56 | 57 | if i==0: 58 | loss, _ = self.forward_pass( in_, target ) 59 | grads = torch.autograd.grad( loss, self.parameters(), create_graph=True ) 60 | else: 61 | loss, _ = self.forward_pass(in_, target, fast_weights) 62 | grads = torch.autograd.grad(loss, fast_weights.values(), create_graph=True) 63 | 64 | fast_weights = OrderedDict((name, param - self.step_size*grad) for ((name, param), grad) in zip(fast_weights.items(), grads)) 65 | ##### Test net after training, should be better than random #### 66 | tr_post_loss, tr_post_acc = evaluate( self, train_loader, 0, fast_weights ) 67 | val_post_loss, val_post_acc = evaluate( self, val_loader, 0, fast_weights ) 68 | 69 | #print 'Train Inner Loss', tr_pre_loss, tr_post_loss, 'Train Inner Corr', tr_pre_acc, tr_post_acc 70 | #print 'Val Inner step Loss', val_pre_loss, val_post_loss, 'Val Inner step Acc', val_pre_acc, val_post_acc 71 | 72 | # Compute the meta gradient and return it 73 | in_, target = val_loader.__iter__().next() 74 | 75 | loss,_ = self.forward_pass( in_, target, fast_weights ) 76 | loss = loss / in_.size()[0] # normalize loss 77 | 78 | grads = torch.autograd.grad( loss, self.parameters() ) 79 | meta_grads = {name:g for ((name, _), g) in zip(self.named_parameters(), grads)} 80 | metrics = (tr_post_loss, tr_post_acc, val_post_loss, val_post_acc) 81 | #metrics = (0,0,0,0) 82 | 83 | return metrics, meta_grads 84 | 85 | -------------------------------------------------------------------------------- /code/inner_loop.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/code/inner_loop.pyc -------------------------------------------------------------------------------- /code/layers.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | import torch 4 | from torch.nn import functional as F 5 | 6 | ''' 7 | Functional definitions of common layers 8 | Useful for when weights are exposed rather 9 | than being contained in modules 10 | ''' 11 | 12 | def linear(input, weight, bias): 13 | #return F.linear(input, weight.cuda(), bias.cuda()) 14 | return F.linear(input, weight, bias) 15 | 16 | def relu(input): 17 | return F.threshold(input, 0, 0, inplace=True) 18 | 19 | def batchnorm(input, weight=None, bias=None, running_mean=None, running_var=None, training=True, eps=1e-5, momentum=0.1): 20 | ''' momentum = 1 restricts stats to the current mini-batch ''' 21 | # This hack only works when momentum is 1 and avoids needing to track running stats 22 | # by substuting dummy variables 23 | #running_mean = torch.zeros(np.prod(np.array(input.data.size()[1]))).cuda() 24 | #running_var = torch.ones(np.prod(np.array(input.data.size()[1]))).cuda() 25 | 26 | running_mean = torch.zeros(np.prod(np.array(input.data.size()[1]))).cuda() 27 | running_var = torch.ones(np.prod(np.array(input.data.size()[1]))).cuda() 28 | 29 | return F.batch_norm(input, running_mean, running_var, weight, bias, training, momentum, eps) 30 | -------------------------------------------------------------------------------- /code/layers.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/code/layers.pyc -------------------------------------------------------------------------------- /code/meta_learner_cv.py: -------------------------------------------------------------------------------- 1 | import time 2 | import argparse 3 | import numpy as np 4 | import random 5 | import torch 6 | import torch.nn.functional as F 7 | import torch.optim as optim 8 | import os 9 | import glob 10 | from torch.autograd import Variable 11 | import sys 12 | import torch.nn as nn 13 | import pickle 14 | import copy 15 | from data_loading import * 16 | from utils import * 17 | from score import * 18 | from inner_loop import InnerLoop 19 | from mlp import mlp 20 | 21 | # This is the meta-learner class 22 | 23 | class dataset(object): 24 | def __init__(self, feature, label): 25 | super(self.__class__, self).__init__() 26 | self.feature = feature 27 | self.label = label 28 | 29 | class MetaLearner(object): 30 | def __init__(self, meta_dataset, fs_dataset, K, meta_lr, inner_lr, layer, hidden, tissue_num, meta_batch_size, inner_batch_size, num_updates, num_inner_updates, tissue_index_list, patience=3, num_trials=10 ): 31 | 32 | super(self.__class__, self).__init__() 33 | 34 | self.meta_dataset = meta_dataset 35 | self.fs_dataset = fs_dataset 36 | 37 | self.meta_batch_size = meta_batch_size 38 | self.inner_batch_size = inner_batch_size 39 | self.num_updates = num_updates 40 | self.num_inner_updates = num_inner_updates 41 | self.num_trials = num_trials 42 | self.hidden = hidden 43 | self.patience = patience 44 | self.feature_num = self.fs_dataset.feature.shape[1] 45 | 46 | self.K = K 47 | self.meta_lr = meta_lr 48 | self.inner_lr = inner_lr 49 | self.layer = layer 50 | self.hidden = hidden 51 | self.tissue_index_list = tissue_index_list 52 | self.tissue_num = tissue_num 53 | 54 | self.observed_tissue_model = mlp(self.feature_num, layer, hidden) 55 | self.observed_opt = torch.optim.Adam(self.observed_tissue_model.parameters(), lr=self.meta_lr, betas=(0.9, 0.99), eps=1e-05) 56 | self.inner_net = InnerLoop(self.num_inner_updates, self.inner_lr, self.feature_num, layer, hidden) 57 | 58 | #torch.cuda.manual_seed(args.seed) 59 | self.observed_tissue_model.cuda() 60 | self.inner_net.cuda() 61 | 62 | def zero_shot_test(self, unseen_train_loader, unseen_vali_loader, unseen_test_loader): 63 | 64 | unseen_tissue_model = mlp( self.feature_num, self.layer, self.hidden ) 65 | 66 | # First need to copy the original meta learning model 67 | unseen_tissue_model.copy_weights( self.observed_tissue_model ) 68 | unseen_tissue_model.cuda() 69 | unseen_tissue_model.eval() 70 | 71 | train_performance = evaluate_cv( unseen_tissue_model, unseen_train_loader) 72 | vali_performance = evaluate_cv( unseen_tissue_model, unseen_vali_loader) 73 | test_performance = evaluate_cv( unseen_tissue_model, unseen_test_loader) 74 | 75 | return train_performance, vali_performance, test_performance, np.mean(tissue_loss) 76 | 77 | def meta_update(self, test_loader, ls): 78 | 79 | #Walk in 'Meta update' function 80 | in_, target = test_loader.__iter__().next() 81 | 82 | # We use a dummy forward / backward pass to get the correct grads into self.net 83 | loss, out = forward_pass(self.observed_tissue_model, in_, target) 84 | 85 | # Unpack the list of grad dicts 86 | gradients = { k: sum(d[k] for d in ls) for k in ls[0].keys() } 87 | 88 | #for k, val, in gradients.items(): 89 | # gradients[k] = val / args.meta_batch_size 90 | # print k,':',gradients[k] 91 | 92 | # Register a hook on each parameter in the net that replaces the current dummy grad 93 | # with our grads accumulated across the meta-batch 94 | hooks = [] 95 | 96 | for (k,v) in self.observed_tissue_model.named_parameters(): 97 | 98 | def get_closure(): 99 | key = k 100 | def replace_grad(grad): 101 | return gradients[key] 102 | return replace_grad 103 | 104 | hooks.append(v.register_hook(get_closure())) 105 | 106 | # Compute grads for current step, replace with summed gradients as defined by hook 107 | self.observed_opt.zero_grad() 108 | 109 | loss.backward() 110 | # Update the net parameters with the accumulated gradient according to optimizer 111 | self.observed_opt.step() 112 | # Remove the hooks before next training phase 113 | for h in hooks: 114 | h.remove() 115 | 116 | def unseen_tissue_learn(self, unseen_train_loader, unseen_test_loader): 117 | 118 | unseen_tissue_model = mlp( self.feature_num, self.layer, self.hidden ) 119 | 120 | # First need to copy the original meta learning model 121 | unseen_tissue_model.copy_weights( self.observed_tissue_model ) 122 | unseen_tissue_model.cuda() 123 | #unseen_tissue_model.train() 124 | unseen_tissue_model.eval() 125 | 126 | unseen_opt = torch.optim.SGD(unseen_tissue_model.parameters(), lr=self.inner_lr) 127 | #unseen_opt = torch.optim.Adam(unseen_tissue_model.parameters(), lr=self.inner_lr, betas=(0.9, 0.99), eps=1e-05) 128 | 129 | # Here test_feature and test_label contains only one tissue info 130 | #unseen_train_loader, unseen_test_loader = get_unseen_data_loader(test_feature, test_label, K, args.inner_batch_size) 131 | for i in range(self.num_inner_updates): 132 | 133 | in_, target = unseen_train_loader.__iter__().next() 134 | loss, _ = forward_pass( unseen_tissue_model, in_, target ) 135 | unseen_opt.zero_grad() 136 | loss.backward() 137 | unseen_opt.step() 138 | 139 | # Test on the rest of cell lines in this tissue (unseen_test_loader) 140 | mtrain_loss, mtrain_pear_corr, mtrain_spearman_corr, _, _ = evaluate_new( unseen_tissue_model, unseen_train_loader,1 ) 141 | mtest_loss, mtest_pear_corr, mtest_spearman_corr, test_prediction, test_true_label = evaluate_new( unseen_tissue_model, unseen_test_loader,0 ) 142 | 143 | return mtrain_loss, mtrain_pear_corr, mtrain_spearman_corr, mtest_loss, mtest_pear_corr, mtest_spearman_corr, test_prediction, test_true_label 144 | 145 | def train(self): 146 | 147 | best_train_loss_test_corr, best_train_corr_test_corr = 0, 0 148 | best_train_corr_test_scorr, best_train_scorr_test_scorr = 0, 0 149 | 150 | best_train_corr_model = '' 151 | 152 | unseen_train_loader, unseen_test_loader = get_unseen_data_loader( self.fs_dataset.feature, self.fs_dataset.label, self.K ) 153 | #unseen_train_loader, unseen_test_loader = get_unseen_data_loader( self.fs_dataset.feature, self.fs_dataset.label, self.fs_catdata, self.K ) 154 | 155 | # Here the training process starts 156 | best_fewshot_train_corr, best_fewshot_train_loss = -2, 1000 157 | best_fewshot_test_corr, best_fewshot_test_loss = -2, 1000 158 | best_train_loss_epoch, best_train_corr_epoch = 0, 0 159 | 160 | best_fewshot_train_spearman_corr, best_fewshot_test_spearman_corr = -2, -2 161 | best_train_spearman_corr_epoch = 0 162 | 163 | train_loss, train_corr = np.zeros((self.num_updates,)), np.zeros((self.num_updates,)) 164 | test_loss, test_corr = np.zeros((self.num_updates,)), np.zeros((self.num_updates,)) 165 | train_spearman_corr, test_spearman_corr = np.zeros((self.num_updates,)), np.zeros((self.num_updates,)) 166 | 167 | for epoch in range( self.num_updates ): 168 | 169 | # Collect a meta batch update 170 | grads = [] 171 | meta_train_loss, meta_train_corr, meta_val_loss, meta_val_corr = np.zeros((self.meta_batch_size,)), np.zeros((self.meta_batch_size,)), np.zeros((self.meta_batch_size,)), np.zeros((self.meta_batch_size,)) 172 | 173 | self.inner_net.copy_weights( self.observed_tissue_model ) 174 | for i in range( self.meta_batch_size ): 175 | 176 | observed_train_loader, observed_test_loader = get_observed_data_loader( self.meta_dataset.feature, self.meta_dataset.label, self.tissue_index_list, self.K, self.inner_batch_size, self.tissue_num ) 177 | 178 | #self.inner_net.copy_weights( self.observed_tissue_model ) 179 | 180 | metrics, g = self.inner_net.forward( observed_train_loader, observed_test_loader ) 181 | grads.append( g ) 182 | 183 | meta_train_loss[i], meta_train_corr[i], meta_val_loss[i], meta_val_corr[i] = metrics 184 | 185 | # Perform the meta update 186 | self.meta_update( observed_test_loader, grads ) 187 | 188 | #meta_train_loss_mean, meta_train_corr_mean, meta_val_loss_mean, meta_val_corr_mean = meta_train_loss.mean(), meta_train_corr.mean(), meta_val_loss.mean(), meta_val_corr.mean() 189 | 190 | ## Evaluate K shot test tasks 191 | train_loss[epoch], train_corr[epoch], train_spearman_corr[epoch], test_loss[epoch], test_corr[epoch], test_spearman_corr[epoch], _, _ = self.unseen_tissue_learn( unseen_train_loader, unseen_test_loader ) 192 | 193 | if test_loss[epoch] < best_fewshot_test_loss: 194 | best_fewshot_test_loss = test_loss[epoch] 195 | 196 | if test_corr[epoch] > best_fewshot_test_corr: 197 | best_fewshot_test_corr = test_corr[epoch] 198 | 199 | if train_loss[epoch] < best_fewshot_train_loss: 200 | best_fewshot_train_loss = train_loss[epoch] 201 | best_train_loss_epoch = epoch 202 | 203 | if train_corr[epoch] > best_fewshot_train_corr: 204 | best_fewshot_train_corr = train_corr[epoch] 205 | best_train_corr_epoch = epoch 206 | best_train_corr_model = self.observed_tissue_model 207 | 208 | if train_spearman_corr[epoch] > best_fewshot_train_spearman_corr: 209 | best_fewshot_train_spearman_corr = train_spearman_corr[epoch] 210 | best_train_spearman_corr_epoch = epoch 211 | 212 | if test_spearman_corr[epoch] > best_fewshot_test_spearman_corr: 213 | best_fewshot_test_spearman_corr = test_spearman_corr[epoch] 214 | best_test_spearman_epoch = epoch 215 | 216 | print 'Few shot', epoch, 'train_loss:', float('%.3f'%train_loss[epoch]), 'train_pearson:', float('%.3f'%train_corr[epoch]), 'train_spearman:', float('%.3f'%train_spearman_corr[epoch]), 217 | print 'test_loss:', float('%.3f'%test_loss[epoch]), 'test_pearson:', float('%.3f'%test_corr[epoch]), 'test_spearman:', float('%.3f'%test_spearman_corr[epoch]) 218 | 219 | best_train_loss_test_corr = test_corr[ best_train_loss_epoch ] 220 | best_train_corr_test_corr = test_corr[ best_train_corr_epoch ] 221 | best_train_corr_test_scorr = test_spearman_corr[ best_train_corr_epoch ] 222 | best_train_scorr_test_scorr = test_spearman_corr[ best_train_spearman_corr_epoch ] 223 | 224 | print '--trial summerize--', 'best_train_loss_test_corr:', float('%.3f'%best_train_loss_test_corr), 'best_train_corr_test_corr', float('%.3f'%best_train_corr_test_corr), 'best_train_corr_test_scorr', float('%.3f'%best_train_corr_test_scorr), 'best_train_scorr_test_corr', float('%.3f'%best_train_scorr_test_scorr) 225 | 226 | return best_train_loss_test_corr, best_train_corr_test_corr, best_train_corr_test_scorr, best_train_scorr_test_scorr, best_train_corr_model 227 | -------------------------------------------------------------------------------- /code/meta_learner_cv.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/code/meta_learner_cv.pyc -------------------------------------------------------------------------------- /code/mlp.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import numpy as np 4 | import torch 5 | import torch.utils.data as du 6 | from torch.autograd import Variable 7 | import torch.nn as nn 8 | import torch.nn.functional as F 9 | from layers import * 10 | 11 | class mlp(nn.Module): 12 | 13 | def __init__(self, feature_dim, layer, hidden): 14 | 15 | super(mlp, self).__init__() 16 | 17 | self.add_module( 'linear1', nn.Linear(feature_dim, hidden) ) 18 | #self.add_module( 'bn1', nn.BatchNorm1d(hidden) ) 19 | 20 | if layer == 2: 21 | self.add_module( 'linear2', nn.Linear(hidden, hidden) ) 22 | #self.add_module( 'bn2', nn.BatchNorm1d(hidden) ) 23 | 24 | self.add_module( 'linear3', nn.Linear(hidden, 1) ) 25 | 26 | self.layer = layer 27 | self.loss_fn = nn.MSELoss() 28 | 29 | self._init_weights() 30 | 31 | def forward(self, x, weights = None): 32 | 33 | if weights == None: 34 | 35 | hidden = F.relu( self._modules['linear1'](x) ) 36 | #out = F.tanh( self._modules['bn1'](out) ) 37 | #hidden = F.relu( self._modules['bn1']( self._modules['linear1'](x) ) ) 38 | 39 | if self.layer == 2: 40 | hidden = F.relu( self._modules['linear2']( hidden ) ) 41 | #out = F.tanh( self._modules['bn2'](out) ) 42 | #hidden = F.relu( self._modules['bn2']( self._modules['linear2']( hidden ) ) ) 43 | 44 | #out = self._modules['linear3']( hidden ) 45 | #out = F.tanh( out ) 46 | out = self._modules['linear3']( hidden ) 47 | 48 | else: 49 | 50 | #hidden = F.tanh( linear(x, weights['linear1.weight'], weights['linear1.bias']) ) 51 | #out = batchnorm(out, weight = weights['bn1.weight'], bias = weights['bn1.bias'], momentum=1) 52 | #hidden = linear(x, weights['linear1.weight'], weights['linear1.bias']) 53 | #hidden = relu( batchnorm( hidden, weight = weights['bn1.weight'], bias = weights['bn1.bias']) ) 54 | hidden = relu( linear(x, weights['linear1.weight'], weights['linear1.bias']) ) 55 | 56 | if self.layer == 2: 57 | #hidden = F.tanh( linear(hidden, weights['linear2.weight'], weights['linear2.bias']) ) 58 | #out = batchnorm(out, weight = weights['bn2.weight'], bias = weights['bn2.bias'], momentum=1) 59 | #hidden = linear( hidden, weights['linear2.weight'], weights['linear2.bias'] ) 60 | #hidden = relu( batchnorm( hidden, weight = weights['bn2.weight'], bias = weights['bn2.bias']) ) 61 | hidden = relu( linear( hidden, weights['linear2.weight'], weights['linear2.bias'] ) ) 62 | 63 | #out = F.tanh( linear(hidden, weights['linear3.weight'], weights['linear3.bias']) ) 64 | out = linear(hidden, weights['linear3.weight'], weights['linear3.bias']) 65 | 66 | return out, hidden 67 | 68 | def copy_weights(self, net): 69 | # Set this module's weights to be the same as those of 'net' 70 | for m_from, m_to in zip(net.modules(), self.modules()): 71 | if isinstance(m_to, nn.Linear) or isinstance(m_to, nn.BatchNorm1d): 72 | 73 | m_to.weight.data = m_from.weight.data.clone() 74 | 75 | if m_to.bias is not None: 76 | m_to.bias.data = m_from.bias.data.clone() 77 | 78 | def net_forward(self, x, weights=None): 79 | return self.forward(x, weights) 80 | 81 | def _init_weights(self): 82 | # Set weights to Gaussian, biases to zero 83 | torch.manual_seed(1337) 84 | torch.cuda.manual_seed(1337) 85 | torch.cuda.manual_seed_all(1337) 86 | 87 | #print 'init weights' 88 | 89 | for m in self.modules(): 90 | if isinstance(m, nn.BatchNorm1d): 91 | m.weight.data.fill_(1) 92 | m.bias.data.zero_() 93 | elif isinstance(m, nn.Linear): 94 | n = m.weight.size(1) 95 | m.weight.data.normal_(0, 0.01) 96 | #m.bias.data.zero_() + 1 97 | m.bias.data = torch.ones(m.bias.data.size()) 98 | -------------------------------------------------------------------------------- /code/mlp.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/code/mlp.pyc -------------------------------------------------------------------------------- /code/score.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import torch 3 | from torch.autograd import Variable 4 | from utils import * 5 | from scipy import stats 6 | 7 | # Helper methods for evaluating a classification network 8 | 9 | def forward_pass(net, in_, target, weights=None): 10 | # Forward in_ through the net, return loss and output 11 | 12 | input_var = Variable(in_).cuda() 13 | target_var = Variable(target).cuda() 14 | 15 | # Second output is hidden 16 | out, _ = net.net_forward(input_var, weights) 17 | 18 | # Here loss is MSE 19 | loss = net.loss_fn(out, target_var) 20 | 21 | return loss, out 22 | 23 | def evaluate_new_PDX(net, loader, train_flag, weights=None): 24 | #evaluate the net on the data in the loader 25 | net.eval() 26 | 27 | test_predict = torch.zeros(0,0).cuda() 28 | test_label = torch.zeros(0,0).cuda() 29 | cat_test_label = torch.zeros(0,0).cuda() 30 | total_loss = 0 31 | 32 | for i, (in_, target, cat_target) in enumerate(loader): 33 | 34 | input_var = Variable(in_) 35 | target_var = Variable(target) 36 | 37 | # Second output is hidden 38 | out, _ = net.net_forward(input_var, weights) 39 | 40 | # Here loss is MSE 41 | l = net.loss_fn(out, target_var) 42 | 43 | test_predict = torch.cat([test_predict, out.data], 0) 44 | test_label = torch.cat([test_label, target_var.data], 0) 45 | cat_test_label = torch.cat([cat_test_label, cat_target], 0) 46 | 47 | #print l.data.cpu().numpy().shape 48 | total_loss += l.data.cpu().numpy() 49 | 50 | if test_predict.size()[0] <= 1: 51 | pear_corr = -1 52 | else: 53 | pear_corr = pearson_corr(test_predict, test_label) 54 | 55 | rho, pval = stats.spearmanr( test_predict.data.cpu().numpy() ,test_label.data.cpu().numpy() ) 56 | 57 | predict_data = {} 58 | predict_data['test_predict'] = test_predict.data.cpu().numpy() 59 | predict_data['test_label'] = test_label.data.cpu().numpy() 60 | predict_data['cat_test_label'] = cat_test_label.cpu().numpy() 61 | 62 | return float(total_loss) / test_label.size()[0], pear_corr, rho, predict_data 63 | 64 | def evaluate_new(net, loader, train_flag, weights=None): 65 | #evaluate the net on the data in the loader 66 | net.eval() 67 | 68 | test_predict = torch.zeros(0,0).cuda() 69 | test_label = torch.zeros(0,0).cuda() 70 | total_loss = 0 71 | 72 | for i, (in_, target) in enumerate(loader): 73 | 74 | input_var = Variable(in_) 75 | target_var = Variable(target) 76 | 77 | # Second output is hidden 78 | out, _ = net.net_forward(input_var, weights) 79 | 80 | # Here loss is MSE 81 | l = net.loss_fn(out, target_var) 82 | 83 | test_predict = torch.cat([test_predict, out.data], 0) 84 | test_label = torch.cat([test_label, target_var.data], 0) 85 | 86 | #print l.data.cpu().numpy().shape 87 | total_loss += l.data.cpu().numpy() 88 | 89 | if test_predict.size()[0] <= 1: 90 | pear_corr = -1 91 | else: 92 | pear_corr = pearson_corr(test_predict, test_label) 93 | 94 | rho, pval = stats.spearmanr( test_predict.data.cpu().numpy() ,test_label.data.cpu().numpy() ) 95 | 96 | return float(total_loss) / test_label.size()[0], pear_corr, rho, test_predict, test_label 97 | 98 | def evaluate_cv(net, loader, weights=None): 99 | #evaluate the net on the data in the loader 100 | net.eval() 101 | 102 | test_predict = torch.zeros(0,0).cuda() 103 | test_label = torch.zeros(0,0).cuda() 104 | total_loss = 0 105 | #print 'In size evaluate' 106 | 107 | for i, (in_, target) in enumerate(loader): 108 | 109 | input_var = Variable(in_) 110 | target_var = Variable(target) 111 | 112 | # Second output is hidden 113 | out, _ = net.net_forward(input_var, weights) 114 | 115 | # Here loss is MSE 116 | l = net.loss_fn(out, target_var) 117 | 118 | test_predict = torch.cat([test_predict, out.data], 0) 119 | test_label = torch.cat([test_label, target_var.data], 0) 120 | 121 | total_loss += l.data.cpu().numpy() 122 | 123 | pear_corr = pearson_corr(test_predict, test_label) 124 | return float(total_loss) / test_label.size()[0], pear_corr, test_predict 125 | 126 | def evaluate(net, loader, train_flag, weights=None): 127 | #evaluate the net on the data in the loader 128 | net.eval() 129 | 130 | test_predict = torch.zeros(0,0).cuda() 131 | test_label = torch.zeros(0,0).cuda() 132 | total_loss = 0 133 | #print 'In size evaluate' 134 | 135 | for i, (in_, target) in enumerate(loader): 136 | 137 | input_var = Variable(in_) 138 | target_var = Variable(target) 139 | 140 | # Second output is hidden 141 | out, _ = net.net_forward(input_var, weights) 142 | 143 | # Here loss is MSE 144 | l = net.loss_fn(out, target_var) 145 | 146 | test_predict = torch.cat([test_predict, out.data], 0) 147 | test_label = torch.cat([test_label, target_var.data], 0) 148 | 149 | #total_loss += l.data.cpu().numpy()[0] 150 | total_loss += l.data.cpu().numpy() 151 | #aa, bb = out.data.cpu().numpy(), target_var.data.cpu().numpy() 152 | #print np.mean(np.square(aa - bb)), l.data.cpu().numpy()[0] 153 | 154 | if test_predict.size()[0] <= 3: 155 | pear_corr = -1 156 | else: 157 | pear_corr = pearson_corr(test_predict, test_label) 158 | 159 | #print test_predict.cpu().numpy()[:,0] 160 | #print test_label.cpu().numpy()[:,0] 161 | #print 'finish evaluate' 162 | ''' 163 | test_predict = test_predict.cpu().numpy() 164 | for i in range(test_predict.shape[0]): 165 | print test_predict[i,0], 166 | print '' 167 | 168 | test_label = test_label.cpu().numpy() 169 | for i in range(test_label.shape[0]): 170 | print test_label[i,0], 171 | print '' 172 | ''' 173 | return float(total_loss) / test_label.size()[0], pear_corr 174 | -------------------------------------------------------------------------------- /code/score.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/code/score.pyc -------------------------------------------------------------------------------- /code/simple_mlp.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import numpy as np 4 | import torch 5 | import torch.utils.data as du 6 | from torch.autograd import Variable 7 | import torch.nn as nn 8 | import torch.nn.functional as F 9 | from utils import * 10 | 11 | class simple_mlp(nn.Module): 12 | 13 | def __init__(self, feature_dim, layer, hidden): 14 | 15 | super(simple_mlp, self).__init__() 16 | 17 | self.layer = layer 18 | 19 | self.linear1 = nn.Linear(feature_dim, hidden) 20 | #self.bn1= nn.BatchNorm1d( hidden ) 21 | 22 | if layer == 2: 23 | self.linear2 = nn.Linear(hidden, hidden) 24 | #self.bn2 = nn.BatchNorm1d( hidden ) 25 | 26 | self.linear3 = nn.Linear(hidden, 1) 27 | #self.bn3 = nn.BatchNorm1d( 1 ) 28 | 29 | def forward(self, x, weights = None): 30 | 31 | #hidden = F.tanh( self.bn1( self.linear1(x) ) ) 32 | #hidden = self.bn1 ( F.tanh( self.linear1(x) ) ) 33 | #hidden = F.relu( self.bn1 ( self.linear1(x) ) ) 34 | hidden = F.relu( self.linear1(x) ) 35 | 36 | if self.layer == 2: 37 | #hidden = F.tanh( self.bn2( self.linear2(hidden) ) ) 38 | #hidden = self.bn2( F.tanh( self.linear2(hidden) ) ) 39 | #hidden = F.relu( self.bn2( self.linear2(hidden) ) ) 40 | hidden = F.relu( self.linear2(hidden) ) 41 | 42 | #out = F.tanh( self.linear3(hidden) ) 43 | out = self.linear3(hidden) 44 | #out = self.bn3(out) 45 | 46 | return out, hidden 47 | -------------------------------------------------------------------------------- /code/tcrp_cv.py: -------------------------------------------------------------------------------- 1 | import time 2 | import argparse 3 | import numpy as np 4 | import random 5 | import torch 6 | import torch.nn.functional as F 7 | import torch.optim as optim 8 | import os 9 | import glob 10 | from torch.autograd import Variable 11 | import sys 12 | import torch.nn as nn 13 | import pickle 14 | import copy 15 | from data_loading import * 16 | from utils import * 17 | from score import * 18 | from inner_loop import InnerLoop 19 | from mlp import mlp 20 | from meta_learner_cv import * 21 | 22 | # Training settings 23 | # This model uses expresion + somatic mutations + CNV as features 24 | # It applies the cross validation framework proposed by Siamese Network 25 | parser = argparse.ArgumentParser() 26 | work_dic = '/share/data/jinbodata/siqi/mut_exp_cnv_data/challenge_GDSC_PDTC/' 27 | #work_dic = '/share/data/jinbodata/siqi/mut_exp_cnv_data/challenge_GDSC_PDX/' 28 | #data_dic = '/share/data/jinbodata/siqi/mut_exp_cnv_data/challenge_4/tissue_test_data/' 29 | 30 | parser.add_argument('--tissue', type=str, default='UPPER_AERODIGESTIVE_TRACT', help='Testing tissue, using the rest tissues for training') 31 | parser.add_argument('--drug', type=str, default='AC220', help='Treated drug') 32 | parser.add_argument('--gene', type=str, default='TP53', help='Knockout genes') 33 | parser.add_argument('--no-cuda', action='store_true', default=False, help='Disables CUDA training.') 34 | parser.add_argument('--seed', type=int, default=100, help='Random seed.') 35 | parser.add_argument('--K', type=int, default=10, help='Perform K shot learning') 36 | parser.add_argument('--meta_batch_size', type=int, default=32, help='Meta-learning batch size, i.e. how many different tasks we need sample') 37 | parser.add_argument('--inner_batch_size', type=int, default=10, help='Batch size for each individual learning job') 38 | parser.add_argument('--num_updates', type=int, default=30, help='Number of training epochs') 39 | parser.add_argument('--num_inner_updates', type=int, default=1, help='Initial learning rate') 40 | parser.add_argument('--num_trials', type=int, default=50, help='Number of trials for unseen tissue') 41 | parser.add_argument('--hidden', type=int, default=60, help='Number of hidden units of NN for single task') 42 | parser.add_argument('--patience', type=int, default=3, help='Patience') 43 | parser.add_argument('--tissue_list', type=str, default=work_dic + 'cell_line_data/tissue_cell_line_list.pkl', help='Cell line list for different tissues') 44 | parser.add_argument('--log_folder', type=str, default=work_dic+'Log/', help='Log folder') 45 | 46 | parser.add_argument('--meta_lr', type=float, default=0.001, help='Learning rate for meta-learning update') 47 | parser.add_argument('--inner_lr', type=float, default=0.001, help='Learning rate for ') 48 | parser.add_argument('--tissue_num', type=int, default=12, help='Tissue number evolved in the inner update') 49 | parser.add_argument('--layer', type=int, default=1, help='Number of layers of NN for single task') 50 | 51 | args = parser.parse_args() 52 | args.cuda = not args.no_cuda and torch.cuda.is_available() 53 | 54 | drug = args.drug 55 | K = args.K 56 | num_trials = args.num_trials 57 | meta_batch_size = args.meta_batch_size 58 | inner_batch_size = args.inner_batch_size 59 | num_updates = args.num_updates 60 | num_inner_updates = args.num_inner_updates 61 | patience = args.patience 62 | 63 | #random.seed(args.seed) 64 | #np.random.seed(args.seed) 65 | #torch.manual_seed(args.seed) 66 | 67 | tissue_list = work_dic + drug + '_tissue_map.pkl' 68 | print tissue_list 69 | # Load tissue cell line mapping 70 | with open(tissue_list, 'rb') as f: 71 | tissue_map = pickle.load(f) 72 | 73 | # Load data 74 | cv_feature_list, cv_label_list, meta_tissue_index_list, test_feature_list, test_label_list, test_tissue_list = load_data_cell_line(tissue_map, drug, K) 75 | 76 | #PDX_feature, PDX_label = load_data_PDX( args.drug ) 77 | 78 | layer, hidden, meta_lr, inner_lr, tissue_num = args.layer, args.hidden, args.meta_lr, args.inner_lr, args.tissue_num 79 | 80 | best_fewshot_train_corr_list = [] 81 | best_fewshot_test_corr_list = [] 82 | 83 | for i, test_tissue in enumerate(test_tissue_list): 84 | 85 | #print 'Validate tissue', test_tissue, cv_feature_list[i].shape 86 | 87 | meta_dataset = dataset(cv_feature_list[i], cv_label_list[i]) 88 | test_dataset = dataset(test_feature_list[i], test_label_list[i]) 89 | 90 | meta_learner = MetaLearner( meta_dataset, test_dataset, K, meta_lr, inner_lr, layer, hidden, tissue_num, meta_batch_size, inner_batch_size, num_updates, num_inner_updates, meta_tissue_index_list[i], num_trials ) 91 | 92 | best_fewshot_train_loss, best_fewshot_train_corr, best_fewshot_test_loss, best_fewshot_test_corr = meta_learner.train() 93 | 94 | print test_tissue, 'best few-shot train loss', best_fewshot_train_loss, 'best few-shot train corr', best_fewshot_train_corr 95 | print 'best few-shot test loss', best_fewshot_test_loss, 'best few-shot test corr', best_fewshot_test_corr 96 | 97 | if best_fewshot_train_corr != -1: 98 | best_fewshot_train_corr_list.append(best_fewshot_train_corr) 99 | 100 | if best_fewshot_test_corr != -1: 101 | best_fewshot_test_corr_list.append( best_fewshot_test_corr ) 102 | 103 | print 'Avg_test corr', np.asarray(best_fewshot_train_corr_list).mean(), np.asarray(best_fewshot_test_corr_list).mean() 104 | 105 | -------------------------------------------------------------------------------- /code/tcrp_train.py: -------------------------------------------------------------------------------- 1 | import time 2 | import argparse 3 | import numpy as np 4 | import random 5 | import torch 6 | import torch.nn.functional as F 7 | import torch.optim as optim 8 | import os 9 | import glob 10 | from torch.autograd import Variable 11 | import sys 12 | import torch.nn as nn 13 | import pickle 14 | import copy 15 | from data_loading import * 16 | from utils import * 17 | from score import * 18 | from inner_loop import InnerLoop 19 | from mlp import mlp 20 | from meta_learner_cv import * 21 | 22 | # Training settings 23 | # This model uses expresion + somatic mutations as features 24 | # It applies the cross validation framework proposed by Siamese Network 25 | parser = argparse.ArgumentParser() 26 | 27 | parser.add_argument('--feature_dic', type=str, default='/home-nfs/siqi/TCRP/data/Sorafenib/', help='Feature folder') 28 | parser.add_argument('--model_dic', type=str, default='/cellar/users/majianzhu/TCRP/models/', help='Feature folder') 29 | parser.add_argument('--drug', type=str, default='AC220', help='Treated drug') 30 | parser.add_argument('--seed', type=int, default=19, help='Random seed.') 31 | parser.add_argument('--K', type=int, default=10, help='Perform K shot learning') 32 | parser.add_argument('--meta_batch_size', type=int, default=32, help='Meta-learning batch size, i.e. how many different tasks we need sample') 33 | parser.add_argument('--inner_batch_size', type=int, default=10, help='Batch size for each individual learning job') 34 | parser.add_argument('--num_updates', type=int, default=10, help='Number of training epochs') 35 | parser.add_argument('--num_inner_updates', type=int, default=1, help='Initial learning rate') 36 | parser.add_argument('--num_out_updates', type=int, default=20, help='Final learning rate') 37 | parser.add_argument('--num_trials', type=int, default=50, help='Number of trials for unseen tissue') 38 | parser.add_argument('--hidden', type=int, default=60, help='Number of hidden units of NN for single task') 39 | parser.add_argument('--tissue_list', type=str, default='/home-nfs/siqi/TCRP/data/Sorafenib_tissue_map.pkl', help='Cell line list for different tissues, used for defining meta-tasks in the meta-learning phase') 40 | parser.add_argument('--meta_lr', type=float, default=0.001, help='Learning rate for meta-learning update') 41 | parser.add_argument('--inner_lr', type=float, default=0.001, help='Learning rate for ') 42 | parser.add_argument('--tissue_num', type=int, default=12, help='Tissue number evolved in the inner update') 43 | parser.add_argument('--layer', type=int, default=1, help='Number of layers of NN for single task') 44 | 45 | args = parser.parse_args() 46 | 47 | feature_dic = args.feature_dic 48 | drug = args.drug 49 | K = args.K 50 | num_trials = args.num_trials 51 | meta_batch_size = args.meta_batch_size 52 | inner_batch_size = args.inner_batch_size 53 | num_updates = args.num_updates 54 | num_inner_updates = args.num_inner_updates 55 | 56 | random.seed(args.seed) 57 | np.random.seed(args.seed) 58 | torch.manual_seed(args.seed) 59 | 60 | tissue_list = args.tissue_list 61 | print tissue_list 62 | # Load tissue cell line mapping 63 | with open(tissue_list, 'rb') as f: 64 | tissue_map = pickle.load(f) 65 | 66 | model_dic = args.model_dic + 'MODELS/' + drug + '/' 67 | 68 | if not os.path.exists(model_dic): 69 | mkdir_cmd = 'mkdir -p ' + model_dic 70 | os.system(mkdir_cmd) 71 | # Load data 72 | #cv_feature_list, cv_label_list, meta_tissue_index_list, test_feature_list, test_label_list, test_tissue_list = load_data_cell_line(tissue_map, drug, K) 73 | train_feature, train_label, tissue_index_list = load_data(tissue_map, drug, K, path = feature_dic) 74 | 75 | PDTC_feature, PDTC_label = load_data_PDTC( args.drug, path = feature_dic ) 76 | #PDX_feature, PDX_label = load_data_PDX( args.drug ) 77 | #best_param = (2,args.hidden,0.001,0.001,12) 78 | 79 | layer, hidden, meta_lr, inner_lr, tissue_num = args.layer, args.hidden, args.meta_lr, args.inner_lr, args.tissue_num 80 | 81 | meta_dataset = dataset(train_feature, train_label) 82 | test_dataset = dataset(PDTC_feature, PDTC_label) 83 | 84 | best_train_loss_test_corr_list, best_train_corr_test_corr_list, best_train_corr_test_scorr_list, best_train_scorr_test_scorr_list = [], [], [], [] 85 | 86 | for i in range(num_trials): 87 | meta_learner = MetaLearner( meta_dataset, test_dataset, K, meta_lr, inner_lr, layer, hidden, tissue_num, meta_batch_size, inner_batch_size, num_updates, num_inner_updates, tissue_index_list, num_trials ) 88 | 89 | best_train_loss_test_corr, best_train_corr_test_corr, best_train_corr_test_scorr, best_train_scorr_test_scorr, best_model = meta_learner.train() 90 | best_train_loss_test_corr_list.append(best_train_loss_test_corr) 91 | best_train_corr_test_corr_list.append(best_train_corr_test_corr) 92 | best_train_corr_test_scorr_list.append(best_train_corr_test_scorr) 93 | best_train_scorr_test_scorr_list.append(best_train_scorr_test_scorr) 94 | 95 | # Please uncomment this line to save your pre-train models 96 | #torch.save(best_model, model_dic + '/model_'+str(K)+'_trail_' + str(i)) 97 | 98 | a = np.asarray(best_train_loss_test_corr_list).mean() 99 | b = np.asarray(best_train_corr_test_corr_list).mean() 100 | c = np.asarray(best_train_corr_test_scorr_list).mean() 101 | d = np.asarray(best_train_scorr_test_scorr_list).mean() 102 | 103 | print 'PDTC best_train_loss_test_corr:', float('%.3f'%a), 'best_train_corr_test_corr', float('%.3f'%b), 'best_train_corr_test_scorr', float('%.3f'%c), 'best_train_scorr_test_scorr', float('%.3f'%d) 104 | 105 | -------------------------------------------------------------------------------- /code/utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import scipy.sparse as sp 3 | import torch 4 | import sys 5 | from scipy import stats 6 | from sklearn import preprocessing 7 | import torch.utils.data as du 8 | 9 | def cut_data_into_pieces(feature, label): 10 | 11 | dataset = du.TensorDataset( torch.FloatTensor(feature), torch.FloatTensor(label) ) 12 | data_loader = du.DataLoader( dataset, batch_size=200 ) 13 | data_list = [] 14 | 15 | for batch_feature, batch_label in data_loader: 16 | data_list.append((batch_feature.cuda(), batch_label.cuda())) 17 | 18 | return data_list 19 | 20 | def encode_onehot(labels): 21 | classes = set(labels) 22 | classes_dict = {c: np.identity(len(classes))[i, :] for i, c in enumerate(classes)} 23 | labels_onehot = np.array(list(map(classes_dict.get, labels)), dtype=np.int32) 24 | return labels_onehot 25 | 26 | def pearson_corr(x, y): 27 | 28 | xx = x - torch.mean(x) 29 | yy = y - torch.mean(y) 30 | 31 | norm_x = torch.norm(xx, 2) 32 | norm_y = torch.norm(yy,2) 33 | 34 | if norm_x ==0 or norm_y ==0: 35 | return 0 36 | else: 37 | return torch.sum(xx*yy) / ( norm_x * norm_y ) 38 | 39 | def load_merged_data(tissue_map, drug, path='/home-nfs/wangsheng/GDSC_PDX_WP_feature/'): 40 | 41 | #Load dataset 42 | print 'Loading feature and label files...' 43 | 44 | feature_list, label_list, tissue2id, tissue_index_list = [], [], [], [] 45 | sample2tissue = {} 46 | sample_num = 0 47 | 48 | for tissue, cell_line_list in tissue_map.items(): 49 | 50 | tissue2id.append( tissue ) 51 | 52 | path_suffix = path + drug + '/' + tissue + '_' + drug 53 | 54 | feature_list.append( np.load(path_suffix + '_feature.npy') ) 55 | label_list.append( np.load(path_suffix + '_label.npy').reshape(-1,1) ) 56 | 57 | sub_list = [] 58 | for i in range(len(cell_line_list)): 59 | sub_list.append( i+sample_num ) 60 | sample2tissue[i+sample_num] = tissue 61 | 62 | tissue_index_list.append( sub_list ) 63 | 64 | sample_num += len(cell_line_list) 65 | 66 | #print tissue, 'contains', len(cell_line_list), 'cell lines, accumulate', sample_num, 'cell lines', feature_list[-1].shape 67 | 68 | train_feature = np.concatenate(feature_list, axis=0) 69 | train_label = np.concatenate(label_list, axis=0) 70 | 71 | #scaler = preprocessing.StandardScaler().fit(train_feature) 72 | #train_feature = scaler.transform(train_feature) 73 | 74 | #path_suffix = path + drug + '/' + 'BREAST_' + drug 75 | #drug_test_feature = np.load(path_suffix + '_feature.npy') 76 | #drug_test_label = np.load(path_suffix + '_label.npy').reshape(-1,1) 77 | #test_feature = scaler.transform(drug_test_feature) 78 | 79 | path_suffix = path + drug + '/' + 'PDX_' + drug 80 | 81 | PDX_feature = np.load( path_suffix + '_feature.npy' ) 82 | PDX_label = np.load( path_suffix + '_BestAvgResponse_label.npy' ).reshape(-1,1) 83 | #PDX_cat_label = np.load( path_suffix + '_ResponseCategory_label.npy').reshape(-1,1) 84 | #PDX_cat_label = np.load( path_suffix + '_TimeToDouble_label.npy').reshape(-1,1) 85 | 86 | #scaler = preprocessing.StandardScaler().fit(PDX_feature) 87 | #PDX_feature = scaler.transform(PDX_feature) 88 | 89 | #print 'ddddd', np.argwhere(np.isnan(PDX_label)) 90 | #print PDX_label 91 | scaler2 = preprocessing.StandardScaler().fit(PDX_label) 92 | PDX_label = scaler2.transform(PDX_label) 93 | 94 | print 'Cell line feature dimension', train_feature.shape, train_label.shape 95 | print 'PDX feature dimension', PDX_feature.shape, PDX_label.shape 96 | 97 | return train_feature, train_label, tissue_index_list, PDX_feature, PDX_label, sample2tissue 98 | 99 | # need to edit this function 100 | #def load_data_cell_line(tissue_map, drug, K, path='/share/data/jinbodata/siqi/mut_exp_cnv_data/challenge_GDSC_PDTC/GDSC_PPI_feature/'): 101 | #def load_data_cell_line(tissue_map, drug, K, path='/share/data/jinbodata/siqi/mut_exp_cnv_data/challenge_GDSC_PDTC/GDSC_won-parafac_feature/'): 102 | def load_data_cell_line(tissue_map, drug, K, path='/home-nfs/wangsheng/GDSC_PDX_WP_feature/'): 103 | #Load dataset 104 | print 'Loading feature and label files...' 105 | feature_map, label_map = {}, {} 106 | all_tissue_feature_list = [] 107 | 108 | for tissue, cell_line_list in tissue_map.items(): 109 | 110 | path_suffix = path + drug + '/' + tissue + '_' + drug 111 | tissue_feature = np.load(path_suffix + '_feature.npy') 112 | tissue_label = np.load(path_suffix + '_label.npy').reshape(-1,1) 113 | 114 | feature_map[ tissue + '_' + drug ] = tissue_feature 115 | label_map[ tissue + '_' + drug ] = tissue_label 116 | 117 | all_tissue_feature_list.append(tissue_feature) 118 | 119 | all_tissue_train_feature = np.concatenate(all_tissue_feature_list, axis=0) 120 | scaler = preprocessing.StandardScaler().fit(all_tissue_train_feature) 121 | #train_feature = scaler.transform(all_tissue_train_feature) 122 | print 'all tissue shape', all_tissue_train_feature.shape 123 | 124 | cv_feature_list, cv_label_list, cv_tissue_index_list = [], [], [] 125 | vali_feature_list, vali_label_list, vali_tissue_list = [], [], [] 126 | 127 | for temp_tissue, temp_cell_line_list in tissue_map.items(): 128 | 129 | if len(temp_cell_line_list) == 0: 130 | continue 131 | feature_map[ temp_tissue+'_'+drug ] = scaler.transform( feature_map[ temp_tissue+'_'+drug ] ) 132 | #print temp_tissue, feature_map[ temp_tissue+'_'+drug ].shape 133 | 134 | for temp_tissue, temp_cell_line_list in tissue_map.items(): 135 | 136 | if len(temp_cell_line_list) <= K: 137 | continue 138 | else: 139 | vali_feature_list.append( feature_map[ temp_tissue+'_'+drug ] ) 140 | vali_label_list.append( label_map[ temp_tissue+'_'+drug ] ) 141 | vali_tissue_list.append( temp_tissue ) 142 | 143 | feature_list, label_list, tissue_index_list = [], [], [] 144 | sample_num = 0 145 | 146 | for tissue, cell_line_list in tissue_map.items(): 147 | 148 | if tissue == temp_tissue: 149 | continue 150 | 151 | feature_list.append( feature_map[ tissue + '_' + drug ] ) 152 | label_list.append( label_map[ tissue + '_' + drug ] ) 153 | 154 | sub_list = [] 155 | for i in range( len(cell_line_list) ): 156 | sub_list.append( i+sample_num ) 157 | 158 | tissue_index_list.append( sub_list ) 159 | sample_num += len( cell_line_list ) 160 | 161 | train_feature = np.concatenate(feature_list, axis=0) 162 | train_label = np.concatenate(label_list, axis=0) 163 | 164 | cv_feature_list.append( train_feature ) 165 | cv_label_list.append( train_label ) 166 | cv_tissue_index_list.append( tissue_index_list ) 167 | 168 | print 'Cross validation', len(cv_feature_list), len(cv_label_list), len(vali_feature_list), len(vali_label_list) 169 | print 'Vali dimension', cv_feature_list[0].shape, vali_feature_list[0].shape, vali_label_list[0].shape 170 | 171 | #return train_feature, train_label, tissue_index_list, drug_test_feature, drug_test_label, sample2tissue 172 | return cv_feature_list, cv_label_list, cv_tissue_index_list, vali_feature_list, vali_label_list, vali_tissue_list 173 | 174 | #def load_data_PDTC(drug, path='/share/data/jinbodata/siqi/mut_exp_cnv_data/challenge_GDSC_PDTC/GDSC_PPI_feature/'): 175 | #def load_data_PDTC(drug, path='/share/data/jinbodata/siqi/mut_exp_cnv_data/challenge_GDSC_PDTC/GDSC_won-parafac_feature/'): 176 | def load_data_PDTC(drug, path='/home-nfs/wangsheng/challenge_GDSC_PDTC/GDSC_PPI_feature/'): 177 | #path_suffix = path + drug + '/' + 'PDTC_' + drug 178 | path_suffix = path + '/' + 'PDTC_' + drug 179 | 180 | PDTC_feature = np.load( path_suffix + '_feature.npy' ) 181 | PDTC_label = np.load( path_suffix + '_label.npy' ).reshape(-1,1) 182 | 183 | scaler = preprocessing.StandardScaler().fit(PDTC_feature) 184 | PDTC_feature = scaler.transform(PDTC_feature) 185 | 186 | #print 'ddddd', np.argwhere(np.isnan(PDX_label)) 187 | #print PDX_label 188 | #scaler2 = preprocessing.StandardScaler().fit(PDTC_label) 189 | #PDTC_label = scaler2.transform(PDTC_label) 190 | 191 | print 'PDTC feature dimension', PDTC_feature.shape, PDTC_label.shape 192 | 193 | #return train_feature, train_label, tissue_index_list, drug_test_feature, drug_test_label, sample2tissue 194 | return PDTC_feature, PDTC_label 195 | 196 | #def load_data_PDX(drug, path='/share/data/jinbodata/siqi/mut_exp_cnv_data/challenge_GDSC_PDTC/GDSC_PPI_feature/'): 197 | #def load_data_PDX(drug, scaler, path='/home-nfs/siqi/CancerDrugPDX/challenge_GDSC_PDX/GDSC_WON_feature/'): 198 | def load_data_PDX(drug, scaler, path='/home-nfs/wangsheng/GDSC_PDX_WP_feature/'): 199 | path_suffix = path + drug + '/' + 'PDX_' + drug 200 | 201 | PDX_feature = np.load( path_suffix + '_feature.npy' ) 202 | PDX_label = np.load( path_suffix + '_BestAvgResponse_label.npy' ).reshape(-1,1) 203 | #PDX_cat_label = np.load( path_suffix + '_ResponseCategory_label.npy').reshape(-1,1) 204 | PDX_cat_label = np.load( path_suffix + '_TimeToDouble_label.npy').reshape(-1,1) 205 | 206 | print PDX_feature.shape, '====' 207 | scaler = preprocessing.StandardScaler().fit(PDX_feature) 208 | PDX_feature = scaler.transform(PDX_feature) 209 | 210 | #print 'ddddd', np.argwhere(np.isnan(PDX_label)) 211 | #print PDX_label 212 | scaler2 = preprocessing.StandardScaler().fit(PDX_label) 213 | PDX_label = scaler2.transform(PDX_label) 214 | 215 | print 'PDX feature dimension', PDX_feature.shape, PDX_label.shape 216 | 217 | #return train_feature, train_label, tissue_index_list, drug_test_feature, drug_test_label, sample2tissue 218 | return PDX_feature, PDX_label, PDX_cat_label 219 | 220 | #def load_data(tissue_map, drug, K, path='/share/data/jinbodata/siqi/mut_exp_cnv_data/challenge_GDSC_PDTC/GDSC_PPI_feature/'): 221 | #def load_data(tissue_map, drug, K, path='/share/data/jinbodata/siqi/mut_exp_cnv_data/challenge_GDSC_PDTC/GDSC_won-parafac_feature/'): 222 | #def load_data(tissue_map, drug, K, path='/home-nfs/siqi/CancerDrugPDX/challenge_GDSC_PDX/GDSC_WON_feature/'): 223 | def load_data(tissue_map, drug, K, path='/home-nfs/wangsheng/challenge_GDSC_PDTC/GDSC_PPI_feature/'): 224 | #Load dataset 225 | print 'Loading feature and label files...' 226 | 227 | feature_list, label_list, tissue_index_list = [], [], [] 228 | sample_num = 0 229 | 230 | for tissue, cell_line_list in tissue_map.items(): 231 | 232 | if len(cell_line_list) == 0: 233 | continue 234 | 235 | #path_suffix = path + drug + '/' + tissue + '_' + drug 236 | path_suffix = path + '/' + tissue + '_' + drug 237 | 238 | feature_list.append( np.load(path_suffix + '_feature.npy') ) 239 | label_list.append( np.load(path_suffix + '_label.npy').reshape(-1,1) ) 240 | 241 | sub_list = [] 242 | for i in range(len(cell_line_list)): 243 | sub_list.append( i+sample_num ) 244 | 245 | tissue_index_list.append(sub_list) 246 | sample_num += len(cell_line_list) 247 | #print tissue, 'contains', len(cell_line_list), 'cell lines, accumulate', sample_num, 'cell lines' 248 | #print np.mean(feature_list[-1]) 249 | #print tissue, sub_list 250 | 251 | train_feature = np.concatenate(feature_list, axis=0) 252 | train_label = np.concatenate(label_list, axis=0) 253 | 254 | scaler = preprocessing.StandardScaler().fit(train_feature) 255 | train_feature = scaler.transform(train_feature) 256 | 257 | print 'Drug feature dimension', train_feature.shape, train_label.shape 258 | 259 | return train_feature, train_label, tissue_index_list 260 | #return train_feature, train_label, tissue_index_list, scaler 261 | 262 | def normalize_adj(mx): 263 | """Row-normalize sparse matrix""" 264 | rowsum = np.array(mx.sum(1)) 265 | r_inv_sqrt = np.power(rowsum, -0.5).flatten() 266 | r_inv_sqrt[np.isinf(r_inv_sqrt)] = 0. 267 | r_mat_inv_sqrt = sp.diags(r_inv_sqrt) 268 | return mx.dot(r_mat_inv_sqrt).transpose().dot(r_mat_inv_sqrt) 269 | 270 | def normalize_features(mx): 271 | """Row-normalize sparse matrix""" 272 | rowsum = np.array(mx.sum(1)) 273 | r_inv = np.power(rowsum, -1).flatten() 274 | r_inv[np.isinf(r_inv)] = 0. 275 | r_mat_inv = sp.diags(r_inv) 276 | mx = r_mat_inv.dot(mx) 277 | return mx 278 | 279 | 280 | def accuracy(output, labels): 281 | preds = output.max(1)[1].type_as(labels) 282 | correct = preds.eq(labels).double() 283 | correct = correct.sum() 284 | return correct / len(labels) 285 | 286 | -------------------------------------------------------------------------------- /code/utils.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/code/utils.pyc -------------------------------------------------------------------------------- /data/Sorafenib/NS_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/NS_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/NS_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/NS_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/NS_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/NS_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/PDTC_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/PDTC_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/PDTC_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/PDTC_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/adrenal_gland_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/adrenal_gland_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/adrenal_gland_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/adrenal_gland_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/adrenal_gland_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/adrenal_gland_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/autonomic_ganglia_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/autonomic_ganglia_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/autonomic_ganglia_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/autonomic_ganglia_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/autonomic_ganglia_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/autonomic_ganglia_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/biliary_tract_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/biliary_tract_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/biliary_tract_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/biliary_tract_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/biliary_tract_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/biliary_tract_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/bone_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/bone_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/bone_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/bone_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/bone_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/bone_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/breast_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/breast_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/breast_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/breast_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/breast_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/breast_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/central_nervous_system_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/central_nervous_system_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/central_nervous_system_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/central_nervous_system_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/central_nervous_system_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/central_nervous_system_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/cervix_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/cervix_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/cervix_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/cervix_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/cervix_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/cervix_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/endometrium_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/endometrium_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/endometrium_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/endometrium_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/endometrium_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/endometrium_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/haematopoietic_and_lymphoid_tissue_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/haematopoietic_and_lymphoid_tissue_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/haematopoietic_and_lymphoid_tissue_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/haematopoietic_and_lymphoid_tissue_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/haematopoietic_and_lymphoid_tissue_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/haematopoietic_and_lymphoid_tissue_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/kidney_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/kidney_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/kidney_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/kidney_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/kidney_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/kidney_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/large_intestine_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/large_intestine_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/large_intestine_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/large_intestine_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/large_intestine_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/large_intestine_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/liver_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/liver_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/liver_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/liver_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/liver_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/liver_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/lung_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/lung_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/lung_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/lung_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/lung_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/lung_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/oesophagus_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/oesophagus_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/oesophagus_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/oesophagus_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/oesophagus_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/oesophagus_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/ovary_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/ovary_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/ovary_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/ovary_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/ovary_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/ovary_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/pancreas_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/pancreas_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/pancreas_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/pancreas_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/pancreas_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/pancreas_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/placenta_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/placenta_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/placenta_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/placenta_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/placenta_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/placenta_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/pleura_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/pleura_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/pleura_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/pleura_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/pleura_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/pleura_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/prostate_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/prostate_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/prostate_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/prostate_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/prostate_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/prostate_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/salivary_gland_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/salivary_gland_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/salivary_gland_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/salivary_gland_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/salivary_gland_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/salivary_gland_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/skin_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/skin_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/skin_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/skin_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/skin_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/skin_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/small_intestine_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/small_intestine_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/small_intestine_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/small_intestine_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/small_intestine_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/small_intestine_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/soft_tissue_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/soft_tissue_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/soft_tissue_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/soft_tissue_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/soft_tissue_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/soft_tissue_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/stomach_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/stomach_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/stomach_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/stomach_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/stomach_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/stomach_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/testis_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/testis_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/testis_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/testis_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/testis_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/testis_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/thyroid_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/thyroid_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/thyroid_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/thyroid_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/thyroid_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/thyroid_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/upper_aerodigestive_tract_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/upper_aerodigestive_tract_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/upper_aerodigestive_tract_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/upper_aerodigestive_tract_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/upper_aerodigestive_tract_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/upper_aerodigestive_tract_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/urinary_tract_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/urinary_tract_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/urinary_tract_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/urinary_tract_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/urinary_tract_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/urinary_tract_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib/vulva_Sorafenib_feature.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/vulva_Sorafenib_feature.npy -------------------------------------------------------------------------------- /data/Sorafenib/vulva_Sorafenib_label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/vulva_Sorafenib_label.npy -------------------------------------------------------------------------------- /data/Sorafenib/vulva_feature_description.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib/vulva_feature_description.npy -------------------------------------------------------------------------------- /data/Sorafenib_tissue_map.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/data/Sorafenib_tissue_map.pkl -------------------------------------------------------------------------------- /images/Figure1_github-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idekerlab/TCRP/28c06c63b23e08f900982cf30b133596d71359b2/images/Figure1_github-01.png --------------------------------------------------------------------------------