Пример #1
0
    def plot_results(self):
        """
        Plots the results 
        """
        print("Plotting Results...")
        prepare_sns(sns, self.params)
        self.plot_all_diseases()

        for disease_id in tqdm(self.params.disease_plots):
            self.plot_disease(self.diseases[disease_id])
Пример #2
0
    def plot_results(self):
        """
        Plots the results 
        """
        print("Plotting Results...")
        prepare_sns(sns, self.params)
        self.figures_dir = os.path.join(self.dir, 'figures')
        if not os.path.exists(self.figures_dir):
            os.makedirs(self.figures_dir)

        for plot_name, params in self.params.plots_to_params.items():
            plot_fn = params["plot_fn"]
            del params["plot_fn"]
            getattr(self, plot_fn)(name=plot_name, **params)
Пример #3
0
    def plot_results(self):
        """
        Outputs the results as a plot
        """
        assert (self.results != None)

        prepare_sns(sns, self.params)
        for name in self.plots:
            _, codisease_probs = self.results[name]
            if self.smooth:
                codisease_probs = np.maximum(
                    0,
                    savgol_filter(codisease_probs,
                                  window_length=self.window_length - 1,
                                  polyorder=3))
            bucket_size = self.top_k / self.n_buckets
            plt.plot(np.arange(1,
                               len(codisease_probs) * bucket_size + 1,
                               bucket_size),
                     codisease_probs[::-1],
                     label=name,
                     linewidth=2.0 if name == self.params.primary else 1.0)
            #plt.xticks(np.arange(1, len(codisease_probs) * bucket_size, bucket_size))

        plt.legend()
        plt.ylabel('Codisease Probability')
        plt.xlabel('Protein Pair Rank')

        figures_dir = os.path.join(self.dir, 'figures')
        if not os.path.exists(figures_dir):
            os.makedirs(figures_dir)
        time_string = datetime.datetime.now().strftime("%m-%d_%H%M")
        sns.despine()
        plt.tight_layout()
        plt.savefig(
            os.path.join(figures_dir, 'codisease_' + time_string + '.pdf'))
Пример #4
0
    assert os.path.isfile(
        json_path), "No json configuration file found at {}".format(json_path)
    params = Params(json_path)
    params.update(json_path)

    # Set the logger
    set_logger(os.path.join(args.experiment_dir, 'experiment.log'),
               level=logging.INFO,
               console=True)

    # Log Title
    logging.info("DPP-Diff Generator")
    logging.info("Sabri Eyuboglu  -- SNAP Group")
    logging.info("======================================")

    prepare_sns(sns, params)

    diseases_dict = load_diseases(params.diseases_path, params.disease_subset)

    method_to_scores = {}
    for method_name, method_exp_dir in params.method_exp_dirs.items():
        method_to_scores[method_name] = {}
        with open(os.path.join(method_exp_dir, 'metrics.csv'),
                  'r') as metrics_file:
            metrics_reader = csv.DictReader(metrics_file)
            print(method_exp_dir)
            for i, row in enumerate(metrics_reader):
                if row[params.metric] == params.metric: continue
                if not is_disease_id(row["Disease ID"]): continue
                if (diseases_dict[row["Disease ID"]].split == "none"):
                    continue