"""CLI handlers for plot commands."""
import argparse
import logging
from modalysis.client.plot import (
plot_common_genes_venn,
plot_dmr_dotplot,
plot_gene_heatmap,
plot_mean_methylation,
)
logger = logging.getLogger(__name__)
[docs]
def handle_plot_mean_methylation(args: argparse.Namespace) -> None:
"""Handle `modalysis plot mean-methylation` CLI command."""
chromosome_order = None
if args.chromosome_order_path:
with open(args.chromosome_order_path) as f:
chromosome_order = [line.strip() for line in f if line.strip()]
base_url = f"http://localhost:{args.port}"
result = plot_mean_methylation(
gff_path=args.gff_path,
merged_pileup_paths=args.merged_pileup_paths,
labels=args.labels,
output_path=args.output_path,
output_name=args.output_name,
y_min=args.y_min,
y_max=args.y_max,
chromosome_order=chromosome_order,
plot_title=args.plot_title,
base_url=base_url,
)
print(result)
[docs]
def handle_plot_gene_heatmap(args: argparse.Namespace) -> None:
"""Handle `modalysis plot gene-heatmap` CLI command."""
base_url = f"http://localhost:{args.port}"
result = plot_gene_heatmap(
annotated_dmr_paths=args.annotated_dmr_paths,
manifestations=args.manifestations,
modifications=args.modifications,
manifestation_labels=args.manifestation_labels,
expression_labels=args.expression_labels,
annotated_gff_path=args.annotated_gff_path,
gff_path=args.gff_path,
merged_pileup_paths=args.merged_pileup_paths,
pileup_manifestations=args.pileup_manifestations,
pileup_modifications=args.pileup_modifications,
output_path=args.output_path,
output_name=args.output_name,
show_gene_labels=args.show_gene_labels,
effect_signs=args.effect_signs,
base_url=base_url,
)
print(result)
[docs]
def handle_plot_dmr_dotplot(args: argparse.Namespace) -> None:
"""Handle `modalysis plot dmr-dotplot` CLI command."""
base_url = f"http://localhost:{args.port}"
result = plot_dmr_dotplot(
annotated_dmr_paths=args.annotated_dmr_paths,
manifestations=args.manifestations,
modifications=args.modifications,
manifestation_labels=args.manifestation_labels,
expression_labels=args.expression_labels,
annotated_gff_path=args.annotated_gff_path,
gff_path=args.gff_path,
output_path=args.output_path,
output_name=args.output_name,
show_gene_labels=args.show_gene_labels,
effect_signs=args.effect_signs,
base_url=base_url,
)
print(result)
[docs]
def handle_plot_common_genes_venn(args: argparse.Namespace) -> None:
"""Handle `modalysis plot common-genes-venn` CLI command."""
base_url = f"http://localhost:{args.port}"
result = plot_common_genes_venn(
annotated_dmr_paths=args.annotated_dmr_paths,
manifestations=args.manifestations,
modifications=args.modifications,
modification_a=args.modification_a,
modification_b=args.modification_b,
output_path=args.output_path,
output_name=args.output_name,
base_url=base_url,
)
print(result)