Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding semsim distribution plot analysis #188

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ plotly = "^5.13.0"
seaborn = "^0.12.2"
matplotlib = "^3.7.0"
pyserde = "^0.9.8"
polars = "^0.18.13"

[tool.poetry.dev-dependencies]
pytest = "^7.2.0"
Expand Down
2 changes: 2 additions & 0 deletions src/pheval/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .cli_pheval_utils import (
create_spiked_vcfs_command,
scramble_phenopackets_command,
semsim_comparison_command,
semsim_convert_command,
semsim_scramble_command,
update_phenopackets_command,
Expand Down Expand Up @@ -54,6 +55,7 @@ def pheval_utils():
pheval_utils.add_command(semsim_convert_command)
pheval_utils.add_command(scramble_phenopackets_command)
pheval_utils.add_command(update_phenopackets_command)
pheval_utils.add_command(semsim_comparison_command)
pheval_utils.add_command(create_spiked_vcfs_command)
pheval_utils.add_command(benchmark)
pheval_utils.add_command(benchmark_comparison)
Expand Down
54 changes: 22 additions & 32 deletions src/pheval/cli_pheval_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pheval.prepare.create_spiked_vcf import spike_vcfs
from pheval.prepare.custom_exceptions import InputError, MutuallyExclusiveOptionError
from pheval.prepare.update_phenopacket import update_phenopackets
from pheval.utils.semsim_utils import percentage_diff, semsim_heatmap_plot
from pheval.utils.semsim_utils import semsim_comparison
from pheval.utils.utils import semsim_convert, semsim_scramble


Expand Down Expand Up @@ -116,18 +116,11 @@ def scramble_phenopackets_command(

@click.command("semsim-comparison")
@click.option(
"--semsim-left",
"-L",
required=True,
metavar="FILE",
help="Path to the first semantic similarity profile.",
)
@click.option(
"--semsim-right",
"-R",
"--input",
"-i",
multiple=True,
required=True,
metavar="FILE",
help="Path to the second semantic similarity profile.",
help="Semsim inputs file",
)
@click.option(
"--score-column",
Expand All @@ -142,42 +135,39 @@ def scramble_phenopackets_command(
"--analysis",
"-a",
required=True,
type=click.Choice(["heatmap", "percentage_diff"], case_sensitive=False),
type=click.Choice(["heatmap", "percentage_diff", "distribution"], case_sensitive=False),
souzadevinicius marked this conversation as resolved.
Show resolved Hide resolved
help="""There are two types of analysis:
heatmap - Generates a heatmap plot that shows the differences between the semantic similarity profiles using the
score column for this purpose. Defaults to "heatmap".
percentage_diff - Calculates the score column percentage difference between the semantic similarity profiles""",
percentage_diff - Calculates the score column percentage difference between the semantic similarity profiles
distribution - Plot showing the semsim score's distributions""",
)
@click.option(
"--output",
"-o",
metavar="FILE",
default="percentage_diff.semsim.tsv",
help="Output path for the difference tsv. Defaults to percentage_diff.semsim.tsv",
"--output-dir",
"-O",
metavar="output_dir",
default=".",
help="Output path directory for the comparisons",
)
def semsim_comparison(
semsim_left: Path,
semsim_right: Path,
def semsim_comparison_command(
input: List[Path],
score_column: str,
analysis: str,
output: Path = "percentage_diff.semsim.tsv",
output_dir: Path,
):
"""Compares two semantic similarity profiles
"""Compares semantic similarity profiles

Args:
semsim-left (Path): File path of the first semantic similarity profile
semsim-right (Path): File path of the second semantic similarity profile
output (Path): Output path for the difference tsv. Defaults to "percentage_diff.semsim.tsv".
input (List[Path]): File paths semantic similarity profiles
output-dir (Path): Output directory path for the comparisons.
score_column (str): Score column that will be computed (e.g. jaccard_similarity)
analysis (str): There are two types of analysis:
analysis (str): There are three types of analysis:
heatmap - Generates a heatmap plot that shows the differences between the semantic similarity profiles using the
score column for this purpose. Defaults to "heatmap".
percentage_diff - Calculates the score column percentage difference between the semantic similarity profiles.
distribution - Plot showing the semsim score's distributions
"""
if analysis == "heatmap":
return semsim_heatmap_plot(semsim_left, semsim_right, score_column)
if analysis == "percentage_diff":
percentage_diff(semsim_left, semsim_right, score_column, output)
semsim_comparison(input, score_column, analysis, output_dir)


@click.command("update-phenopackets")
Expand Down
Loading
Loading