示例#1
0
def dot_plot_results(means: str, pvalues: str, rows: str, columns: str, job_id: str):
    with tempfile.TemporaryDirectory() as output_path:
        with tempfile.NamedTemporaryFile(suffix=os.path.splitext(means)[-1]) as means_file:
            with tempfile.NamedTemporaryFile(suffix=os.path.splitext(pvalues)[-1]) as pvalues_file:
                with tempfile.NamedTemporaryFile() as rows_file:
                    with tempfile.NamedTemporaryFile() as columns_file:
                        _from_s3_to_temp(means, means_file)
                        _from_s3_to_temp(pvalues, pvalues_file)
                        _from_s3_to_temp(rows, rows_file)
                        _from_s3_to_temp(columns, columns_file)

                        output_name = 'plot__{}.png'.format(job_id)

                        dot_plot(means_file.name, pvalues_file.name, output_path, output_name, rows_file.name,
                                 columns_file.name)

                        output_file = os.path.join(output_path, output_name)

                        if not os.path.exists(output_file):
                            raise PlotException('Could not generate output file for plot of type dot_plot')

                        response = {
                            'job_id': job_id,
                            'files': {
                                'plot': output_name,
                            },
                            'success': True
                        }

                        write_image_to_s3(output_file, output_name)

                        return response
示例#2
0
    def test_dot_plot_with_all_columns_and_rows(self):
        means_path = self._get_input_file_path_for('means')
        pvalues_path = self._get_input_file_path_for('pvalues')
        plot_output = 'dot_plot_output_all_rows_columns.png'

        dot_plot(means_path=means_path,
                 pvalues_path=pvalues_path,
                 output_path=output_test_dir,
                 output_name=plot_output
                 )

        output_path = os.path.join(output_test_dir, plot_output)
        self.assertTrue(os.path.exists(output_path), 'Plot of type dot_plot did not work')
        self.assertGreater(os.path.getsize(output_path), 0)
        os.remove(output_path)
示例#3
0
def dot_plot(means_path: str, pvalues_path: str, output_path: str, output_name: str, rows: str,
             columns: str, verbose: bool):
    try:
        r_plotter.dot_plot(means_path, pvalues_path, output_path, output_name, rows, columns)
    except MissingR:
        print('You cannot perform this plot command unless there is a working R setup according to CellPhoneDB specs')
    except RRuntimeException as e:
        app_logger.error(str(e))
    except:
        app_logger.error('Unexpected error')

        if verbose:
            traceback.print_exc(file=sys.stdout)
        else:
            app_logger.error('execute with --verbose to see full stack trace')