"""CLI parser registration for plot command group."""
import argparse
from modalysis.cli.handlers.plot import (
handle_plot_common_genes_venn,
handle_plot_dmr_dotplot,
handle_plot_gene_heatmap,
handle_plot_mean_methylation,
)
from modalysis.constants import DEFAULT_PORT
[docs]
def register_plot_parser(
subparsers: argparse._SubParsersAction,
) -> None:
"""Register `plot` subcommands and arguments."""
plot_parser = subparsers.add_parser("plot", help="Plot commands")
plot_subparsers = plot_parser.add_subparsers(dest="plot_command")
plot_mean_methylation_parser = plot_subparsers.add_parser(
"mean-methylation", help="Plot mean methylation by region and chromosome"
)
plot_mean_methylation_parser.add_argument(
"--gff-path",
required=True,
help="Path to the formatted GFF .modalysis file",
)
plot_mean_methylation_parser.add_argument(
"--merged-pileup-paths",
nargs="+",
required=True,
help="Paths to one or more merged pileup .modalysis files",
)
plot_mean_methylation_parser.add_argument(
"--labels",
nargs="+",
required=True,
help="Labels for each merged pileup file (one per file, e.g. 5mC 5mC_5hmC)",
)
plot_mean_methylation_parser.add_argument(
"--output-path",
required=True,
help="Path to the output directory",
)
plot_mean_methylation_parser.add_argument(
"--output-name",
required=True,
help="Name for the output file (saved as .png)",
)
plot_mean_methylation_parser.add_argument(
"--y-min",
type=float,
default=0.0,
help="Minimum value for the Y axis (default: 0.0)",
)
plot_mean_methylation_parser.add_argument(
"--y-max",
type=float,
default=0.1,
help="Maximum value for the Y axis (default: 0.1)",
)
plot_mean_methylation_parser.add_argument(
"--chromosome-order-path",
help="Optional path to a file with chromosome names in preferred order (one per line)",
)
plot_mean_methylation_parser.add_argument(
"--plot-title",
help="Optional custom title for the plot",
)
plot_mean_methylation_parser.add_argument(
"--port",
type=int,
default=DEFAULT_PORT,
help=f"Port the server is running on (default: {DEFAULT_PORT})",
)
plot_mean_methylation_parser.set_defaults(func=handle_plot_mean_methylation)
# gene-heatmap subcommand
plot_gene_heatmap_parser = plot_subparsers.add_parser(
"gene-heatmap",
help="Plot gene-level heatmaps of mean modification by region (promoter, body, enhancer)",
)
plot_gene_heatmap_parser.add_argument(
"--annotated-dmr-paths",
nargs="+",
required=True,
help="Paths to annotated DMR .modalysis files (one per manifestation/modification pair)",
)
plot_gene_heatmap_parser.add_argument(
"--manifestations",
nargs="+",
required=True,
help="Manifestation label for each annotated DMR file (e.g. CM CM J J)",
)
plot_gene_heatmap_parser.add_argument(
"--modifications",
nargs="+",
required=True,
help="Modification label for each annotated DMR file (e.g. 5MC 5MC_5HMC 5MC 5MC_5HMC)",
)
plot_gene_heatmap_parser.add_argument(
"--manifestation-labels",
nargs="+",
required=True,
help="Unique manifestation labels used in the study (e.g. CM J)",
)
plot_gene_heatmap_parser.add_argument(
"--expression-labels",
nargs="+",
required=True,
help="Expression label corresponding to each manifestation label (e.g. cerebral hepatic)",
)
plot_gene_heatmap_parser.add_argument(
"--annotated-gff-path",
required=True,
help="Path to the annotated GFF .modalysis file (with EXPRESSION column)",
)
plot_gene_heatmap_parser.add_argument(
"--gff-path",
required=True,
help="Path to the formatted GFF .modalysis file (for gene coordinates)",
)
plot_gene_heatmap_parser.add_argument(
"--merged-pileup-paths",
nargs="+",
required=True,
help="Paths to merged pileup .modalysis files (one per manifestation/modification pair)",
)
plot_gene_heatmap_parser.add_argument(
"--pileup-manifestations",
nargs="+",
required=True,
help="Manifestation label for each merged pileup file (e.g. CM CM J J)",
)
plot_gene_heatmap_parser.add_argument(
"--pileup-modifications",
nargs="+",
required=True,
help="Modification label for each merged pileup file (e.g. 5MC 5MC_5HMC 5MC 5MC_5HMC)",
)
plot_gene_heatmap_parser.add_argument(
"--output-path",
required=True,
help="Path to the output directory",
)
plot_gene_heatmap_parser.add_argument(
"--output-name",
required=True,
help="Prefix for output files (each heatmap saved as <prefix>_<combination>.png)",
)
plot_gene_heatmap_parser.add_argument(
"--show-gene-labels",
action="store_true",
default=False,
help="Show gene IDs on the Y axis (default: off, compact rows)",
)
plot_gene_heatmap_parser.add_argument(
"--effect-signs",
nargs="+",
choices=["NEGATIVE", "NON_NEGATIVE"],
help="Optional effect signs to plot (default: both NEGATIVE and NON_NEGATIVE)",
)
plot_gene_heatmap_parser.add_argument(
"--port",
type=int,
default=DEFAULT_PORT,
help=f"Port the server is running on (default: {DEFAULT_PORT})",
)
plot_gene_heatmap_parser.set_defaults(func=handle_plot_gene_heatmap)
# dmr-dotplot subcommand
plot_dmr_dotplot_parser = plot_subparsers.add_parser(
"dmr-dotplot",
help="Plot DMR positions within gene regions (promoter, body, enhancer) as a dot plot",
)
plot_dmr_dotplot_parser.add_argument(
"--annotated-dmr-paths",
nargs="+",
required=True,
help="Paths to annotated DMR .modalysis files (one per manifestation/modification pair)",
)
plot_dmr_dotplot_parser.add_argument(
"--manifestations",
nargs="+",
required=True,
help="Manifestation label for each annotated DMR file (e.g. CM CM J J)",
)
plot_dmr_dotplot_parser.add_argument(
"--modifications",
nargs="+",
required=True,
help="Modification label for each annotated DMR file (e.g. 5MC 5MC_5HMC 5MC 5MC_5HMC)",
)
plot_dmr_dotplot_parser.add_argument(
"--manifestation-labels",
nargs="+",
required=True,
help="Unique manifestation labels used in the study (e.g. CM J)",
)
plot_dmr_dotplot_parser.add_argument(
"--expression-labels",
nargs="+",
required=True,
help="Expression label corresponding to each manifestation label (e.g. cerebral hepatic)",
)
plot_dmr_dotplot_parser.add_argument(
"--annotated-gff-path",
required=True,
help="Path to the annotated GFF .modalysis file (with EXPRESSION column)",
)
plot_dmr_dotplot_parser.add_argument(
"--gff-path",
required=True,
help="Path to the formatted GFF .modalysis file (for gene coordinates)",
)
plot_dmr_dotplot_parser.add_argument(
"--output-path",
required=True,
help="Path to the output directory",
)
plot_dmr_dotplot_parser.add_argument(
"--output-name",
required=True,
help="Prefix for output files (each dotplot saved as <prefix>_<combination>.png)",
)
plot_dmr_dotplot_parser.add_argument(
"--port",
type=int,
default=DEFAULT_PORT,
help=f"Port the server is running on (default: {DEFAULT_PORT})",
)
plot_dmr_dotplot_parser.add_argument(
"--show-gene-labels",
action="store_true",
default=False,
help="Show gene IDs on the Y-axis (default: off)",
)
plot_dmr_dotplot_parser.add_argument(
"--effect-signs",
nargs="+",
choices=["NEGATIVE", "NON_NEGATIVE"],
help="Optional effect signs to plot (default: both NEGATIVE and NON_NEGATIVE)",
)
plot_dmr_dotplot_parser.set_defaults(func=handle_plot_dmr_dotplot)
# common-genes-venn subcommand
plot_common_genes_venn_parser = plot_subparsers.add_parser(
"common-genes-venn",
help="Plot Venn diagrams of common negative DMR genes by manifestation and region",
)
plot_common_genes_venn_parser.add_argument(
"--annotated-dmr-paths",
nargs="+",
required=True,
help="Paths to annotated DMR .modalysis files (one per manifestation/modification pair)",
)
plot_common_genes_venn_parser.add_argument(
"--manifestations",
nargs="+",
required=True,
help="Manifestation label for each annotated DMR file (e.g. CM CM HD HD)",
)
plot_common_genes_venn_parser.add_argument(
"--modifications",
nargs="+",
required=True,
help="Modification label for each annotated DMR file (e.g. 5MC 5MC_5HMC 5MC 5MC_5HMC)",
)
plot_common_genes_venn_parser.add_argument(
"--modification-a",
required=True,
help="First modification label to compare (for example: 5MC)",
)
plot_common_genes_venn_parser.add_argument(
"--modification-b",
required=True,
help="Second modification label to compare (for example: 5MC_5HMC)",
)
plot_common_genes_venn_parser.add_argument(
"--output-path",
required=True,
help="Path to the output directory",
)
plot_common_genes_venn_parser.add_argument(
"--output-name",
required=True,
help="Output file name prefix for the Venn figure (saved as .png)",
)
plot_common_genes_venn_parser.add_argument(
"--port",
type=int,
default=DEFAULT_PORT,
help=f"Port the server is running on (default: {DEFAULT_PORT})",
)
plot_common_genes_venn_parser.set_defaults(func=handle_plot_common_genes_venn)