def cpdb_method_analysis_launcher( self, raw_meta: pd.DataFrame, counts: pd.DataFrame, counts_data: str, threshold: float, result_precision: int, subsampler: Subsampler = None, ) -> (pd.DataFrame, pd.DataFrame, pd.DataFrame): if threshold < 0 or threshold > 1: raise ThresholdValueException(threshold) meta = method_preprocessors.meta_preprocessor(raw_meta) counts = self._counts_validations(counts, meta) if subsampler is not None: counts = subsampler.subsample(counts) meta = meta.filter(items=list(counts), axis=0) interactions = self.database_manager.get_repository( 'interaction').get_all_expanded(include_gene=False) genes = self.database_manager.get_repository('gene').get_all_expanded() complex_composition = self.database_manager.get_repository( 'complex').get_all_compositions() complex_expanded = self.database_manager.get_repository( 'complex').get_all_expanded() means, significant_means, deconvoluted = cpdb_analysis_method.call( meta, counts, counts_data, interactions, genes, complex_expanded, complex_composition, self.separator, threshold, result_precision) return means, significant_means, deconvoluted
def cpdb_method_analysis_launcher(self, raw_meta: pd.DataFrame, counts: pd.DataFrame, threshold: float, result_precision: int, ) -> (pd.DataFrame, pd.DataFrame, pd.DataFrame): if threshold < 0 or threshold > 1: raise ThresholdValueException(threshold) meta = method_preprocessors.meta_preprocessor(raw_meta) counts = self._counts_validations(counts, meta) interactions = self.database_manager.get_repository('interaction').get_all_expanded( only_cellphonedb_interactor=True) genes = self.database_manager.get_repository('gene').get_all_expanded() complex_composition = self.database_manager.get_repository('complex').get_all_compositions() complex_expanded = self.database_manager.get_repository('complex').get_all_expanded() means, significant_means, deconvoluted = cpdb_analysis_method.call( meta, counts, interactions, genes, complex_expanded, complex_composition, threshold, result_precision) return means, significant_means, deconvoluted
def _meta_file_validator(self, raw_meta_file: str) -> None: raw_meta = pd.read_csv('{}/preprocessors_fixtures/{}'.format(data_test_dir, raw_meta_file), sep='\t') meta = method_preprocessors.meta_preprocessor(raw_meta) result_expected = pd.read_csv( '{}/preprocessors_fixtures/meta_result_preprocessor.txt'.format(data_test_dir), sep='\t', index_col=0) self.assertTrue(meta.equals(result_expected)) self.assertEqual(meta.index.name, 'cell')
def cpdb_statistical_analysis_launcher( self, raw_meta: pd.DataFrame, counts: pd.DataFrame, counts_data: str, iterations: int, threshold: float, threads: int, debug_seed: int, result_precision: int, pvalue: float, subsampler: Subsampler = None, ) -> (pd.DataFrame, pd.DataFrame, pd.DataFrame, pd.DataFrame): if threads < 1: core_logger.info('Using Default thread number: %s' % self.default_threads) threads = self.default_threads if threshold < 0 or threshold > 1: raise ThresholdValueException(threshold) meta = method_preprocessors.meta_preprocessor(raw_meta) counts = self._counts_validations(counts, meta) if subsampler is not None: counts = subsampler.subsample(counts) meta = meta.filter(items=(list(counts)), axis=0) interactions = self.database_manager.get_repository( 'interaction').get_all_expanded(include_gene=False) genes = self.database_manager.get_repository('gene').get_all_expanded() complex_composition = self.database_manager.get_repository( 'complex').get_all_compositions() complex_expanded = self.database_manager.get_repository( 'complex').get_all_expanded() deconvoluted, means, pvalues, significant_means = \ cpdb_statistical_analysis_method.call(meta, counts, counts_data, interactions, genes, complex_expanded, complex_composition, iterations, threshold, threads, debug_seed, result_precision, pvalue, self.separator) return pvalues, means, significant_means, deconvoluted
def cpdb_statistical_analysis_launcher(self, raw_meta: pd.DataFrame, counts: pd.DataFrame, iterations: int, threshold: float, threads: int, debug_seed: int, result_precision: int ) -> (pd.DataFrame, pd.DataFrame, pd.DataFrame, pd.DataFrame, pd.DataFrame): if threads < 1: core_logger.info('Using Default thread number: %s' % self.default_threads) threads = self.default_threads if threshold < 0 or threshold > 1: raise ThresholdValueException(threshold) meta = method_preprocessors.meta_preprocessor(raw_meta) counts = self._counts_validations(counts, meta) interactions = self.database_manager.get_repository('interaction').get_all_expanded( only_cellphonedb_interactor=True) genes = self.database_manager.get_repository('gene').get_all_expanded() complex_composition = self.database_manager.get_repository('complex').get_all_compositions() complex_expanded = self.database_manager.get_repository('complex').get_all_expanded() deconvoluted, mean_pvalue, means, pvalues, significant_means = \ cpdb_statistical_analysis_method.call(meta, counts, interactions, genes, complex_expanded, complex_composition, iterations, threshold, threads, debug_seed, result_precision) return pvalues, means, significant_means, mean_pvalue, deconvoluted
def cpdb_statistical_analysis_launcher( self, raw_meta: pd.DataFrame, counts: pd.DataFrame, threads: int, debug_seed: int, result_precision: int, log2_transform: bool ) -> (pd.DataFrame, pd.DataFrame, pd.DataFrame, pd.DataFrame, pd.DataFrame ): if threads < 1: core_logger.info('Using Default thread number: %s' % self.default_threads) threads = self.default_threads meta = method_preprocessors.meta_preprocessor(raw_meta) counts = self._counts_validations(counts, meta) winsorized = \ cpdb_statistical_analysis_method.call(meta, counts, threads, debug_seed, result_precision, log2_transform) return winsorized
def _meta_file_exception_validator(self, raw_meta_file): raw_meta = pd.read_csv('{}/preprocessors_fixtures/{}'.format(data_test_dir, raw_meta_file), sep='\t') with self.assertRaises(ProcessMetaException): method_preprocessors.meta_preprocessor(raw_meta)