From 44719c8b40798f56861ec52f256af99ba3dc8dc7 Mon Sep 17 00:00:00 2001 From: Zilong-Li Date: Tue, 24 Dec 2024 11:19:51 +0100 Subject: [PATCH] nice groff --- external/popl/popl.hpp | 5 +++++ src/Cmd.cpp | 31 +++++++++++++++++-------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/external/popl/popl.hpp b/external/popl/popl.hpp index ef6b10b..db0b0fe 100644 --- a/external/popl/popl.hpp +++ b/external/popl/popl.hpp @@ -1262,6 +1262,11 @@ inline std::string GroffOptionPrinter::print(const Attribute& max_attribute) con throw std::invalid_argument("attribute must be 'optional', 'advanced', or 'default'"); std::stringstream s; + for (const auto& option : option_parser_->options()){ + // use groff option as the title + if(option->long_name()=="groff") + s << ".TH " << option->description() << "\n"; + } if (!option_parser_->description().empty()) s << ".SH DESCRIPTION\n.PP\n" << option_parser_->description() << "\n"; diff --git a/src/Cmd.cpp b/src/Cmd.cpp index b8c0505..903b646 100644 --- a/src/Cmd.cpp +++ b/src/Cmd.cpp @@ -16,30 +16,33 @@ Param::Param(int argc, char **argv) { std::string copyr{"PCA All In One (v" + (std::string)VERSION + ") https://github.com/Zilong-Li/PCAone\n" + "(C) 2021-2024 Zilong Li GNU General Public License v3\n" + "\n" + - "Usage: use plink files as input and apply default window-based RSVD method\n" + - " PCAone --bfile plink -n 20 \n\n" + - " use csv file as input and apply the Implicitly Restarted Arnoldi Method\n" + - " PCAone --csv csv.zst --svd 0 \n" + + "Usage: use PLINK files as input and apply default window-based RSVD method:\n" + + " $ PCAone -b plink \n\n" + + " use CSV file as input and apply the Implicitly Restarted Arnoldi Method:\n" + + " $ PCAone -c csv.zst -d 0 \n\n" + + " compute ancestry adjusted LD matrix:\n" + + " $ PCAone -b plink -k 2 -D -o adj \n" + + " $ PCAone -B adj -f adj.mbim --print-r2 -o adj \n" + "\n"}; OptionParser opts(copyr); opts.add, Attribute::headline>("","PCAone","General options:"); auto help_opt = opts.add("h", "help", "print all options including hidden advanced options"); opts.add>("m", "memory", "RAM usage in GB unit for out-of-core mode. default is in-core mode", memory, &memory); opts.add>("n", "threads", "the number of threads to be used", threads, &threads); - opts.add>("v", "verbose", "verbosity level for logs. any level x includes messages for all levels (1...x).\n" - "0: silent. no message on screen;\n" + opts.add>("v", "verbose", "verbosity level for logs. any level x includes messages for all levels (1...x). Options are\n" + "0: silent, no messages on screen;\n" "1: concise messages to screen;\n" "2: more verbose information;\n" "3: enable debug information." , verbose, &verbose); opts.add, Attribute::headline>("","PCA","PCA algorithms:"); - auto svd_opt = opts.add>("d", "svd", "SVD method to be applied. default 2 is recommended for big data.\n" + auto svd_opt = opts.add>("d", "svd", "SVD method to be applied. default 2 is recommended for big data. Options are\n" "0: the Implicitly Restarted Arnoldi Method (IRAM);\n" "1: the Yu's single-pass Randomized SVD with power iterations;\n" "2: the accurate window-based Randomized SVD method (PCAone);\n" "3: the full Singular Value Decomposition.", 2); opts.add>("k", "pc", "top k principal components (PCs) to be calculated", k, &k); - opts.add>("C", "scale", "do scaling for input file.\n" + opts.add>("C", "scale", "do scaling for input file. Options are\n" "0: do just centering;\n" "1: do log transformation eg. log(x+0.01) for RNA-seq data;\n" "2: do count per median log transformation (CPMED) for scRNAs.", scale, &scale); @@ -82,17 +85,17 @@ Param::Param(int argc, char **argv) { opts.add, Attribute::headline>("","MISC","Misc options:"); opts.add>("", "maf", "exclude variants with MAF lower than this value", maf, &maf); - opts.add>("", "project", "project the new samples onto the existing PCs.\n" + opts.add>("", "project", "project the new samples onto the existing PCs. Options are\n" "0: disabled;\n" "1: by multiplying the loadings with mean imputation for missing genotypes;\n" "2: by solving the least squares system Vx=g. skip sites with missingness;\n" "3: by Augmentation, Decomposition and Procrusters transformation.\n", project, &project); - opts.add>("", "inbreed", "compute the inbreeding coefficient accounting for population structure.\n" + opts.add>("", "inbreed", "compute the inbreeding coefficient accounting for population structure. Options are\n" "0: disabled;\n" "1: compute per-site inbreeding coefficient and HWE test.\n", inbreed, &inbreed); opts.add>("", "ld-r2", "r2 cutoff for LD-based pruning (usually 0.2).", ld_r2, &ld_r2); opts.add>("", "ld-bp", "physical distance threshold in bases for LD (usually 1000000).", ld_bp, &ld_bp); - opts.add>("", "ld-stats", "statistics to calculate LD r2 for pairwise SNPs.\n" + opts.add>("", "ld-stats", "statistics to compute LD R2 for pairwise SNPs. Options are\n" "0: the ancestry adjusted, i.e. correlation between residuals;\n" "1: the standard, i.e. correlation between two alleles.\n", ld_stats, &ld_stats); auto clumpfile = opts.add>("", "clump", "assoc-like file with target variants and pvalues for clumping.", "", &clump); @@ -101,7 +104,7 @@ Param::Param(int argc, char **argv) { opts.add>("", "clump-p2", "secondary significance threshold for clumped SNPs.", clump_p2, &clump_p2); opts.add>("", "clump-r2", "r2 cutoff for LD-based clumping.", clump_r2, &clump_r2); opts.add>("", "clump-bp", "physical distance threshold in bases for clumping.", clump_bp, &clump_bp); - opts.add("", "groff", "print groff formatted help message.", &groff); + opts.add("", "groff", "PCAone 1 \"24 December 2024\" \"PCAone-v"+ std::string(VERSION)+"\" \"Bioinformatics tools\"", &groff); // collect command line options acutal in effect ss << (std::string) "PCAone (v" + VERSION + ") https://github.com/Zilong-Li/PCAone\n"; @@ -204,9 +207,9 @@ Param::Param(int argc, char **argv) { throw std::invalid_argument("not supporting -m option for PCAngsd with BEAGLE file yet!"); if (bands < 4 || bands % 2 != 0) throw std::invalid_argument("the -w/--batches must be a power of 2 and the minimun is 4."); - + if (svd_t == SvdType::PCAoneAlg2 && !noshuffle) perm = true; - + } catch (const popl::invalid_option &e) { std::cerr << "Invalid Option Exception: " << e.what() << "\n"; std::cerr << "error: ";