-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdfit_helppage.cpp
More file actions
170 lines (143 loc) · 12 KB
/
Copy pathdfit_helppage.cpp
File metadata and controls
170 lines (143 loc) · 12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cstdint>
#include <iostream>
#include <math.h>
#include "dfit_helppage.h"
#if 0
int HelpPageSimple(FILE *fp){
fprintf(fp,"Simple helppage damage estimation using numerical optimization\n");
fprintf(fp,"Estimates damage in either local, global or lca mode depending on the bdamage input format\n");
fprintf(fp,"Dfit command performs either optimization of beta-binomial (default --nbootstrap = 0) or binomial model (--nbootstrap > 2)\n\n");
fprintf(fp,"Local mode: \t damage estimated for each reference/chromosome in the BAM file\n");
fprintf(fp,"Global mode: \t one damage estimate for whole BAM file\n");
fprintf(fp,"lca mode: \t damage estimated over the lca tree at different ranks\n\n");
fprintf(fp,"\n--help \t\t\t\t Print extended help page to see all options.\n\n");
fprintf(stderr, "./metaDMG-cpp dfit file.bdamage.gz --names file.gz --nodes trestructure.gz --bam file.bam --showfits int --nopt int --nbootstrap int --seed int --doCI int --CI float --lib <ds,ss> --out file\n");
fprintf(fp,"\n------------ Required ------------- \n");
fprintf(fp,"file.bdamage.gz contains the misincorporation matrix, in global mode from getdamage command either global or local mode or from lca command\n");
fprintf(fp,"e..g ./metaDMG-cpp dfit file.bdamage.gz\n");
fprintf(fp,"\n------------ Optional ------------- \n");
fprintf(fp,"--showfits: \t\t\t Verbose parameter, stored in the .dfit.txt.gz, default = 0, see documentation or extendend helppage --help, for full description of columns\n");
fprintf(fp,"--nopt \t\t\t\t Number of optimization calls (default: 10).\n");
fprintf(fp,"--lib \t\t\t\t double stranded (ds) use C>T (forward) and G>A (reverse); single stranded (ss) use C>T for both forward and reverse (default ds)\n");
fprintf(fp,"--nbootstrap: \t\t\t Number of bootstrap iterations, default = 0, i.e. optimization of beta-binomial model\n");
fprintf(fp,"--threads: \t\t\t Number of threads, default = 1, i.e. no threading\n");
fprintf(stderr, "\n---------- Examples ----------\n");
fprintf(stderr, "\t Local mode binomial:\n \t\t ./metaDMG-cpp getdamage Pitch6.bam -l 10 -p 15 -r 1 -o Pitch6getDMG\n \t\t ./metaDMG-cpp dfit Pitch6getDMG.bdamage.gz --showfits 1\n");
fprintf(stderr, "\t Global mode binomial:\n \t\t ./metaDMG-cpp getdamage Pitch6.bam -l 10 -p 15 -r 0 -o Pitch6getDMG\n \t\t ./metaDMG-cpp dfit Pitch6getDMG.bdamage.gz --nbootstrap 2 --showfits 2\n");
fprintf(stderr, "\t Lca mode beta-binomial:\n \t\t ./metaDMG-cpp lca --names names.dmp --nodes nodes.dmp --acc2tax acc2taxid.map.gz --weight_type 1 --fix_ncbi 0 --bam Pitch6.bam --out Pitch6lcatest \n \t\t ./metaDMG-cpp dfit Pitch6lcatest.bdamage.gz --names names.dmp --nodes nodes.dmp --showfits 0\n");
exit(1);
return 0;
}
int HelpPage(FILE *fp){
fprintf(fp,"Extended helppage damage estimation using numerical optimization\n");
fprintf(fp,"Estimates damage in either local, global or lca mode depending on the bdamage input format\n");
fprintf(fp,"Dfit command performs either optimization of beta-binomial (default --nbootstrap = 0) or binomial model (--nbootstrap > 2)\n\n");
fprintf(fp,"Local mode: \t damage estimated for each reference/chromosome in the BAM file\n");
fprintf(fp,"Global mode: \t one damage estimate for whole BAM file\n");
fprintf(fp,"lca mode: \t damage estimated over the lca tree at different ranks\n\n");
fprintf(fp,"\n--help \t\t\t\t Print extended help page to see all options.\n\n");
fprintf(stderr, "./metaDMG-cpp dfit file.bdamage.gz --names file.gz --nodes trestructure.gz --bam file.bam --showfits int --nopt int --nbootstrap int --seed int --doCI int --CI float --lib <ds,ss> --out file\n");
fprintf(fp,"\n------------ Required ------------- \n");
fprintf(fp,"./metaDMG-cpp dfit file.bdamage.gz \t bdamage file contains the misincorporation matrix, in global mode from getdamage command or local mode from lca command\n");
fprintf(fp,"\n------------ Optional ------------- \n");
fprintf(fp,"\n--nopt \t\t\t\t Number of optimization calls (default: 10).\n");
fprintf(fp,"\n--seed \t\t\t\t Seed value for random number generators (default: computer time).\n");
fprintf(fp,"\n--out \t\t\t\t Prefix for output name.\n");
fprintf(fp,"\n--lib \t\t\t\t double stranded (ds) use C>T (forward) and G>A (reverse); single stranded (ss) use C>T for both forward and reverse (default ds)\n");
fprintf(fp,"\n--nbootstrap \t\t\t number of bootstrap iterations. default: 1 -> use Beta-binomial model, -nbootstrap >1 use Binomial model ");
fprintf(fp,"\n--bam \t\t\t\t In local mode - convert the internal id numbering from bdamage.gz to the reference in the bam header\n");
fprintf(fp,"\n--threads \t\t\t\t Number of threads, default = 1, i.e. no threading\n");
fprintf(fp,"\n--rand: \t\t\t Pseudo-random number generator, OS specific\n");
fprintf(fp,"\t\t <0,1,2,3> \n");
fprintf(fp,"\t\t 0 : \t\t\t drand48_r, default for linux or unix, not available for MacOS.\n");
fprintf(fp,"\t\t 1 : \t\t\t std::uniform_int_distribution\n");
fprintf(fp,"\t\t 2 : \t\t\t rand_r\n");
fprintf(fp,"\t\t 3 : \t\t\t erand48, default for MacOS.\n");
fprintf(fp,"\n\n---- Optimization model specific ---- \n");
fprintf(stderr, "\n\n------ Beta-binomial model ------\n\n");
fprintf(fp,"--showfits: \t\t\t Verbose parameter, stored in the .dfit.txt.gz, default = 0, see documentation for full description of columns\n");
fprintf(fp,"\t--showfits 0\t\t [id;A;q;c;phi;llh;ncall;sigmaD;Zfit] \n");
fprintf(fp,"\t\t\t\t id:contig; A:amplitute of damage; q:decrease in damage; c:offset (background noise); phi:variance between Beta-binomial and binomial model\n");
fprintf(fp,"\t\t\t\t llh:minimized negative log-likelihood; ncall:optimization calls; sigmaD: standard deviation; Zfit: significance score\n");
//showfits 1
fprintf(fp,"\n\t--showfits 1\t\t [id;A;q;c;phi;llh;ncall;sigmaD;Zfit;\n");
fprintf(fp,"\t\t\t\t fwdxi;fwdxConfi;..;fwdxn;fwdxConfn..;\n\t\t\t\t\t bwdx;dxConfn;..;bwdxn;bwdxConfn]\n");
fprintf(fp,"\t\t\t\t fwdx: damage estimates forward strand; fwdxConf: confidence interval; fbwdx: reverse strand; bwdxConfn: confidence interval.\n \t\t\t\t\t i position 1 to position n (zero-index)\n");
//showfits 2
fprintf(fp,"\n\t--showfits 2\t\t [id;A;q;c;phi;llh;ncall;sigmaD;Zfit;\n");
fprintf(fp,"\t\t\t\t fwKi;fwNi;fwdxi;fwf0;fwdxConfi;..;fwKi;fwNi;fwdxi;fwfi;fwdxConfi..;\n\t\t\t\t\t bwKi;bwNi;bwdxi;bwfi;bwdxConfi;..;bwKn;bwNn;bwdxn;fwfn;bwdxConfn]\n");
fprintf(fp,"\t\t\t\t fwKi: Number of transitions forward strand (C>T); fwNi: Number reference counts forward strand (C); fwfi: C>T frequency based on forward strand from bdamage file\n");
fprintf(fp,"\t\t\t\t bwKi: Number of transitions reverse strand (G>A); bwNi: Number reference counts reverse strand (G); bwfi: C>T frequency based on reverse strand from bdamage file\n");
fprintf(stderr, "\n\n---------- Binomial model ----------\n\n");
fprintf(fp,"--showfits: \t\t\t Verbose parameter, stored in the .dfit.txt.gz, default = 0\n");
fprintf(fp,"\t--showfits 0\t\t [id;A;q;c;phi;llh;ncall;sigmaD;Zfit;A_b;q_b;c_b;phi_b;A_CI_l;A_CI_h;q_CI_l;q_CI_h;c_CI_l;c_CI_h;phi_CI_l;phi_CI_h] \n");
fprintf(fp,"\t\t\t\t\t id;A;q;c;phi;llh;ncall;sigmaD;Zfit estimates from beta-binomial (see above)\n");
fprintf(fp,"\t\t\t\t\t A_b;q_b;c_b;phi_b;A_CI_l;A_CI_h;q_CI_l;q_CI_h;c_CI_l;c_CI_h;phi_CI_l;phi_CI_h estimates binomial model with bootstrap method (*_b), confidence interval (*_CI_l) and (*_CI_h)\n");
fprintf(fp,"\n\t--showfits 1\t\t similar columns added as described above, using the bootstrap estimated parameters;\n");
fprintf(fp,"\n\t--showfits 2\t\t similar columns added as described above, using the bootstrap estimated parameters;\n");
fprintf(fp,"--nbootstrap: \t\t\t Number of bootstrap iterations, default = 0\n");
fprintf(fp,"--printboot: \t\t\t Print all bootstrap iterations of [id,A_b,q_b,c_b,phi_b] in seperate file, suffix: .bdamage.gz.boot.stat.txt.gz\n");
fprintf(fp,"--sigtype \t\t\t Determines the bootstrap method <1,2,3>, default = 1\n");
fprintf(fp,"\t0: \t\t\t\t Sample with replacement from the C>T frequency from the .bdamage format\n");
fprintf(fp,"\t1: \t\t\t\t Sample with replacement from the K and N column from the .bdamage format and calculates f column\n");
fprintf(fp,"\t1: \t\t\t\t Sample with replacement from binomial distribution defined from K and N column from the .bdamage format\n");
fprintf(fp,"--CI: \t\t\t\t Desired confidence interval, default = 0.95\n");
fprintf(fp,"--doCI: \t\t\t Confidence interval type <0,1>\n");
fprintf(fp,"\t0: \t\t\t\t Mean and Standard Deviation-Based CI Calculation\n");
fprintf(fp,"\t1: \t\t\t\t Percentile CI Calculation\n");
fprintf(fp,"--showfits: \t\t\t Verbose parameter, stored in the .dfit.txt.gz, default = 0\n");
fprintf(stderr, "\n---------- Examples ----------\n");
fprintf(stderr, "\t Local mode binomial:\n \t\t ./metaDMG-cpp getdamage Pitch6.bam -l 10 -p 15 -r 1 -o Pitch6getDMG\n \t\t ./metaDMG-cpp dfit Pitch6getDMG.bdamage.gz --showfits 1\n");
fprintf(stderr, "\t Global mode binomial:\n \t\t ./metaDMG-cpp getdamage Pitch6.bam -l 10 -p 15 -r 0 -o Pitch6getDMG\n \t\t ./metaDMG-cpp dfit Pitch6getDMG.bdamage.gz --nbootstrap 2 --showfits 2\n");
fprintf(stderr, "\t Lca mode beta-binomial:\n \t\t ./metaDMG-cpp lca --names names.dmp --nodes nodes.dmp --acc2tax acc2taxid.map.gz --weight_type 1 --fix_ncbi 0 --bam Pitch6.bam --out Pitch6lcatest \n \t\t ./metaDMG-cpp dfit Pitch6lcatest.bdamage.gz --names names.dmp --nodes nodes.dmp --showfits 0\n");
exit(1);
return 0;
}
#endif
int print_usage(FILE *fp){
fprintf(fp, "Usage: metaDMG-cpp dfit <file.bdamage.gz> [options]\n\n");
fprintf(fp, "Fit damage model per taxon/contig.\n");
fprintf(fp, "Use --nbootstrap > 1 for bootstrap summaries.\n\n");
fprintf(fp, "Options:\n");
fprintf(fp, " --nbootstrap INT Bootstrap replicates (default: 1)\n");
fprintf(fp, " --lib <ds|ss> Library type (default: ds)\n");
fprintf(fp, " --showfits INT Output detail (0-2, default: 0)\n");
fprintf(fp, " --printboot INT Write bootstrap draws to .boot.stat.gz (default: 0; use >0)\n");
fprintf(fp, " --out FILE Output prefix\n");
fprintf(fp, " --threads INT Threads (default: 1)\n\n");
fprintf(fp, "Run with --help for full options.\n");
return 0;
}
int print_help(FILE *fp){
fprintf(fp, "Usage:\n");
fprintf(fp, " metaDMG-cpp dfit file.bdamage.gz [options]\n\n");
fprintf(fp, "Description:\n");
fprintf(fp, " Fit damage model per taxon/contig from .bdamage.gz.\n");
fprintf(fp, " Use --nbootstrap > 1 to enable bootstrap summaries and confidence intervals.\n\n");
fprintf(fp, "Core options:\n");
fprintf(fp, " --lib <ds|ss> Library type (default: ds)\n");
fprintf(fp, " --nopt INT Optimizer runs (default: 10)\n");
fprintf(fp, " --showfits INT Output detail: 0=summary, 1=dx, 2=full (default: 0)\n\n");
fprintf(fp, "Bootstrap:\n");
fprintf(fp, " --nbootstrap INT # bootstrap replicates (default: 1)\n");
fprintf(fp, " --printboot INT Write all bootstrap draws to .boot.stat.gz (default: 0; use >0)\n");
fprintf(fp, " --sigtype <1|2|3> Bootstrap method (default: 1)\n");
fprintf(fp, " --doCI <1|2> CI method: 1=mean/sd, 2=percentile (default: 2)\n");
fprintf(fp, " --CI FLOAT Confidence level (default: 0.95)\n\n");
fprintf(fp, "I/O and misc:\n");
fprintf(fp, " --out FILE Output prefix\n");
fprintf(fp, " --bam FILE Use BAM header for names\n");
fprintf(fp, " --nodes FILE.gz Taxonomy nodes\n");
fprintf(fp, " --names FILE.gz Taxonomy names (with --nodes)\n");
fprintf(fp, " --threads INT Threads (default: 1)\n");
fprintf(fp, " --seed INT Random seed\n\n");
fprintf(fp, "Examples:\n");
fprintf(fp, " metaDMG-cpp dfit file.bdamage.gz\n");
fprintf(fp, " metaDMG-cpp dfit file.bdamage.gz --nbootstrap 100\n");
fprintf(fp, "../metaDMG-cpp dfit output/test_getdamage_global.bdamage --showfits 2 --seed 12345 --lib ds --out output/test_dfit_global --nbootstrap 2 --printboot 1");
return 0;
}