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" => '',
27 "cross_validate:1" => '0|1',
29 "selection_method:s" => '\'random\'|\'consecutive\'' );
31 my $res = GetOptions( \%options,
32 @common_options::get_opt_strings,
33 keys(%required_options),
34 keys(%optional_options) );
37 common_options::set_globals( \%options );
41 $help_text{Pre_help_message} = <<'EOF';
44 Perl script for Case-Deletion Diagnostics of NONMEM runs.
49 $help_text{Description
} = <<'EOF';
52 The Case Deletion Diagnostics tool is run from the command line
53 with a few mandatory arguments. CDD is run as a diagnostic after
54 a model is regarded finished or at least mature enough to run
55 validation tool on. You need to specify the NONMEM modelfile
56 with a model that have successful termination. You also have to
57 specify the number or name of the datafile column on which to
58 select for deletion. You do so with the case_column option.
61 $help_text{Examples
} = <<'EOF';
64 cdd -model=run89.mod -case_column=10
66 This will perform a Case Deletion Diagnostic on the model
67 specified in run89.mod based on the factors in column ten. If,
68 for example, column ten holds the ids of the seven centers
69 included in the study, this command will create seven copies of
70 the dataset, each with individuals included in one specific
71 center deleted. Say that the centers are numbered 1 to 7. Then
72 dataset 1 will have individuals from center 1 excluded, dataset
73 2 individuals from center 2 and so on.
76 $help_text{Options
} = <<'EOF';
79 The options are given here in their long form. Any option may be
80 abbreviated to any nonconflicting prefix. The -threads option
81 may be abbreviated to -t(or even -thr) but -debug may not be
82 abbreviated to -d because it conflicts with -debug_packages and
85 The following options are valid:
88 $help_text{-h
} = <<'EOF';
91 With -h or -? cdd will print a list of options and exit.
94 $help_text{-help
} = <<'EOF';
97 With -help cdd will print this, longer, help message.
100 $help_text{-bins
} = <<'EOF';
103 Sets the number of databins, or cdd datasets, to use. If the
104 number of unique values, or factors, in the based_on column is
105 higher than the number of bins then one or more factors will be
106 deleted in each cdd dataset. Specifying $number as higher than
107 the number of factors will have no effect. The bin number is
108 then set to the number of factors.
109 Default value = Number of unique values in the based_on column.
112 $help_text{-selection_method
} = <<'EOF';
113 -selection_method='random' or 'consecutive'
115 Specifies whether the factors selected for exclusion should be
116 drawn randomly or consecutively from the datafile.
117 Default value = 'consecutive'
120 $help_text{-case_column
} = <<'EOF';
121 -case_column=column_name|column_number
124 $help_text{-rplots
} = <<'EOF';
125 <p class="style2">-rplots</p>
127 Generate R scripts for making various plots of the result.
130 $help_text{Post_help_message
} = <<'EOF';
131 Also see 'execute -help' for a description of common options.
134 common_options
::online_help
( 'cdd', \
%options, \
%help_text, \
%required_options, \
%optional_options);
136 ## Check that we do have a model file
137 if ( scalar(@ARGV) < 1 ) {
138 print "A model file must be specified. Use 'cdd -h' for help.\n";
142 if( scalar(@ARGV) > 1 ){
143 print "CDD can only handle one modelfile. Use 'cdd -h' for help.\n";die;
147 unless ( defined $options{'case_column'} ){
148 print "case_column must be given\n" ;
152 ui
-> category
( 'cdd' );
153 ui
-> silent
(1) if( $options{'silent'} );
155 debug
-> level
( $options{'debug'} );
156 debug
-> package( $options{'debug_package'} );
157 debug
-> subroutine
( $options{'debug_subroutine'} );
158 debug
-> warn_with_trace
( $options{'warn_with_trace'} );
160 my $eval_string = common_options
::model_parameters
(\
%options);
162 my $model = model
-> new
( eval( $eval_string ),
163 filename
=> $ARGV[0],
164 ignore_missing_output_files
=> 1 );
166 if( $options{'shrinkage'} ) {
167 $model -> shrinkage_stats
( enabled
=> 1 );
170 ## Create new Cdd object:
171 my $cdd = tool
::cdd
->
172 new
( eval( $common_options::parameters
),
173 models
=> [ $model ],
174 bins
=> $options{'bins'},
175 selection_method
=> $options{'selection_method'},
176 case_columns
=> $options{'case_column'} );
178 open(CMD
, ">", $cdd -> directory
. "/command.txt");
179 print CMD
$cmd_line, "\n";
182 if ( $options{'summarize'} ) {
183 $cdd -> prepare_results
();
184 $cdd -> print_summary
;
187 $cdd -> prepare_results
();
188 $cdd -> print_results
;
189 # $cdd -> print_summary;
192 if( $options{'rplots'} ){
193 $cdd -> create_R_scripts
();