def get_patient_predictions_rfe(self,expression_file,ic50_file,patient_directory,target_features,drug): e_data,e_target,p_identifiers,p_data = dfm.get_cell_line_and_patient_expression_data_target_for_drug(expression_file,ic50_file,patient_directory,1.0,drug) step_length = int(len(e_data.tolist()[0]) / 100) + 1 model = RFE(self.model,target_features,step=step_length) model.fit(e_data,e_target) predictions = model.predict(p_data) all_features = dfm.get_cell_line_and_patient_expression_gene_intersection(dfm.get_cell_line_expression_frame(expression_file),dfm.get_patients_expression_frame(patient_directory))[0] top_features = [all_features[i] for i in xrange(0,len(all_features)) if model.support_[i]] return p_identifiers, predictions, top_features
def get_patient_predictions_threshold(self,expression_file,ic50_file,patient_directory,threshold,drug): """ Returns the predictions for which patients are likely to be sensitive to SMAPs and which are likely to be resistant. First trains a given SVM model on expression data, and then uses the trained model to predict patient outcome. Returns a list of patient identifiers, and a list of predictions about the patients response to a given drug. """ e_data,e_target,p_identifiers,p_data = dfm.get_cell_line_and_patient_expression_data_target_for_drug(expression_file,ic50_file,patient_directory,threshold,drug) self.model.fit(e_data,e_target) predictions = self.model.predict(p_data) return p_identifiers,predictions