def run_gene_prioritization_pipeline(self): """ Runs data cleaning for gene_prioritization_pipeline. Args: NA. Returns: validation_flag: Boolean type value indicating if input data is valid or not. message: A message indicates the status of current check. """ # Checks user spreadsheet data and phenotype data if self.user_spreadsheet_df is None or self.phenotype_df is None: return False, logger.logging # Imputes na value on user spreadsheet data user_spreadsheet_df_imputed = SpreadSheet.impute_na(self.user_spreadsheet_df, option=self.run_parameters['impute']) if user_spreadsheet_df_imputed is None: return False, logger.logging # Checks if value of inputs satisfy certain criteria: see details in function validate_inputs_for_gp_fp user_spreadsheet_val_chked, phenotype_val_checked = CommonUtil.validate_inputs_for_gp_fp( user_spreadsheet_df_imputed, self.phenotype_df, self.run_parameters['correlation_measure']) if user_spreadsheet_val_chked is None or phenotype_val_checked is None: return False, logger.logging # Removes NA value and duplication on column and row name user_spreadsheet_df_checked = SpreadSheet.remove_dataframe_indexer_duplication(user_spreadsheet_val_chked) # Checks the validity of gene name to see if it can be ensemble or not user_spreadsheet_df_cleaned, map_filtered_dedup, mapping = SpreadSheet.map_ensemble_gene_name( user_spreadsheet_df_checked, self.run_parameters) if user_spreadsheet_df_cleaned is None or phenotype_val_checked is None: return False, logger.logging # Stores cleaned phenotype data (transposed) to a file, dimension: phenotype x sample IOUtil.write_to_file(phenotype_val_checked, self.run_parameters['phenotype_name_full_path'], self.run_parameters['results_directory'], '_ETL.tsv') IOUtil.write_to_file(user_spreadsheet_df_cleaned, self.run_parameters['spreadsheet_name_full_path'], self.run_parameters['results_directory'], '_ETL.tsv') # writes dedupped mapping between user_supplied_gene_name and ensemble name to a file IOUtil.write_to_file(map_filtered_dedup, self.run_parameters['spreadsheet_name_full_path'], self.run_parameters['results_directory'], '_MAP.tsv', use_index=True, use_header=False) # writes user supplied gene name along with its mapping status to a file IOUtil.write_to_file(mapping, self.run_parameters['spreadsheet_name_full_path'], self.run_parameters['results_directory'], '_User_To_Ensembl.tsv', use_index=False, use_header=True) logger.logging.append( 'INFO: Cleaned user spreadsheet has {} row(s), {} column(s).'.format( user_spreadsheet_df_cleaned.shape[0], user_spreadsheet_df_cleaned.shape[1])) logger.logging.append( 'INFO: Cleaned phenotype data has {} row(s), {} column(s).'.format(phenotype_val_checked.shape[0], phenotype_val_checked.shape[1])) return True, logger.logging
def run_feature_prioritization_pipeline(self): """ Run data cleaning for feature prioritization pipeline. Args: NA. Returns: validation_flag: Boolean type value indicating if input data is valid or not. message: A message indicates the status of current check. """ from knpackage.toolbox import get_spreadsheet_df if self.user_spreadsheet_df is None or self.phenotype_df is None: return False, logger.logging # Imputes na value on user spreadsheet data user_spreadsheet_df_imputed = SpreadSheet.impute_na(self.user_spreadsheet_df, option=self.run_parameters['impute']) if user_spreadsheet_df_imputed is None: return False, logger.logging # Checks if value of inputs satisfy certain criteria user_spreadsheet_val_chked, phenotype_val_chked = CommonUtil.validate_inputs_for_gp_fp( user_spreadsheet_df_imputed, self.phenotype_df, self.run_parameters[ 'correlation_measure']) if user_spreadsheet_val_chked is None or phenotype_val_chked is None: return False, logger.logging IOUtil.write_to_file(user_spreadsheet_val_chked, self.run_parameters['spreadsheet_name_full_path'], self.run_parameters['results_directory'], '_ETL.tsv') logger.logging.append( 'INFO: Cleaned user spreadsheet has {} row(s), {} column(s).'.format( user_spreadsheet_val_chked.shape[0], user_spreadsheet_val_chked.shape[1])) if self.run_parameters['correlation_measure'] == 't_test': phenotype_df = get_spreadsheet_df(self.run_parameters['phenotype_name_full_path']) phenotype_output = TransformationUtil.phenotype_expander(phenotype_df) else: phenotype_output = phenotype_val_chked IOUtil.write_to_file(phenotype_output, self.run_parameters['phenotype_name_full_path'], self.run_parameters['results_directory'], '_ETL.tsv') logger.logging.append( 'INFO: Cleaned phenotypic data has {} row(s), {} column(s).'.format(phenotype_val_chked.shape[0], phenotype_val_chked.shape[1])) return True, logger.logging