Load cell line features. load all data in the specified dataset and revise into the same format. Store all kinds of cell lines features in a dictionary. param: dataset: str
(dataset,args)
| 175 | |
| 176 | |
| 177 | def load_cellline_features(dataset,args): |
| 178 | ''' |
| 179 | Load cell line features. load all data in the specified dataset and revise into the same format. |
| 180 | Store all kinds of cell lines features in a dictionary. |
| 181 | |
| 182 | param: |
| 183 | dataset: str |
| 184 | ''' |
| 185 | |
| 186 | function_mapping = {'CCLE':'process_CCLE', 'Customized':'process_Customized'} |
| 187 | |
| 188 | def process_CCLE(): |
| 189 | |
| 190 | def load_file(postfix): |
| 191 | if args.train_test_mode == 'fine_tune': |
| 192 | df = pd.read_csv(os.path.join(ROOT_DIR, 'data', 'cell_line_data','CCLE','CCLE_%s.csv' % postfix),sep=',') |
| 193 | else: |
| 194 | df = pd.read_csv(os.path.join(ROOT_DIR, 'data', 'cell_line_data','CCLE','CCLE_%s.csv' % postfix),sep=',') |
| 195 | |
| 196 | |
| 197 | ## need to transform mut into one-hot dataframe |
| 198 | if postfix == 'mut': |
| 199 | # remove entre_id which is 0 |
| 200 | mu = df.loc[df['Entrez_Gene_Id'].values !=0] |
| 201 | |
| 202 | # transform data to one_hot format |
| 203 | clean_cells_ALL = list(set(list(mu['DepMap_ID']))) |
| 204 | clean_genes_ALL = list(set(list(mu['Entrez_Gene_Id']))) |
| 205 | CCLE_mu = pd.DataFrame(one_hot(mu,clean_cells_ALL,clean_genes_ALL), columns=['Entrez gene id']+clean_genes_ALL) |
| 206 | |
| 207 | |
| 208 | # use entrez gene id as index |
| 209 | if postfix != "mut": |
| 210 | df.columns = ['Entrez gene id']+[split_it_cell(_) for _ in list(df.columns)[1:]] |
| 211 | df_transpose = df.T |
| 212 | # set first row as column |
| 213 | df_transpose.columns = df_transpose.iloc[0] |
| 214 | processed_data = df_transpose.drop(df_transpose.index[0]) |
| 215 | # use entrez gene id as index |
| 216 | if postfix != "mut": |
| 217 | if postfix == "GSVA_scores": |
| 218 | # X_tr, means1, std1, means2, std2, feat_filt = normalize(df, norm='tanh_norm') |
| 219 | # X_tr = pd.DataFrame(X_tr,columns=df.columns,index=df.index) |
| 220 | processed_data = df |
| 221 | |
| 222 | else: |
| 223 | df.columns = ['Entrez gene id']+[split_it_cell(_) for _ in list(df.columns)[1:]] |
| 224 | df_transpose = df.T |
| 225 | # set first row as column |
| 226 | df_transpose.columns = df_transpose.iloc[0] |
| 227 | processed_data = df_transpose.drop(df_transpose.index[0]) |
| 228 | |
| 229 | else: |
| 230 | ## same as exp |
| 231 | mu_transpose = CCLE_mu.T |
| 232 | # set first row as column |
| 233 | mu_transpose.columns = mu_transpose.iloc[0] |
| 234 | processed_data = mu_transpose.drop(mu_transpose.index[0]) |