Skip to content

Commit

Permalink
Merge pull request #196 from monarch-initiative/195-move-click-comman…
Browse files Browse the repository at this point in the history
…ds-out-of-analysispy-and-move-into-pheval-utils

195 move click commands out of analysispy and move into pheval utils
  • Loading branch information
yaseminbridges authored Sep 14, 2023
2 parents 2e2aa18 + 6cb1c66 commit 110f395
Show file tree
Hide file tree
Showing 2 changed files with 201 additions and 196 deletions.
196 changes: 0 additions & 196 deletions src/pheval/analyse/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from dataclasses import dataclass
from pathlib import Path

import click
import pandas as pd

from pheval.analyse.generate_plots import AnalysisResults, TrackRunPrioritisation
Expand All @@ -22,7 +21,6 @@
RankedPhEvalGeneResult,
RankedPhEvalVariantResult,
)
from pheval.prepare.custom_exceptions import InputError
from pheval.utils.file_utils import all_files, files_with_suffix, obtain_closest_file_name
from pheval.utils.phenopacket_utils import (
GenomicVariant,
Expand Down Expand Up @@ -672,197 +670,3 @@ def benchmark_runs(
gene_stats_writer.close() if gene_analysis else None
variants_stats_writer.close() if variant_analysis else None
disease_stats_writer.close() if disease_analysis else None


@click.command()
@click.option(
"--directory",
"-d",
required=True,
metavar="PATH",
help="General results directory to be benchmarked, assumes contains subdirectories of pheval_gene_results/"
"pheval_variant_results and the tool specific results directory. ",
type=Path,
)
@click.option(
"--phenopacket-dir",
"-p",
required=True,
metavar="PATH",
help="Full path to directory containing input phenopackets.",
type=Path,
)
@click.option(
"--output-prefix",
"-o",
metavar="<str>",
required=True,
help=" Output file prefix. ",
)
@click.option(
"--score-order",
"-so",
required=True,
help="Ordering of results for ranking.",
type=click.Choice(["ascending", "descending"]),
default="descending",
show_default=True,
)
@click.option(
"--threshold",
"-t",
metavar="<float>",
default=float(0.0),
required=False,
help="Score threshold.",
type=float,
)
@click.option(
"--gene-analysis/--no-gene-analysis",
default=False,
required=False,
type=bool,
show_default=True,
help="Specify analysis for gene prioritisation",
)
@click.option(
"--variant-analysis/--no-variant-analysis",
default=False,
required=False,
type=bool,
show_default=True,
help="Specify analysis for variant prioritisation",
)
@click.option(
"--disease-analysis/--no-disease-analysis",
default=False,
required=False,
type=bool,
show_default=True,
help="Specify analysis for disease prioritisation",
)
@click.option(
"--plot-type",
"-y",
default="bar_stacked",
show_default=True,
type=click.Choice(["bar_stacked", "bar_cumulative", "bar_non_cumulative"]),
help="Bar chart type to output.",
)
def benchmark(
directory: Path,
phenopacket_dir: Path,
score_order: str,
output_prefix: str,
threshold: float,
gene_analysis: bool,
variant_analysis: bool,
disease_analysis: bool,
plot_type: str,
):
"""Benchmark the gene/variant prioritisation performance for a single run."""
if not gene_analysis and not variant_analysis and not disease_analysis:
raise InputError("Need to specify gene analysis and/or variant and/or disease analysis.")
benchmark_directory(
TrackInputOutputDirectories(results_dir=directory, phenopacket_dir=phenopacket_dir),
score_order,
output_prefix,
threshold,
gene_analysis,
variant_analysis,
disease_analysis,
plot_type,
)


@click.command()
@click.option(
"--run-data",
"-r",
required=True,
metavar="PATH",
help="Path to .txt file containing testdata directory and corresponding results directory separated by tab."
"Each run contained to a new line with the input testdata listed first and on the same line separated by a tab"
"the results directory.",
type=Path,
)
@click.option(
"--output-prefix",
"-o",
metavar="<str>",
required=True,
help=" Output file prefix. ",
)
@click.option(
"--score-order",
"-so",
required=True,
help="Ordering of results for ranking.",
type=click.Choice(["ascending", "descending"]),
default="descending",
show_default=True,
)
@click.option(
"--threshold",
"-t",
metavar="<float>",
default=float(0.0),
required=False,
help="Score threshold.",
type=float,
)
@click.option(
"--gene-analysis/--no-gene-analysis",
default=False,
required=False,
type=bool,
show_default=True,
help="Specify analysis for gene prioritisation",
)
@click.option(
"--variant-analysis/--no-variant-analysis",
default=False,
required=False,
type=bool,
show_default=True,
help="Specify analysis for variant prioritisation",
)
@click.option(
"--disease-analysis/--no-disease-analysis",
default=False,
required=False,
type=bool,
show_default=True,
help="Specify analysis for disease prioritisation",
)
@click.option(
"--plot-type",
"-y",
default="bar_stacked",
show_default=True,
type=click.Choice(["bar_stacked", "bar_cumulative", "bar_non_cumulative"]),
help="Bar chart type to output.",
)
def benchmark_comparison(
run_data: Path,
score_order: str,
output_prefix: str,
threshold: float,
gene_analysis: bool,
variant_analysis: bool,
disease_analysis: bool,
plot_type: str,
):
"""Benchmark the gene/variant prioritisation performance for two runs."""
if not gene_analysis and not variant_analysis and not disease_analysis:
raise InputError("Need to specify gene analysis and/or variant and/or disease analysis.")
benchmark_runs(
_parse_run_data_text_file(run_data),
score_order,
output_prefix,
threshold,
gene_analysis,
variant_analysis,
disease_analysis,
plot_type,
)
Loading

0 comments on commit 110f395

Please sign in to comment.