Source code for modalysis.cli.parsers.dmr

"""CLI parser registration for DMR command group."""

import argparse

from modalysis.cli.handlers.dmr import (
    handle_dmr_annotate,
    handle_dmr_common_genes,
    handle_dmr_format,
    handle_dmr_gene_counts,
)
from modalysis.constants import DEFAULT_PORT


[docs] def register_dmr_parser( subparsers: argparse._SubParsersAction, ) -> None: """Register `dmr` subcommands and arguments.""" dmr_parser = subparsers.add_parser("dmr", help="DMR commands") dmr_subparsers = dmr_parser.add_subparsers(dest="dmr_command") dmr_format_parser = dmr_subparsers.add_parser("format", help="Format a DMR file") dmr_format_parser.add_argument( "--input-path", required=True, help="Path to the input DMR file" ) dmr_format_parser.add_argument( "--output-path", required=True, help="Path to the output directory" ) dmr_format_parser.add_argument( "--output-name", required=True, help="Name for the output file" ) dmr_format_parser.add_argument( "--allowed-chromosomes", required=True, help="Path to a file with one valid chromosome name per line", ) dmr_format_parser.add_argument( "--min-score", type=float, default=5, help="Minimum score threshold; rows below this are filtered out (default: 5)", ) dmr_format_parser.add_argument( "--max-p-value", type=float, default=0.05, help="Maximum p-value threshold; rows above this are filtered out (default: 0.05)", ) dmr_format_parser.add_argument( "--min-pct-a-samples", type=float, default=50.0, help="Minimum percentage of A-group samples (default: 50.0)", ) dmr_format_parser.add_argument( "--min-pct-b-samples", type=float, default=50.0, help="Minimum percentage of B-group samples (default: 50.0)", ) dmr_format_parser.add_argument( "--min-reads", type=int, default=5, help="Minimum read count for both a_total and b_total (default: 5)", ) dmr_format_parser.add_argument( "--port", type=int, default=DEFAULT_PORT, help=f"Port the server is running on (default: {DEFAULT_PORT})", ) dmr_format_parser.set_defaults(func=handle_dmr_format) dmr_annotate_parser = dmr_subparsers.add_parser( "annotate", help="Annotate formatted DMR file with gene regions from GFF" ) dmr_annotate_parser.add_argument( "--dmr-path", required=True, help="Path to the formatted DMR .modalysis file", ) dmr_annotate_parser.add_argument( "--gff-path", required=True, help="Path to the formatted GFF .modalysis file", ) dmr_annotate_parser.add_argument( "--output-path", required=True, help="Path to the output directory" ) dmr_annotate_parser.add_argument( "--output-name", required=True, help="Name for the output file" ) dmr_annotate_parser.add_argument( "--port", type=int, default=DEFAULT_PORT, help=f"Port the server is running on (default: {DEFAULT_PORT})", ) dmr_annotate_parser.set_defaults(func=handle_dmr_annotate) dmr_gene_counts_parser = dmr_subparsers.add_parser( "gene-counts", help="Count unique genes by manifestation, expression, effect sign, modification, and region", ) dmr_gene_counts_parser.add_argument( "--annotated-dmr-paths", required=True, nargs="+", help="Paths to annotated DMR .modalysis files", ) dmr_gene_counts_parser.add_argument( "--manifestations", required=True, nargs="+", help="Manifestation label for each DMR file, in the same order as --annotated-dmr-paths", ) dmr_gene_counts_parser.add_argument( "--modifications", required=True, nargs="+", help="Modification label for each DMR file, in the same order as --annotated-dmr-paths", ) dmr_gene_counts_parser.add_argument( "--manifestation-labels", required=True, nargs="+", help="Manifestation labels used in --manifestations (for example: CM J)", ) dmr_gene_counts_parser.add_argument( "--expression-labels", required=True, nargs="+", help="Expression labels from annotated GFF matching --manifestation-labels (for example: cerebral hepatic)", ) dmr_gene_counts_parser.add_argument( "--annotated-gff-path", required=True, help="Path to annotated GFF .modalysis file", ) dmr_gene_counts_parser.add_argument( "--output-path", required=True, help="Path to the output directory" ) dmr_gene_counts_parser.add_argument( "--output-name", required=True, help="Name for the output file" ) dmr_gene_counts_parser.add_argument( "--output-excel", action="store_true", help="Also write an Excel workbook (.xlsx) with grouped headers", ) dmr_gene_counts_parser.add_argument( "--port", type=int, default=DEFAULT_PORT, help=f"Port the server is running on (default: {DEFAULT_PORT})", ) dmr_gene_counts_parser.set_defaults(func=handle_dmr_gene_counts) dmr_common_genes_parser = dmr_subparsers.add_parser( "common-genes", help="Find genes shared between two modifications for each manifestation", ) dmr_common_genes_parser.add_argument( "--annotated-dmr-paths", required=True, nargs="+", help="Paths to annotated DMR .modalysis files", ) dmr_common_genes_parser.add_argument( "--manifestations", required=True, nargs="+", help="Manifestation label for each DMR file, in the same order as --annotated-dmr-paths", ) dmr_common_genes_parser.add_argument( "--modifications", required=True, nargs="+", help="Modification label for each DMR file, in the same order as --annotated-dmr-paths", ) dmr_common_genes_parser.add_argument( "--manifestation-labels", required=True, nargs="+", help="Manifestation labels used in --manifestations (for example: CM J)", ) dmr_common_genes_parser.add_argument( "--expression-labels", required=True, nargs="+", help="Expression labels from annotated GFF matching --manifestation-labels (for example: cerebral hepatic)", ) dmr_common_genes_parser.add_argument( "--modification-a", required=True, help="First modification label to compare (for example: 5MC)", ) dmr_common_genes_parser.add_argument( "--modification-b", required=True, help="Second modification label to compare (for example: 5MC_5HMC)", ) dmr_common_genes_parser.add_argument( "--annotated-gff-path", required=True, help="Path to annotated GFF .modalysis file", ) dmr_common_genes_parser.add_argument( "--output-path", required=True, help="Path to the output directory" ) dmr_common_genes_parser.add_argument( "--output-name", required=True, help="Name for the output file" ) dmr_common_genes_parser.add_argument( "--port", type=int, default=DEFAULT_PORT, help=f"Port the server is running on (default: {DEFAULT_PORT})", ) dmr_common_genes_parser.set_defaults(func=handle_dmr_common_genes)