6 # Don't edit the line below, it must look exactly like this.
7 # Everything above this line will be replaced #
17 my $cmd_line = $0 . " " . join( " ", @ARGV );
19 ## Configure the command line parsing
20 Getopt::Long::config("auto_abbrev");
23 ## Declare the options
25 my %required_options = ( 'case_column:s' => 'column_name|column_number');
26 my %optional_options = ( "bins:i" => '',
29 "selection_method:s" => '\'random\'|\'consecutive\'',
30 "outside_n_sd_check:f" => '' );
32 my $res = GetOptions( \%options,
33 @common_options::get_opt_strings,
34 keys(%required_options),
35 keys(%optional_options) );
38 common_options::set_globals( \%options );
39 common_options::get_defaults( \%options, 'cdd' );
43 $help_text{Pre_help_message} = <<'EOF';
46 $help_text{Description
} = <<'EOF';
47 <h3 class=heading1>Description</h3>
49 The Case Deletion Diagnostics tool is run using the command from the command line
50 with a few mandatory arguments. CDD is run as a diagnostic after
51 a model is regarded finished or at least mature enough to run
52 validation tool on. You need to specify the NONMEM modelfile
53 with a model that have successful termination. You also have to
54 specify the number or name of the datafile column on which to
55 select for deletion. You do so with the case_column option.
58 $help_text{Examples
} = <<'EOF';
59 <h3 class=heading1>Examples</h3>
61 cdd -model=run89.mod -case_column=10
63 This will perform a Case Deletion Diagnostic on the model
64 specified in run89.mod based on the factors in column ten. If,
65 for example, column ten holds the ids of the seven centers
66 included in the study, this command will create seven copies of
67 the dataset, each with individuals included in one specific
68 center deleted. Say that the centers are numbered 1 to 7. Then
69 dataset 1 will have individuals from center 1 excluded, dataset
70 2 individuals from center 2 and so on.
73 $help_text{Options
} = <<'EOF';
74 <h3 class=heading1>Options</h3>
76 The options are given here in their long form. Any option may be
77 abbreviated to any nonconflicting prefix. The -threads option
78 may be abbreviated to -t(or even -thr) but -debug may not be
79 abbreviated to -d because it conflicts with -debug_packages and
82 The following options are valid:
85 $help_text{-h
} = <<'EOF';
86 <p class="option">-h | -?</p>
88 With -h or -? cdd will print a list of options and exit.
91 $help_text{-help
} = <<'EOF';
92 <p class="option">-help</p>
94 With -help cdd will print this, longer, help message.
97 $help_text{-bins
} = <<'EOF';
98 <p class="option">-bins=$number</p>
100 Sets the number of databins, or cdd datasets, to use. If the
101 number of unique values, or factors, in the based_on column is
102 higher than the number of bins then one or more factors will be
103 deleted in each cdd dataset. Specifying $number as higher than
104 the number of factors will have no effect. The bin number is
105 then set to the number of factors.
106 Default value = Number of unique values in the based_on column.
109 $help_text{-selection_method
} = <<'EOF';
110 <p class="option">-selection_method='random' or 'consecutive'</p>
112 Specifies whether the factors selected for exclusion should be
113 drawn randomly or consecutively from the datafile.
114 Default value = 'consecutive'
117 $help_text{-case_column
} = <<'EOF';
118 <p class="option">-case_column=column_name|column_number</p>
120 This flag is mandatory. Through this flag you set the column on
121 which the case-deletion is done. You can either use the name of
122 the column as specified in the $INPUT record in the model file
123 or you can use the column number.
127 $help_text{-rplots
} = <<'EOF';
128 <p class="option">-rplots</p>
130 Generate R scripts for making various plots of the result.
133 $help_text{-xv
} = <<'EOF';
134 <p class="option">-xv|-noxv</p>
136 Turns the cross-validation feature on (-xv) or off (-noxv). The
137 default behavior is to run the cross-validation step.
140 $help_text{Post_help_message
} = <<'EOF';
141 Also see 'execute -help' for a description of common options.
144 common_options
::online_help
( 'cdd', \
%options, \
%help_text, \
%required_options, \
%optional_options);
146 ## Check that we do have a model file
147 if ( scalar(@ARGV) < 1 ) {
148 print "A model file must be specified. Use 'cdd -h' for help.\n";
152 if( scalar(@ARGV) > 1 ){
153 print "CDD can only handle one modelfile. Use 'cdd -h' for help.\n";die;
157 unless ( defined $options{'case_column'} ){
158 print "case_column must be given\n" ;
162 ui
-> category
( 'cdd' );
163 ui
-> silent
(1) if( $options{'silent'} );
165 debug
-> level
( $options{'debug'} );
166 debug
-> package( $options{'debug_package'} );
167 debug
-> subroutine
( $options{'debug_subroutine'} );
168 debug
-> warn_with_trace
( $options{'warn_with_trace'} );
170 my $eval_string = common_options
::model_parameters
(\
%options);
172 my $model = model
-> new
( eval( $eval_string ),
173 filename
=> $ARGV[0],
174 ignore_missing_output_files
=> 1 );
176 if( $options{'shrinkage'} ) {
177 $model -> shrinkage_stats
( enabled
=> 1 );
180 if( $options{'threads'} ){
181 $options{'threads'} = [1,$options{'threads'}] ;
184 ## Create new Cdd object:
185 my $cdd = tool
::cdd
->
186 new
( eval( $common_options::parameters
),
187 models
=> [ $model ],
188 bins
=> $options{'bins'},
189 selection_method
=> $options{'selection_method'},
190 case_columns
=> $options{'case_column'},
191 outside_n_sd_check
=> $options{'outside_n_sd_check'},
192 cross_validate
=> $options{'xv'} );
194 open(CMD
, ">", $cdd -> directory
. "/command.txt");
195 print CMD
$cmd_line, "\n";
198 if ( $options{'summarize'} ) {
199 $cdd -> prepare_results
();
200 $cdd -> print_summary
;
203 $cdd -> prepare_results
();
204 $cdd -> print_results
;
205 # $cdd -> print_summary;
208 if( $options{'rplots'} ){
209 $cdd -> create_R_scripts
();