Closed oyxf closed 3 years ago
Please provide a minimal, reproducible example. Thanks!
Thank you for your fast response!
The example is as follow:
#!/usr/bin/env Rscript
suppressPackageStartupMessages(library("argparse"))
# ======================= GLOBAL command line parameters setting========================================================
parser <- ArgumentParser(
prog='tools',
description = " data manipulation toolsets.",
formatter_class= "lambda prog: argparse.ArgumentDefaultsHelpFormatter(prog, max_help_position=20,width=150)",
argument_default = "True",
usage = "%(prog)s [global options]"
)
parser$add_argument(
"-i",
"--input",
type = "character",
required="True",
help = "The input exprssion matrix."
)
parser$add_argument(
"-f",
"--assay",
type = "character",
default = NULL,
help = "[OPTIONAL]the comma separated assays list except the main assay specified by --assay, when it comes to multimodal assay."
)
subparsers <- parser$add_subparsers(dest="sub_name",
prog ="tools",
metavar = "<subcommand>",
help = "choose only one option")
sub_st_deconv <- subparsers$add_parser("st_deconv",
formatter_class= "lambda prog: argparse.ArgumentDefaultsHelpFormatter(prog, max_help_position=20,width=150)",
help = "one stop run of data dimension reduction and clustering.")
sub_st_deconv$add_argument("--refexp",
type = "character",
help = "[REQUIRED]the customized reference expression matrix in seurat format, which may come from the quantification results of microarray, Bulk RNA-seq and scRNA-seq sequencing." )
sub_st_deconv$add_argument( "--refcelltype",
type = "character",
help = "[REQUIRED]the cell type annotation column id in the reference expression matrix." )
opt<-parser$parse_args()
The R version is R. 4.0.3 and command line :
Rscript example.r --help
Thanks for the bug report! Should work now in the development version of {argparse}
:
remotes::install_github("trevorld/r-argparse")
Hi,
when I use " formatter_class" to subparsers$add_parser, it seems not work,but for ArgumentParser, it is OK 。