| 1 | package Bio::SDRS; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use 5.008; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 9 | ▶ | use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION $AUTOLOAD); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 9 | ▶ | use Carp qw(cluck croak carp); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 9 | ▶ | use POSIX; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 9 | ▶ | use Math::NumberCruncher; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 9 | ▶ | use Statistics::Distributions; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 9 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 9 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||||||||||||||||||||||||
| 18 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | # This allows declaration | ||||||||||||||||||||||||||||||||||||||||||
| 21 | # use Bio::SDRS ':all'; | ||||||||||||||||||||||||||||||||||||||||||
| 22 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||||||||||||||||||||||||||||||||||
| 23 | # will save memory. | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 9 | our %EXPORT_TAGS = ( 'all' => [ qw() ] ); | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 9 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 9 | our @EXPORT = qw(); | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 9 | our $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 9 | my %component = map { ($_ => 1) } ('MULTIPLE', 'LDOSE', 'HDOSE', 'STEP', | |||||||||||||||||||||||||||||||||||||||||
| 33 | 'MAXPROC', 'TRIM', 'SIGNIFICANCE', | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 'TMPDIR', 'DEBUG'); | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 9 | our $VERSION = '0.11'; | |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | Bio::SDRS - Perl extension for Sigmoidal Dose Response Search, a tool | ||||||||||||||||||||||||||||||||||||||||||
| 43 | for characterizing biological responses to compounds. | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | use Bio::SDRS; | ||||||||||||||||||||||||||||||||||||||||||
| 48 | my $sdrs = new Bio::SDRS; | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | $sdrs->doses(0.423377, 1.270132, 3.810395, 11.431184, 34.293553, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 102.880658, 308.641975, 925.925926, 2777.777778, 8333.333333, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 25000); | ||||||||||||||||||||||||||||||||||||||||||
| 53 | $sdrs->set_assay('C8-BMS-208882', | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 1.885, 1.82, 2.2, 2.205, 2.78, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 4.965, 9.21, 31.275, 74.445, 99.03, | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 100); | ||||||||||||||||||||||||||||||||||||||||||
| 57 | $sdrs->calculate; | ||||||||||||||||||||||||||||||||||||||||||
| 58 | foreach my $assay ($sdrs->assays) { | ||||||||||||||||||||||||||||||||||||||||||
| 59 | print "$assay\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 60 | foreach my $prop (('MAX', 'MIN', 'LOW', 'HIGH', 'EC50', | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 'PVALUE', 'EC50RANGE', 'PEAK', 'A', 'B', | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 'D', 'FOLD')) { | ||||||||||||||||||||||||||||||||||||||||||
| 63 | printf " %s = %s\n", $prop, $sdrs->ec50data($assay, $prop); | ||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | print "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | =head2 Constructor | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | $obj = new Bio::SDRS; | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | # You can also use $obj = Bio::SDRS->new(); | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | =head2 Object Methods | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | =head3 Input Methods | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | $sdrs->multiple([$new_multiple]); | ||||||||||||||||||||||||||||||||||||||||||
| 79 | $sdrs->ldose([$new_ldose]); | ||||||||||||||||||||||||||||||||||||||||||
| 80 | $sdrs->hdose([$new_hdose]); | ||||||||||||||||||||||||||||||||||||||||||
| 81 | $sdrs->step([$new_step]); | ||||||||||||||||||||||||||||||||||||||||||
| 82 | $sdrs->maxproc([$new_maxproc]); | ||||||||||||||||||||||||||||||||||||||||||
| 83 | $sdrs->trim([$new_trim]); | ||||||||||||||||||||||||||||||||||||||||||
| 84 | $sdrs->significance([$new_significance]); | ||||||||||||||||||||||||||||||||||||||||||
| 85 | $sdrs->tmpdir([$new_tmpdir]); | ||||||||||||||||||||||||||||||||||||||||||
| 86 | $sdrs->debug([$new_debug]); | ||||||||||||||||||||||||||||||||||||||||||
| 87 | $sdrs->doses(doses...); | ||||||||||||||||||||||||||||||||||||||||||
| 88 | $sdrs->set_assay(assay, {response}...) | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | =head3 Output Methods | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | $sdrs->assays; | ||||||||||||||||||||||||||||||||||||||||||
| 93 | $sdrs->scandata; | ||||||||||||||||||||||||||||||||||||||||||
| 94 | $sdrs->score_doses; | ||||||||||||||||||||||||||||||||||||||||||
| 95 | $sdrs->sorted_assays_by_dose([$dose]); | ||||||||||||||||||||||||||||||||||||||||||
| 96 | $sdrs->pvalues_by_dose([$dose]) | ||||||||||||||||||||||||||||||||||||||||||
| 97 | $sdrs->ec50data([$assay[, $property[, $precision]]]); | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | =head3 Other Methods | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | $sdrs->calculate; | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | Bio::SDRS implements the Sigmoidal Dose Response Search of assay responses | ||||||||||||||||||||||||||||||||||||||||||
| 106 | described in the paper by | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | Rui-Ru Ji, Nathan O. Siemers, Lei Ming, Liang Schweizer, and Robert E | ||||||||||||||||||||||||||||||||||||||||||
| 109 | Bruccoleri. | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | The module is implemented using a simple object oriented paradigm | ||||||||||||||||||||||||||||||||||||||||||
| 112 | where the object stores all the information needed for a calculation | ||||||||||||||||||||||||||||||||||||||||||
| 113 | along with a state variable, C<STATE>. The state variable has three | ||||||||||||||||||||||||||||||||||||||||||
| 114 | possible values, C<'setup'>, C<'calculating'> and C<'calculated'>. The | ||||||||||||||||||||||||||||||||||||||||||
| 115 | value of C<'setup'> indicates that the object is being setup with | ||||||||||||||||||||||||||||||||||||||||||
| 116 | data, and any results in the object are inconsistent with the data. | ||||||||||||||||||||||||||||||||||||||||||
| 117 | The value of C<'calculating'> indicates the object's computations are | ||||||||||||||||||||||||||||||||||||||||||
| 118 | in progress and tells the code not to delete intermediate files. This | ||||||||||||||||||||||||||||||||||||||||||
| 119 | object runs in parallel, and the object destruction code gets called | ||||||||||||||||||||||||||||||||||||||||||
| 120 | when each thread exits. Intermediate files must be protected at that | ||||||||||||||||||||||||||||||||||||||||||
| 121 | time. The value of C<'calculated'> indicates that the object's | ||||||||||||||||||||||||||||||||||||||||||
| 122 | computational results are consistent with the data, and may be | ||||||||||||||||||||||||||||||||||||||||||
| 123 | returned to a calling program. | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | The C<'calculate'> method is used to update all the calculated values | ||||||||||||||||||||||||||||||||||||||||||
| 126 | from the input data. It checks the state variable first, and only does | ||||||||||||||||||||||||||||||||||||||||||
| 127 | the calculation if the state is C<'setup'>. Once the calculations are | ||||||||||||||||||||||||||||||||||||||||||
| 128 | complete, then the state variable is set to C<'calculated'>. Thus, the | ||||||||||||||||||||||||||||||||||||||||||
| 129 | C<calculate> method can be called whenever a calculated value is | ||||||||||||||||||||||||||||||||||||||||||
| 130 | needed, and there is no performance penalty. | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | The module initializes the C<Bio::SDRS> object with a state of | ||||||||||||||||||||||||||||||||||||||||||
| 133 | C<'setup'>. Any data input sets the state to C<'setup'>. Any requests | ||||||||||||||||||||||||||||||||||||||||||
| 134 | for calculated data, calls C<'calculate'>, which updates the state | ||||||||||||||||||||||||||||||||||||||||||
| 135 | variable so futures requests for calculated data return quickly. | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | B<N.B.> This module uses parallel programming via a fork call to get | ||||||||||||||||||||||||||||||||||||||||||
| 138 | high performance. I<You must close all database connections prior to | ||||||||||||||||||||||||||||||||||||||||||
| 139 | calling the C<calculate> method, and reopen them afterwards. In | ||||||||||||||||||||||||||||||||||||||||||
| 140 | addition, you must ensure that any automated DESTROY methods take in | ||||||||||||||||||||||||||||||||||||||||||
| 141 | account their execution when the child processes terminated.> | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | The following methods are provided: | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | =item C<new()> | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | Creates a new Bio::SDRS object. | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 14 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 14 | my $pkg; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 14 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 14 | eval {($pkg) = caller(0);}; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 14 | ▶ | if ($class ne $pkg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | unshift @_, $class; | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 14 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 14 | bless $self; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 14 | $self->_init_data; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 14 | $self->{MULTIPLE} = 1.18; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 14 | $self->{LDOSE} = 0.17; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 14 | $self->{HDOSE} = 30000; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 14 | $self->{STEP} = 60; | |||||||||||||||||||||||||||||||||||||||||
| 172 | 14 | $self->{MAXPROC} = 2; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 14 | $self->{TRIM} = 0.0; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 14 | $self->{SIGNIFICANCE} = 0.05; | |||||||||||||||||||||||||||||||||||||||||
| 175 | 14 | $self->{DEBUG} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 14 | $self->_init_tmp; | |||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 14 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 28 | ▶ | sub _init_data { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_data: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 28 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 183 | 28 | $self->{STATE} = "setup"; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 28 | $self->{DOSES} = []; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 28 | $self->{RESPONSES} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 14 | ▶ | sub _init_tmp { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_tmp: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 14 | ▶ | my $tmp = exists($ENV{TMPDIR}) ? $ENV{TMPDIR} : "/tmp"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 14 | $tmp .= "/sdrs"; | |||||||||||||||||||||||||||||||||||||||||
| 192 | 14 | ▶ | if (exists($ENV{USER})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $tmp .= "." . $ENV{USER}; | |||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 14 | $tmp .= "." . $$; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 14 | $self->{TMPDIR} = $tmp; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 14 | $self->{TMP_CREATED} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 14 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | # There's an important multiprocessing issue to keep in mind here. | ||||||||||||||||||||||||||||||||||||||||||
| 203 | # When this process forks, this method will be invoked for all the subprocesses. | ||||||||||||||||||||||||||||||||||||||||||
| 204 | # Thus, we need to prevent the deletion of the temporary array until the | ||||||||||||||||||||||||||||||||||||||||||
| 205 | # calculation is completed. That is why there is a check on the STATE. | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 208 | 14 | ▶ | if (not $self->{DEBUG} and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
not $self->{"DEBUG"} and $self->{"TMP_CREATED"} and $self->{"STATE"} eq "calculated"
not $self->{"DEBUG"} and $self->{"TMP_CREATED"}
MC/DC33%1/3
not $self->{"DEBUG"} and $self->{"TMP_CREATED"} and $self->{"STATE"} eq "calculated"
not $self->{"DEBUG"}
$self->{"TMP_CREATED"}
$self->{"STATE"} eq "calculated"
Truth table50%2/4
not(A) and B and C
A= not $self->{"DEBUG"}B= $self->{"TMP_CREATED"}C= $self->{"STATE"} eq "calculated"
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | $self->{TMP_CREATED} and | ||||||||||||||||||||||||||||||||||||||||||
| 210 | $self->{STATE} eq 'calculated') { | ||||||||||||||||||||||||||||||||||||||||||
| 211 | &_system_with_check("rm -rf " . $self->{TMPDIR}, | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 6 | $self->{DEBUG}); | |||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | # documentation for autoloaded methods goes here. | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | =item C<multiple([$multiple_value])> | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | Retrieves the current setting for the C<multiple> value, | ||||||||||||||||||||||||||||||||||||||||||
| 221 | and optionally sets it. This value specifies the multiplicity factor | ||||||||||||||||||||||||||||||||||||||||||
| 222 | for increasing the dose in the search. It must be greater than one. | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | =item C<ldose([$ldose_value])> | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | Retrieves the current setting for the C<ldose> value, | ||||||||||||||||||||||||||||||||||||||||||
| 227 | and optionally sets it. This value specifies the lowest dose in the search. | ||||||||||||||||||||||||||||||||||||||||||
| 228 | It must be greater than zero. | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | =item C<hdose([$hdose_value])> | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | Retrieves the current setting for the C<hdose> value, | ||||||||||||||||||||||||||||||||||||||||||
| 233 | and optionally sets it. This value specifies the highest | ||||||||||||||||||||||||||||||||||||||||||
| 234 | dose in the search. It must be greater than the ldose value. | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | =item C<step([$step_value])> | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | Retrieves the current setting for the C<step> value, and optionally | ||||||||||||||||||||||||||||||||||||||||||
| 239 | sets it. This value specifies the maximum change in doses in the | ||||||||||||||||||||||||||||||||||||||||||
| 240 | search. In the search process, this module starts at the ldose | ||||||||||||||||||||||||||||||||||||||||||
| 241 | value. It tries multiplying the current dose by the C<multiple> value, | ||||||||||||||||||||||||||||||||||||||||||
| 242 | but it will only increase the dose by no more than the C<step> value | ||||||||||||||||||||||||||||||||||||||||||
| 243 | specified here. It must be positive. | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | =item C<maxproc([$maxproc_value])> | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | Retrieves the current setting for the C<maxproc> value, | ||||||||||||||||||||||||||||||||||||||||||
| 248 | and optionally sets it. This value specifies the maximum number of processes that | ||||||||||||||||||||||||||||||||||||||||||
| 249 | can be used for the search. The upper limit is 64 and the lower limit is 1. | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | =item C<trim([$trim_value])> | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | Retrieves the current setting for the C<trim> value, and optionally | ||||||||||||||||||||||||||||||||||||||||||
| 254 | sets it. This value specifies the trimming factor for the number of | ||||||||||||||||||||||||||||||||||||||||||
| 255 | assays. If the C<trim> is 0, then all assays will be used, and if 1, | ||||||||||||||||||||||||||||||||||||||||||
| 256 | no assays will be used. It must be between 0 and 1. | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | =item C<significance([$significance_value])> | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | Retrieves the current setting for the C<significance> value, and | ||||||||||||||||||||||||||||||||||||||||||
| 261 | optionally sets it. This value specifies the minimum permitted | ||||||||||||||||||||||||||||||||||||||||||
| 262 | significance value for the F score cutoff. It must be between zero and | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 1. | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | =item C<tmpdir([$tmpdir_value])> | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | Retrieves the current setting for the C<tmpdir> value, and optionally | ||||||||||||||||||||||||||||||||||||||||||
| 268 | sets it. This value specifies the temporary directory where scans of | ||||||||||||||||||||||||||||||||||||||||||
| 269 | the dose calculation are written. The default is | ||||||||||||||||||||||||||||||||||||||||||
| 270 | /tmp/sdrs.C<user>.C<process_id>. | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | =item C<debug([$debug_value])> | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | Retrieves the current setting for the C<debug> variable, and | ||||||||||||||||||||||||||||||||||||||||||
| 275 | optionally sets it. This value specifies whether debugging information | ||||||||||||||||||||||||||||||||||||||||||
| 276 | is printed and if the temporary directory (see above) is deleted after | ||||||||||||||||||||||||||||||||||||||||||
| 277 | execution of this module. | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 112 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=23 SCAR=41.1
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 112 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 112 | my $type = ref($self); | |||||||||||||||||||||||||||||||||||||||||
| 284 | 112 | my $pkg = __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||
| 285 | 112 | my ($pos, $new_val); | |||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 112 | ▶ | croak "$self is not an object\n" if not $type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 112 | ▶ | croak "$pkg AUTOLOAD function fails on $type\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | if $type !~ m/^$pkg$/; | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 112 | my $name = uc($AUTOLOAD); | |||||||||||||||||||||||||||||||||||||||||
| 291 | 112 | $name =~ s/^.*:://; | |||||||||||||||||||||||||||||||||||||||||
| 292 | 112 | ▶ | if (not exists($component{$name})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | croak "$name is not a valid method for $type.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | elsif (not exists($self->{$name})) { | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | croak "$name is not a valid method for $type\n"; | |||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | elsif (defined $_[0]) { | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 112 | $self->{$name} = shift; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 112 | $self->{STATE} = "setup"; | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 112 | ▶ | if ($name eq "MULTIPLE" and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$name eq "MULTIPLE" and $self->{"MULTIPLE"} <= 1
MC/DC0%0/2
$name eq "MULTIPLE" and $self->{"MULTIPLE"} <= 1
$name eq "MULTIPLE"
$self->{"MULTIPLE"} <= 1
Truth table66%2/3
A and B
A= $name eq "MULTIPLE"B= $self->{"MULTIPLE"} <= 1
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | $self->{MULTIPLE} <= 1.0) { | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | croak "multiple parameter must be greater than 1.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 112 | ▶ | if ($name eq "LDOSE" and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$name eq "LDOSE" and $self->{"LDOSE"} <= 0
MC/DC0%0/2
$name eq "LDOSE" and $self->{"LDOSE"} <= 0
$name eq "LDOSE"
$self->{"LDOSE"} <= 0
Truth table66%2/3
A and B
A= $name eq "LDOSE"B= $self->{"LDOSE"} <= 0
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | $self->{LDOSE} <= 0.0) { | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | croak "ldose parameter must be positive.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 112 | ▶ | if ($name eq "HDOSE" and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$name eq "HDOSE" and $self->{"HDOSE"} <= $self->{"LDOSE"}
MC/DC0%0/2
$name eq "HDOSE" and $self->{"HDOSE"} <= $self->{"LDOSE"}
$name eq "HDOSE"
$self->{"HDOSE"} <= $self->{"LDOSE"}
Truth table66%2/3
A and B
A= $name eq "HDOSE"B= $self->{"HDOSE"} <= $self->{"LDOSE"}
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | $self->{HDOSE} <= $self->{LDOSE}) { | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | croak "hdose parameter must be greater than the ldose parameter.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 314 | 112 | ▶ | if ($name eq "STEP" and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$name eq "STEP" and $self->{"STEP"} <= 0
MC/DC0%0/2
$name eq "STEP" and $self->{"STEP"} <= 0
$name eq "STEP"
$self->{"STEP"} <= 0
Truth table66%2/3
A and B
A= $name eq "STEP"B= $self->{"STEP"} <= 0
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | $self->{STEP} <= 0.0) { | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | croak "step parameter must be positive.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 112 | ▶ | if ($name eq "MAXPROC" and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$name eq "MAXPROC" and $self->{"MAXPROC"} > 64 || $self->{"MAXPROC"} < 1
$self->{"MAXPROC"} > 64 or $self->{"MAXPROC"} < 1
MC/DC0%0/3
$name eq "MAXPROC" and $self->{"MAXPROC"} > 64 || $self->{"MAXPROC"} < 1
$name eq "MAXPROC"
$self->{"MAXPROC"} > 64
$self->{"MAXPROC"} < 1
Truth table50%2/4
A and B or C
A= $name eq "MAXPROC"B= $self->{"MAXPROC"} > 64C= $self->{"MAXPROC"} < 1
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | ($self->{MAXPROC} > 64 or $self->{MAXPROC} < 1)) { | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | croak "maxproc parameter must be between 1 and 64.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 112 | ▶ | if ($name eq "TRIM" and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$name eq "TRIM" and $self->{"TRIM"} < 0 || $self->{"TRIM"} > 1
$self->{"TRIM"} < 0 or $self->{"TRIM"} > 1
MC/DC0%0/3
$name eq "TRIM" and $self->{"TRIM"} < 0 || $self->{"TRIM"} > 1
$name eq "TRIM"
$self->{"TRIM"} < 0
$self->{"TRIM"} > 1
Truth table50%2/4
A and B or C
A= $name eq "TRIM"B= $self->{"TRIM"} < 0C= $self->{"TRIM"} > 1
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | ($self->{TRIM} < 0.0 or | ||||||||||||||||||||||||||||||||||||||||||
| 324 | $self->{TRIM} > 1.0)) { | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | croak "trim parameter must be between 0 and 1, inclusive\n"; | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 112 | ▶ | if ($name eq "SIGNIFICANCE" and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$name eq "SIGNIFICANCE" and $self->{"SIGNIFICANCE"} <= 0 || $self->{"SIGNIFICANCE"} >= 1
$self->{"SIGNIFICANCE"} <= 0 or $self->{"SIGNIFICANCE"} >= 1
MC/DC0%0/3
$name eq "SIGNIFICANCE" and $self->{"SIGNIFICANCE"} <= 0 || $self->{"SIGNIFICANCE"} >= 1
$name eq "SIGNIFICANCE"
$self->{"SIGNIFICANCE"} <= 0
$self->{"SIGNIFICANCE"} >= 1
Truth table50%2/4
A and B or C
A= $name eq "SIGNIFICANCE"B= $self->{"SIGNIFICANCE"} <= 0C= $self->{"SIGNIFICANCE"} >= 1
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | ($self->{SIGNIFICANCE} <= 0.0 or | ||||||||||||||||||||||||||||||||||||||||||
| 329 | $self->{SIGNIFICANCE} >= 1.0)) { | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | croak "trim parameter must be between 0 and 1, exclusive\n"; | |||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 112 | return $self->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | =item C<doses($dose1, $dose2, ...)> | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | Specify the list of compound doses used in the all the assays in the | ||||||||||||||||||||||||||||||||||||||||||
| 338 | experiment. The doses must be in numerical order, from smallest to | ||||||||||||||||||||||||||||||||||||||||||
| 339 | largest. | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 14 | ▶ | sub doses { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
doses: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 345 | 14 | ▶ | if (scalar(@_) == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | return @{$self->{DOSES}}; | |||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 14 | $self->_init_data; | |||||||||||||||||||||||||||||||||||||||||
| 350 | 14 | my $dose1 = shift; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 14 | push(@{$self->{DOSES}}, $dose1); | |||||||||||||||||||||||||||||||||||||||||
| 352 | 14 | foreach my $dose (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 353 | 125 | ▶ | if ($dose < $dose1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | croak "Doses not in order. Current dose is $dose, and previous does is $dose1\n"; | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 125 | push(@{$self->{DOSES}}, $dose); | |||||||||||||||||||||||||||||||||||||||||
| 357 | 125 | $dose1 = $dose; | |||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 359 | 14 | $self->{STATE} = "setup"; | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | =item C<set_assay($assay_name, $response1, ...)> | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | Adds an assay to the list to be searched over. Each response in the | ||||||||||||||||||||||||||||||||||||||||||
| 366 | list corresponds to the doses specified in the C<doses> method. The | ||||||||||||||||||||||||||||||||||||||||||
| 367 | number must match, and they must be in numerical order, from smallest | ||||||||||||||||||||||||||||||||||||||||||
| 368 | to largest. | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 275 | ▶ | sub set_assay { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_assay: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 275 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 374 | 275 | my $assay = shift; | |||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | 275 | $self->{STATE} = "setup"; | |||||||||||||||||||||||||||||||||||||||||
| 377 | 275 | ▶ | if (exists($self->{RESPONSES}->{$assay})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | croak "Duplicate assay ($assay) response specified.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | 275 | $self->{RESPONSES}->{$assay} = [ @_ ]; | |||||||||||||||||||||||||||||||||||||||||
| 381 | 275 | ▶ | if (scalar(@{$self->{DOSES}}) == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | croak "You must call the doses method before calling the set_assay method.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 275 | my $nresp = scalar(@{$self->{RESPONSES}->{$assay}}); | |||||||||||||||||||||||||||||||||||||||||
| 385 | 275 | my $ndoses = scalar(@{$self->{DOSES}}); | |||||||||||||||||||||||||||||||||||||||||
| 386 | 275 | ▶ | if ($nresp != $ndoses) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | croak "The number of assay responses ($nresp) does not equal the number of doses ($ndoses)\n"; | |||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | =item C<assays()> | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | Return the list of assay names; | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 6 | ▶ | sub assays { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assays: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 399 | 6 | return keys %{$self->{RESPONSES}}; | |||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | =item C<calculate()> | ||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | Perform the SDRS calculation. | ||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 14 | ▶ | sub calculate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
calculate: called CC=29 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 410 | 14 | ▶ | return if $self->{STATE} eq 'calculated'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 14 | $self->_make_tmp; | |||||||||||||||||||||||||||||||||||||||||
| 412 | 14 | $self->{STATE} = "calculating"; | |||||||||||||||||||||||||||||||||||||||||
| 413 | # | ||||||||||||||||||||||||||||||||||||||||||
| 414 | # Calculate F Test degrees of freedom. | ||||||||||||||||||||||||||||||||||||||||||
| 415 | # | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 14 | my $ndoses = scalar(@{$self->{DOSES}}); | |||||||||||||||||||||||||||||||||||||||||
| 417 | 14 | my $p = 4; #number of parameters | |||||||||||||||||||||||||||||||||||||||||
| 418 | 14 | $self->{FDISTR_N} = $p - 1; | |||||||||||||||||||||||||||||||||||||||||
| 419 | 14 | $self->{FDISTR_M} = $ndoses - $p; | |||||||||||||||||||||||||||||||||||||||||
| 420 | $self->{CUTOFF} = Statistics::Distributions::fdistr($self->{FDISTR_N}, | ||||||||||||||||||||||||||||||||||||||||||
| 421 | $self->{FDISTR_M}, | ||||||||||||||||||||||||||||||||||||||||||
| 422 | 14 | $self->{SIGNIFICANCE}); | |||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 14 | my $count = scalar(keys %{$self->{RESPONSES}}); | |||||||||||||||||||||||||||||||||||||||||
| 425 | 14 | foreach my $assay (keys %{$self->{RESPONSES}}) { | |||||||||||||||||||||||||||||||||||||||||
| 426 | 275 | my @data = @{$self->{RESPONSES}->{$assay}}; | |||||||||||||||||||||||||||||||||||||||||
| 427 | 275 | my ($max, $min) = Math::NumberCruncher::Range(\@data); | |||||||||||||||||||||||||||||||||||||||||
| 428 | 275 | $self->{MAX}->{$assay} = $max; | |||||||||||||||||||||||||||||||||||||||||
| 429 | 275 | $self->{MIN}->{$assay} = $min; | |||||||||||||||||||||||||||||||||||||||||
| 430 | 275 | my $value = _compute_sst(\@data); #total sum of squares | |||||||||||||||||||||||||||||||||||||||||
| 431 | 275 | $self->_define_ab_boundary($assay, \@data); | |||||||||||||||||||||||||||||||||||||||||
| 432 | 275 | $self->{SST}->{$assay} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 433 | 275 | $self->{VALUES}->{$assay} = \@data; | |||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 435 | 14 | my $assayNum = int($count * (1 - $self->{TRIM})); | |||||||||||||||||||||||||||||||||||||||||
| 436 | 14 | my %expressedAssays; | |||||||||||||||||||||||||||||||||||||||||
| 437 | 14 | $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 438 | 14 | foreach my $g (sort {$self->{MAX}->{$b} <=> $self->{MAX}->{$a}} (keys %{$self->{MAX}})) { | |||||||||||||||||||||||||||||||||||||||||
| 439 | 275 | ▶ | last if ($count >= $assayNum); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 275 | $expressedAssays{$g} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 441 | 275 | $count++; | |||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | 14 | my (%pvalues, %sortedprobes, $pid, @pids, $file, $iproc, $err); | |||||||||||||||||||||||||||||||||||||||||
| 445 | 14 | my $tmpdir = $self->{TMPDIR}; | |||||||||||||||||||||||||||||||||||||||||
| 446 | 14 | ▶ | for ($iproc = 0; $iproc < $self->{MAXPROC}; $iproc++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | 44 | ▶ | if ($pid = fork) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 448 | 36 | ▶ | print STDERR "Process $pid forked.\n" if $self->{DEBUG}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 449 | 36 | push @pids, $pid; | |||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||
| 451 | elsif (defined $pid) { | ||||||||||||||||||||||||||||||||||||||||||
| 452 | 8 | sleep $iproc; | |||||||||||||||||||||||||||||||||||||||||
| 453 | 8 | $file = "$tmpdir/sdrs.out.$iproc"; | |||||||||||||||||||||||||||||||||||||||||
| 454 | 8 | ▶ | open (ECOUT, ">$file") || die "can not open EC50 output file: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | # | ||||||||||||||||||||||||||||||||||||||||||
| 456 | # The following statement causes the system to write each output line | ||||||||||||||||||||||||||||||||||||||||||
| 457 | # to disk immediately, rather than waiting for a buffer to fill. | ||||||||||||||||||||||||||||||||||||||||||
| 458 | # | ||||||||||||||||||||||||||||||||||||||||||
| 459 | 8 | select((select(ECOUT), $| = 1)[$[]); # Change buffering to line by line. | |||||||||||||||||||||||||||||||||||||||||
| 460 | 8 | my $last_dose = $self->{LDOSE}; | |||||||||||||||||||||||||||||||||||||||||
| 461 | 8 | my $icount = 0; | |||||||||||||||||||||||||||||||||||||||||
| 462 | 8 | ▶ | for (my $dose = $self->{LDOSE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | $dose < $self->{HDOSE} * $self->{MULTIPLE}; | ||||||||||||||||||||||||||||||||||||||||||
| 464 | $dose *= $self->{MULTIPLE}) { | ||||||||||||||||||||||||||||||||||||||||||
| 465 | 10984 | ▶ | if ($dose - $last_dose > $self->{STEP}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | 9840 | $dose = $last_dose + $self->{STEP}; | |||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||
| 468 | 10984 | ▶ | if (($icount++ % $self->{MAXPROC}) == $iproc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | 2746 | print ECOUT $self->_scan_dose_point($dose); | |||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||
| 471 | 10984 | $last_dose = $dose; | |||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||
| 473 | 8 | close ECOUT; | |||||||||||||||||||||||||||||||||||||||||
| 474 | 8 | exit 0; | |||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||
| 476 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | die "Can't fork: $!\n"; | |||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||
| 480 | 6 | $err = 0; | |||||||||||||||||||||||||||||||||||||||||
| 481 | 6 | foreach $pid (@pids) { | |||||||||||||||||||||||||||||||||||||||||
| 482 | 24 | waitpid($pid, 0); | |||||||||||||||||||||||||||||||||||||||||
| 483 | 24 | ▶ | if ($? != 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | print STDERR "Process $pid return status was $?\n"; | |||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $err = 1; | |||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | # Now collect all the outputs together. | ||||||||||||||||||||||||||||||||||||||||||
| 490 | 6 | %{$self->{GSCORE}} = (); | |||||||||||||||||||||||||||||||||||||||||
| 491 | 6 | %{$self->{GPARAM}} = (); | |||||||||||||||||||||||||||||||||||||||||
| 492 | 6 | %{$self->{FSCORES}} = (); | |||||||||||||||||||||||||||||||||||||||||
| 493 | 6 | my $multiple = $self->{MULTIPLE}; | |||||||||||||||||||||||||||||||||||||||||
| 494 | 6 | my $step = $self->{STEP}; | |||||||||||||||||||||||||||||||||||||||||
| 495 | 6 | @{$self->{SCANDATA}} = (); | |||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | 6 | ▶ | for ($iproc = 0; $iproc < $self->{MAXPROC}; $iproc++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 498 | 24 | my $infile = "$tmpdir/sdrs.out.$iproc"; | |||||||||||||||||||||||||||||||||||||||||
| 499 | 24 | ▶ | open (IN, "<$infile") || die "can not open input file $infile: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | 24 | ▶ | while (<IN>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 501 | 207323 | push (@{$self->{SCANDATA}}, $_); | |||||||||||||||||||||||||||||||||||||||||
| 502 | 207323 | chomp; | |||||||||||||||||||||||||||||||||||||||||
| 503 | 207323 | my ($assay, $dose, $fscore, $a, $b, $d) = split (/\t/, $_); | |||||||||||||||||||||||||||||||||||||||||
| 504 | 207323 | $self->{GSCORE}->{$assay}->{$dose} = $fscore; | |||||||||||||||||||||||||||||||||||||||||
| 505 | 207323 | $self->{GPARAM}->{$assay}->{$dose} = "$a:$b:$d"; | |||||||||||||||||||||||||||||||||||||||||
| 506 | 207323 | ▶ | if (defined $expressedAssays{$assay}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | 207323 | $self->{FSCORES}->{$dose}->{$assay} = $fscore; | |||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||
| 510 | 24 | close IN; | |||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | #sort probesets based on F scores for every selected doses, output P values for FDR calculation | ||||||||||||||||||||||||||||||||||||||||||
| 514 | 6 | %{$self->{SORTED_DATA}} = (); | |||||||||||||||||||||||||||||||||||||||||
| 515 | 6 | %{$self->{PVAL_DATA}} = (); | |||||||||||||||||||||||||||||||||||||||||
| 516 | 6 | foreach my $dose (keys %{$self->{FSCORES}}) { | |||||||||||||||||||||||||||||||||||||||||
| 517 | 8238 | my %fs = %{$self->{FSCORES}->{$dose}}; | |||||||||||||||||||||||||||||||||||||||||
| 518 | 8238 | ▶ | foreach my $assay (sort {$fs{$b} <=> $fs{$a} || $a cmp $b } (keys %fs)) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$fs{$b} <=> $fs{$a} || $a cmp $b
MC/DC0%0/2
$fs{$b} <=> $fs{$a} || $a cmp $b
$fs{$b} <=> $fs{$a}
$a cmp $b
Truth table66%2/3
A || B
A= $fs{$b} <=> $fs{$a}B= $a cmp $b
| |||||||||||||||||||||||||||||||||||||||||||
| 519 | 207323 | push (@{$self->{SORTED_DATA}->{$dose}}, $assay); | |||||||||||||||||||||||||||||||||||||||||
| 520 | 207323 | my $pvalue; | |||||||||||||||||||||||||||||||||||||||||
| 521 | 207323 | ▶ | if ($fs{$assay} < 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | $pvalue = 1.0; | |||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||
| 524 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 525 | $pvalue = Statistics::Distributions::fprob($self->{FDISTR_N}, | ||||||||||||||||||||||||||||||||||||||||||
| 526 | $self->{FDISTR_M}, | ||||||||||||||||||||||||||||||||||||||||||
| 527 | 207323 | $fs{$assay}); | |||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||
| 529 | 207323 | push (@{$self->{PVAL_DATA}->{$dose}}, $pvalue); | |||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | #calculates EC50 for every probeset | ||||||||||||||||||||||||||||||||||||||||||
| 534 | 6 | %{$self->{EC50DATA}} = (); | |||||||||||||||||||||||||||||||||||||||||
| 535 | 6 | foreach my $assay (keys %{$self->{GPARAM}}) { | |||||||||||||||||||||||||||||||||||||||||
| 536 | 151 | my (%fscore, %param); | |||||||||||||||||||||||||||||||||||||||||
| 537 | 151 | %fscore = %{$self->{GSCORE}->{$assay}}; | |||||||||||||||||||||||||||||||||||||||||
| 538 | 151 | %param = %{$self->{GPARAM}->{$assay}}; | |||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||
| 540 | 151 | my @sorted_list = sort {$a<=>$b} (values %fscore); | |||||||||||||||||||||||||||||||||||||||||
| 541 | 151 | my $max = pop @sorted_list; | |||||||||||||||||||||||||||||||||||||||||
| 542 | 151 | my $min = shift @sorted_list; | |||||||||||||||||||||||||||||||||||||||||
| 543 | 151 | @sorted_list = sort {$fscore{$a}<=>$fscore{$b}} (keys %fscore); | |||||||||||||||||||||||||||||||||||||||||
| 544 | 151 | my $ec50 = pop @sorted_list; #highest f score | |||||||||||||||||||||||||||||||||||||||||
| 545 | 151 | my ($range, $high, $low, $peak, $ec50range, $fold); | |||||||||||||||||||||||||||||||||||||||||
| 546 | 151 | ▶ | if ($max >= $self->{CUTOFF}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 547 | 111 | $range = $self->_find_ec50_range(\%fscore, $ec50); | |||||||||||||||||||||||||||||||||||||||||
| 548 | 111 | ($high, $low, $peak) = split (/\-/, $range); | |||||||||||||||||||||||||||||||||||||||||
| 549 | 111 | $ec50range = $high - $low; | |||||||||||||||||||||||||||||||||||||||||
| 550 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 551 | 40 | $high = $low = $peak = $ec50range = ''; | |||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||
| 553 | 151 | my $pvalue; | |||||||||||||||||||||||||||||||||||||||||
| 554 | 151 | ▶ | if ($max <= 0.0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | $pvalue = 1.0; | |||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||
| 557 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 558 | $pvalue = Statistics::Distributions::fprob($self->{FDISTR_N}, | ||||||||||||||||||||||||||||||||||||||||||
| 559 | $self->{FDISTR_M}, | ||||||||||||||||||||||||||||||||||||||||||
| 560 | 151 | $max); | |||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||
| 562 | 151 | my ($a, $b, $d) = split (/\:/, $param{$ec50}); | |||||||||||||||||||||||||||||||||||||||||
| 563 | 151 | ▶ | if ($d >= 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 564 | 11 | ▶ | if ($a != 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 565 | 10 | $fold = -($b/$a); | |||||||||||||||||||||||||||||||||||||||||
| 566 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 567 | 1 | $fold = -99999; | |||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||
| 569 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 570 | 140 | ▶ | if ($a != 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 571 | 140 | $fold = $b/$a; | |||||||||||||||||||||||||||||||||||||||||
| 572 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | $fold = 99999; | |||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||
| 576 | 151 | $self->{EC50DATA}->{$assay} = { MAX => $max, | |||||||||||||||||||||||||||||||||||||||||
| 577 | MIN => $min, | ||||||||||||||||||||||||||||||||||||||||||
| 578 | LOW => $low, | ||||||||||||||||||||||||||||||||||||||||||
| 579 | HIGH => $high, | ||||||||||||||||||||||||||||||||||||||||||
| 580 | EC50 => $ec50, | ||||||||||||||||||||||||||||||||||||||||||
| 581 | PVALUE => $pvalue, | ||||||||||||||||||||||||||||||||||||||||||
| 582 | EC50RANGE => $ec50range, | ||||||||||||||||||||||||||||||||||||||||||
| 583 | PEAK => $peak, | ||||||||||||||||||||||||||||||||||||||||||
| 584 | A => $a, | ||||||||||||||||||||||||||||||||||||||||||
| 585 | B => $b, | ||||||||||||||||||||||||||||||||||||||||||
| 586 | D => $d, | ||||||||||||||||||||||||||||||||||||||||||
| 587 | FOLD => $fold }; | ||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||
| 589 | 6 | $self->{STATE} = "calculated"; | |||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||
| 592 | =item C<scandata()> | ||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | Return the complete list of scan data used in the SDRS calculation. This is just an array of lines containing the values of the EC50 calculations. | ||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||
| 596 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||
| 598 | 6 | ▶ | sub scandata { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scandata: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 599 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 600 | 6 | return @{$self->{SCANDATA}}; | |||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | =item C<score_doses()> | ||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | Return the list of doses used in the SDRS calculation that can be | ||||||||||||||||||||||||||||||||||||||||||
| 606 | used as arguments for assays and pvalues. | ||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||
| 608 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | 5 | ▶ | sub score_doses { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
score_doses: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 611 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 612 | 5 | return keys %{$self->{FSCORES}}; | |||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | =item C<sorted_assays_by_dose([$dose])> | ||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||
| 617 | Return a list of assays for each dose in $dose sorted by F-score. | ||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||
| 621 | 6865 | ▶ | sub sorted_assays_by_dose { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sorted_assays_by_dose: called CC=4 SCAR=16.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 622 | 6865 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 623 | 6865 | my $dose = shift; | |||||||||||||||||||||||||||||||||||||||||
| 624 | 6865 | ▶ | if ($self->{STATE} ne 'calculated') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | $self->calculate; | |||||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||
| 628 | 6865 | ▶ | if (not defined $dose) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | return %{$self->{SORTED_DATA}}; | |||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||
| 631 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 632 | 6865 | ▶ | if (not exists($self->{SORTED_DATA}->{$dose})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | carp "Sorted assays by dose = $dose does not exist.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||
| 636 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 637 | 6865 | return @{$self->{SORTED_DATA}->{$dose}}; | |||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||
| 643 | =item C<pvalues_by_dose([$dose])> | ||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||
| 645 | Return a list of P values for the assays returned by sorted_assays_by_dose | ||||||||||||||||||||||||||||||||||||||||||
| 646 | for each dose in $dose sorted by F-score. | ||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||
| 648 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||
| 650 | 6865 | ▶ | sub pvalues_by_dose { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pvalues_by_dose: called CC=4 SCAR=16.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 651 | 6865 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 652 | 6865 | my $dose = shift; | |||||||||||||||||||||||||||||||||||||||||
| 653 | 6865 | ▶ | if ($self->{STATE} ne 'calculated') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | $self->calculate; | |||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||
| 657 | 6865 | ▶ | if (not defined $dose) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | return %{$self->{PVAL_DATA}}; | |||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||
| 660 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 661 | 6865 | ▶ | if (not exists($self->{PVAL_DATA}->{$dose})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | carp "P values by dose = $dose does not exist.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||
| 665 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 666 | 6865 | return @{$self->{PVAL_DATA}->{$dose}}; | |||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||
| 671 | =item C<ec50data([$assay[, $property[, $precision]]])> | ||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||
| 673 | Returns EC50 data for the calculation. If no arguments are specified, | ||||||||||||||||||||||||||||||||||||||||||
| 674 | then the internal hash for the EC50 calculation are returned. If just | ||||||||||||||||||||||||||||||||||||||||||
| 675 | an C<$assay> is specified, then the internal hash for all the EC50 | ||||||||||||||||||||||||||||||||||||||||||
| 676 | values associated with that C<$assay> is returned. If an C<$assay> and | ||||||||||||||||||||||||||||||||||||||||||
| 677 | C<$property> are specified, then the property for that assay is | ||||||||||||||||||||||||||||||||||||||||||
| 678 | returned. If the C<$precision> operand is specified, then it controls | ||||||||||||||||||||||||||||||||||||||||||
| 679 | how many digits of precision are returned for the value. | ||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||
| 681 | Here is the list of possible properties. | ||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||
| 683 | MAX Maximum F score | ||||||||||||||||||||||||||||||||||||||||||
| 684 | MIN Minimum F score. If this property is negative, then an error | ||||||||||||||||||||||||||||||||||||||||||
| 685 | was encountered in the calculation of F scores. This is likely due | ||||||||||||||||||||||||||||||||||||||||||
| 686 | insufficient range in the responses. | ||||||||||||||||||||||||||||||||||||||||||
| 687 | LOW Lower bound of 95% confidence interval for the estimated EC50. | ||||||||||||||||||||||||||||||||||||||||||
| 688 | HIGH Upper bound of 95% confidence interval for the estimated EC50. | ||||||||||||||||||||||||||||||||||||||||||
| 689 | EC50 Estimated EC50. | ||||||||||||||||||||||||||||||||||||||||||
| 690 | PVALUE P value of the best fitting model | ||||||||||||||||||||||||||||||||||||||||||
| 691 | EC50RANGE range of 95% confidence interval for the estimated EC50. | ||||||||||||||||||||||||||||||||||||||||||
| 692 | PEAK Number of peaks in the F scores at search doses across experimental dose range. | ||||||||||||||||||||||||||||||||||||||||||
| 693 | A Estimated value for A in the best model. | ||||||||||||||||||||||||||||||||||||||||||
| 694 | B Estimated value for B in the best model. | ||||||||||||||||||||||||||||||||||||||||||
| 695 | D Estimated value for D in the best model. | ||||||||||||||||||||||||||||||||||||||||||
| 696 | FOLD Ratio of B/A or 99999.0. If A == 0. Positive if D < 0, negative otherwise. | ||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||
| 698 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||
| 700 | 1812 | ▶ | sub ec50data { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ec50data: called CC=9 SCAR=25.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 701 | 1812 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 702 | 1812 | my $assay = shift; | |||||||||||||||||||||||||||||||||||||||||
| 703 | 1812 | my $property = shift; | |||||||||||||||||||||||||||||||||||||||||
| 704 | 1812 | my $precision = shift; | |||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||
| 706 | 1812 | ▶ | $precision = 6 if not defined $precision; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 707 | 1812 | ▶ | if ($self->{STATE} ne 'calculated') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | $self->calculate; | |||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||
| 710 | 1812 | ▶ | if (not defined $assay) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | return %{$self->{EC50DATA}}; | |||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||
| 713 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 714 | 1812 | ▶ | if (not exists($self->{EC50DATA}->{$assay})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | carp "EC50 data for $assay does not exist.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||
| 718 | 1812 | my $assaydata = $self->{EC50DATA}->{$assay}; | |||||||||||||||||||||||||||||||||||||||||
| 719 | 1812 | ▶ | if (not defined $property) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | return %{$self->{EC50DATA}->{$assay}}; | |||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||
| 722 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 723 | 1812 | ▶ | if (not exists($assaydata->{$property})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | carp "EC50 data for property $property for assay $assay does not exist.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||||||||||
| 727 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 728 | 1812 | my $ret = $assaydata->{$property}; | |||||||||||||||||||||||||||||||||||||||||
| 729 | 1812 | ▶ | if ($ret ne "" and $ret != int($ret)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ret ne "" and $ret != int $ret
MC/DC100%2/2
$ret ne "" and $ret != int $ret
$ret ne ""
$ret != int $ret
Truth table100%3/3
A and B
A= $ret ne ""B= $ret != int $ret
| |||||||||||||||||||||||||||||||||||||||||||
| 730 | 1394 | $ret = sprintf("%.${precision}g", $ret) + 0.0; | |||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||
| 732 | 1812 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||
| 738 | 14 | ▶ | sub _make_tmp { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_tmp: called CC=6 SCAR=23.5
| |||||||||||||||||||||||||||||||||||||||||||
| 739 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 740 | 14 | ▶ | if (-d $self->{TMPDIR} and -w $self->{TMPDIR}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-d $self->{"TMPDIR"} and -w $self->{"TMPDIR"}
MC/DC0%0/2
-d $self->{"TMPDIR"} and -w $self->{"TMPDIR"}
-d $self->{"TMPDIR"}
-w $self->{"TMPDIR"}
Truth table33%1/3
A and B
A= -d $self->{"TMPDIR"}B= -w $self->{"TMPDIR"}
| |||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||||
| 743 | 14 | ▶ | if (-d $self->{TMPDIR}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | croak "Unable to write " . $self->{TMPDIR} . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||
| 746 | 14 | ▶ | if (-w $self->{TMPDIR}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 747 | unlink($self->{TMPDIR}) || | ||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | ▶ | croak "Unable to delete " . $self->{TMPDIR} . "\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||
| 750 | &_system_with_check("mkdir -p " . $self->{TMPDIR}, | ||||||||||||||||||||||||||||||||||||||||||
| 751 | 14 | $self->{DEBUG}); | |||||||||||||||||||||||||||||||||||||||||
| 752 | 14 | $self->{TMP_CREATED} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||
| 755 | 111 | ▶ | sub _find_ec50_range { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_ec50_range: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||
| 756 | 111 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 757 | 111 | my ($scores, $ec50) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 758 | 111 | my @range = (); | |||||||||||||||||||||||||||||||||||||||||
| 759 | 111 | my $off_flag = 1; | |||||||||||||||||||||||||||||||||||||||||
| 760 | 111 | my $peak = 0; | |||||||||||||||||||||||||||||||||||||||||
| 761 | 111 | my $current; | |||||||||||||||||||||||||||||||||||||||||
| 762 | 111 | my $seen = 0; | |||||||||||||||||||||||||||||||||||||||||
| 763 | 111 | my $boundary; | |||||||||||||||||||||||||||||||||||||||||
| 764 | 111 | foreach my $dose (sort {$a<=>$b} keys %$scores) { | |||||||||||||||||||||||||||||||||||||||||
| 765 | 152403 | $current = $$scores{$dose}; | |||||||||||||||||||||||||||||||||||||||||
| 766 | 152403 | ▶ | $seen = 1 if ($dose == $ec50); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 767 | 152403 | ▶ | if ($current >= $self->{CUTOFF}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 768 | 99063 | push @range, $dose; | |||||||||||||||||||||||||||||||||||||||||
| 769 | 99063 | ▶ | $off_flag = 0 if ($off_flag == 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 770 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 771 | 53340 | ▶ | if ($seen == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 772 | 55 | $boundary = _find_boundary(\@range); | |||||||||||||||||||||||||||||||||||||||||
| 773 | 55 | $seen = 0; | |||||||||||||||||||||||||||||||||||||||||
| 774 | } | ||||||||||||||||||||||||||||||||||||||||||
| 775 | 53340 | @range = (); | |||||||||||||||||||||||||||||||||||||||||
| 776 | 53340 | ▶ | if ($off_flag == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 777 | 55 | $off_flag = 1; | |||||||||||||||||||||||||||||||||||||||||
| 778 | 55 | $peak++; | |||||||||||||||||||||||||||||||||||||||||
| 779 | } | ||||||||||||||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||
| 782 | 111 | ▶ | $boundary = _find_boundary(\@range) if ($seen == 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 783 | 111 | ▶ | $peak++ if ($current >= $self->{CUTOFF}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||
| 785 | 111 | return "$boundary-$peak"; | |||||||||||||||||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||
| 788 | 111 | ▶ | sub _find_boundary { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_boundary: called CC=2 SCAR=7.5
| |||||||||||||||||||||||||||||||||||||||||||
| 789 | 111 | my $range = shift; | |||||||||||||||||||||||||||||||||||||||||
| 790 | 111 | my ($high, $low); | |||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||
| 792 | 111 | ▶ | if (@$range >= 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 793 | 111 | $low = shift @$range; | |||||||||||||||||||||||||||||||||||||||||
| 794 | 111 | $high = pop @$range; | |||||||||||||||||||||||||||||||||||||||||
| 795 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | $low = shift @$range; | |||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | $high = $low; | |||||||||||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||||||||||
| 799 | 111 | return "$high-$low"; | |||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||
| 802 | 2746 | ▶ | sub _scan_dose_point { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_scan_dose_point: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 803 | 2746 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 804 | 2746 | my $dose = shift; | |||||||||||||||||||||||||||||||||||||||||
| 805 | 2746 | my $ecstring = ''; | |||||||||||||||||||||||||||||||||||||||||
| 806 | 2746 | my $m = $self->{FDISTR_M}; | |||||||||||||||||||||||||||||||||||||||||
| 807 | 2746 | my $n = $self->{FDISTR_N}; | |||||||||||||||||||||||||||||||||||||||||
| 808 | 2746 | foreach my $assay (keys %{$self->{VALUES}}) { | |||||||||||||||||||||||||||||||||||||||||
| 809 | 42563 | my ($al, $ah, $astep) = split (/\:/, $self->{ARANGE}->{$assay}); | |||||||||||||||||||||||||||||||||||||||||
| 810 | 42563 | my ($bl, $bh, $bstep) = split (/\:/, $self->{BRANGE}->{$assay}); | |||||||||||||||||||||||||||||||||||||||||
| 811 | my ($a, $b, $d, $best_sse) = _compute_best_sse($al, $ah, $astep, | ||||||||||||||||||||||||||||||||||||||||||
| 812 | $bl, $bh, $bstep, | ||||||||||||||||||||||||||||||||||||||||||
| 813 | $dose, | ||||||||||||||||||||||||||||||||||||||||||
| 814 | $self->{VALUES}->{$assay}, | ||||||||||||||||||||||||||||||||||||||||||
| 815 | 42563 | $self->{DOSES}); | |||||||||||||||||||||||||||||||||||||||||
| 816 | 42563 | ▶ | if ($best_sse == 0 or $n == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$best_sse == 0 or $n == 0
MC/DC0%0/2
$best_sse == 0 or $n == 0
$best_sse == 0
$n == 0
Truth table33%1/3
A or B
A= $best_sse == 0B= $n == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 817 | carp sprintf("best_sse($best_sse) = 0 or n($n) = 0 for $assay. arange = %s brange = %s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 818 | $self->{ARANGE}->{$assay}, | ||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | $self->{BRANGE}->{$assay}); | |||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | $ecstring .= "$assay\t" . | |||||||||||||||||||||||||||||||||||||||||
| 821 | sprintf("%.5f", $dose) . | ||||||||||||||||||||||||||||||||||||||||||
| 822 | "\t-1\t-1\t-1\t-1\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 823 | } | ||||||||||||||||||||||||||||||||||||||||||
| 824 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 825 | 42563 | my $f_score = ($self->{SST}->{$assay} - $best_sse) * $m / ($best_sse * $n); | |||||||||||||||||||||||||||||||||||||||||
| 826 | 42563 | $f_score = sprintf("%.3f", $f_score); | |||||||||||||||||||||||||||||||||||||||||
| 827 | 42563 | $a = sprintf("%.3f", $a); | |||||||||||||||||||||||||||||||||||||||||
| 828 | 42563 | $b = sprintf("%.3f", $b); | |||||||||||||||||||||||||||||||||||||||||
| 829 | 42563 | $d = sprintf("%.3f", $d); | |||||||||||||||||||||||||||||||||||||||||
| 830 | 42563 | $ecstring .= "$assay\t" . | |||||||||||||||||||||||||||||||||||||||||
| 831 | sprintf("%.5f", $dose) . | ||||||||||||||||||||||||||||||||||||||||||
| 832 | "\t$f_score\t$a\t$b\t$d\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 833 | } | ||||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||
| 835 | 2746 | return $ecstring; | |||||||||||||||||||||||||||||||||||||||||
| 836 | } | ||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||
| 838 | 275 | ▶ | sub _define_ab_boundary { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_define_ab_boundary: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 839 | 275 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 840 | 275 | my ($assay, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 841 | 275 | my @sorted = sort {$a<=>$b} @$data; | |||||||||||||||||||||||||||||||||||||||||
| 842 | 275 | my @sorted_copy = @sorted; | |||||||||||||||||||||||||||||||||||||||||
| 843 | 275 | my @brange = splice (@sorted, $#sorted-5, 6); | |||||||||||||||||||||||||||||||||||||||||
| 844 | 275 | $self->_find_step($assay, 'b', \@brange); | |||||||||||||||||||||||||||||||||||||||||
| 845 | 275 | my @arange = splice (@sorted_copy, 0, 6); | |||||||||||||||||||||||||||||||||||||||||
| 846 | 275 | $self->_find_step($assay, 'a', \@arange); | |||||||||||||||||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||
| 849 | 550 | ▶ | sub _find_step { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_step: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||
| 851 | 550 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 852 | 550 | my ($assay, $pam, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 853 | 550 | my $stdev = Math::NumberCruncher::StandardDeviation($data); | |||||||||||||||||||||||||||||||||||||||||
| 854 | 550 | my $mean = Math::NumberCruncher::Mean($data); | |||||||||||||||||||||||||||||||||||||||||
| 855 | 550 | my $cutoff = $mean / 10; | |||||||||||||||||||||||||||||||||||||||||
| 856 | 550 | ▶ | $stdev = $cutoff if ($stdev eq 'NaN' || $stdev < $cutoff); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$stdev eq "NaN" or $stdev < $cutoff
MC/DC100%2/2
$stdev eq "NaN" or $stdev < $cutoff
$stdev eq "NaN"
$stdev < $cutoff
Truth table100%3/3
A or B
A= $stdev eq "NaN"B= $stdev < $cutoff
| |||||||||||||||||||||||||||||||||||||||||||
| 857 | 550 | my ($l, $h, $step); | |||||||||||||||||||||||||||||||||||||||||
| 858 | 550 | $step = $stdev / 2.5; | |||||||||||||||||||||||||||||||||||||||||
| 859 | 550 | $step = sprintf("%.3f", $step); | |||||||||||||||||||||||||||||||||||||||||
| 860 | 550 | ▶ | if ($step == 0.0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 861 | 5 | carp "Data range too small for $assay -- step size raised to 0.001.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 862 | 5 | $step = "0.001"; | |||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||
| 864 | 550 | ▶ | if ($pam eq 'a') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 865 | 275 | $h = $mean + 2.3*$stdev; | |||||||||||||||||||||||||||||||||||||||||
| 866 | 275 | $l = $mean - 2*$stdev; | |||||||||||||||||||||||||||||||||||||||||
| 867 | 275 | ▶ | $l = $self->{MIN}->{$assay} if ($l <= 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 868 | 275 | $h = sprintf("%.3f", $h); | |||||||||||||||||||||||||||||||||||||||||
| 869 | 275 | $l = sprintf("%.3f", $l); | |||||||||||||||||||||||||||||||||||||||||
| 870 | 275 | $self->{ARANGE}->{$assay} = "$l:$h:$step"; | |||||||||||||||||||||||||||||||||||||||||
| 871 | } elsif ($pam eq 'b') { | ||||||||||||||||||||||||||||||||||||||||||
| 872 | 275 | $h = $mean + 2*$stdev; | |||||||||||||||||||||||||||||||||||||||||
| 873 | 275 | $l = $mean - 2.3*$stdev; | |||||||||||||||||||||||||||||||||||||||||
| 874 | 275 | ▶ | $l = $self->{MIN}->{$assay} if ($l <= 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 875 | 275 | $h = sprintf("%.3f", $h); | |||||||||||||||||||||||||||||||||||||||||
| 876 | 275 | $l = sprintf("%.3f", $l); | |||||||||||||||||||||||||||||||||||||||||
| 877 | 275 | $self->{BRANGE}->{$assay} = "$l:$h:$step"; | |||||||||||||||||||||||||||||||||||||||||
| 878 | } | ||||||||||||||||||||||||||||||||||||||||||
| 879 | } | ||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||
| 881 | 275 | ▶ | sub _compute_sst { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compute_sst: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 882 | 275 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 883 | 275 | my $sst = 0; | |||||||||||||||||||||||||||||||||||||||||
| 884 | 275 | my $mean = Math::NumberCruncher::Mean($data); | |||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||
| 886 | 275 | foreach my $data (@$data) { | |||||||||||||||||||||||||||||||||||||||||
| 887 | 3010 | $sst += ($data - $mean)**2; | |||||||||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||||||||||
| 889 | 275 | return $sst; | |||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||
| 892 | 20 | ▶ | sub _system_with_check { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_system_with_check: called CC=4 SCAR=16.6
| |||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||
| 894 | 20 | my $command = shift; | |||||||||||||||||||||||||||||||||||||||||
| 895 | 20 | my $echo = shift; | |||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||
| 897 | 20 | ▶ | if (defined $echo and $echo) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $echo and $echo
MC/DC0%0/2
defined $echo and $echo
defined $echo
$echo
Truth table33%1/3
A and B
A= defined $echoB= $echo
| |||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | &_dated_mesg($command); | |||||||||||||||||||||||||||||||||||||||||
| 899 | } | ||||||||||||||||||||||||||||||||||||||||||
| 900 | 20 | my $status = system("$command"); | |||||||||||||||||||||||||||||||||||||||||
| 901 | 20 | ▶ | if ($status != 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | croak "Shell command: $command returned $status error code.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||
| 904 | } | ||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | ▶ | sub _dated_mesg { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dated_mesg: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||
| 908 | # Print a dated message to STDERR | ||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | my $mesg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | my $date = &_date; | |||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | ▶ | if (substr($mesg, -1, 1) ne "\n") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | $mesg .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | print STDERR "At $date: $mesg"; | |||||||||||||||||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | ▶ | sub _date { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_date: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | return strftime("%a %b %d %T %Z %Y", localtime); | |||||||||||||||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||
| 922 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||
| 924 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||
| 926 | sdrs.pl | ||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||
| 928 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||
| 930 | Ruiru Ji <ruiruji@gmail.com> | ||||||||||||||||||||||||||||||||||||||||||
| 931 | Nathan O. Siemers <nathan.siemers@bms.com> | ||||||||||||||||||||||||||||||||||||||||||
| 932 | Lei Ming <lei.ming@bms.com> | ||||||||||||||||||||||||||||||||||||||||||
| 933 | Liang Schweizer <liang.schweizer@bms.com> | ||||||||||||||||||||||||||||||||||||||||||
| 934 | Robert Bruccoleri <bruc@acm.org> | ||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||
| 936 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||
| 939 | 9 | ▶ | use Inline C => <<'END_OF_C_CODE', NAME => 'Bio::SDRS::FastSSE'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||
| 941 | void extract_double_array(SV *arrayp, | ||||||||||||||||||||||||||||||||||||||||||
| 942 | double a[], | ||||||||||||||||||||||||||||||||||||||||||
| 943 | I32 asize, | ||||||||||||||||||||||||||||||||||||||||||
| 944 | I32 *limitp); | ||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||
| 946 | void _compute_best_sse(double al, | ||||||||||||||||||||||||||||||||||||||||||
| 947 | double ah, | ||||||||||||||||||||||||||||||||||||||||||
| 948 | double astep, | ||||||||||||||||||||||||||||||||||||||||||
| 949 | double bl, | ||||||||||||||||||||||||||||||||||||||||||
| 950 | double bh, | ||||||||||||||||||||||||||||||||||||||||||
| 951 | double bstep, | ||||||||||||||||||||||||||||||||||||||||||
| 952 | double dose, | ||||||||||||||||||||||||||||||||||||||||||
| 953 | SV* valuesp, | ||||||||||||||||||||||||||||||||||||||||||
| 954 | SV* dosesp) | ||||||||||||||||||||||||||||||||||||||||||
| 955 | { | ||||||||||||||||||||||||||||||||||||||||||
| 956 | double a, b, d, diff, sse, tmp, y_hat, d2; | ||||||||||||||||||||||||||||||||||||||||||
| 957 | double a_best, b_best, d_best, sse_best; | ||||||||||||||||||||||||||||||||||||||||||
| 958 | SV* param_ret; | ||||||||||||||||||||||||||||||||||||||||||
| 959 | SV* best_sse_ret; | ||||||||||||||||||||||||||||||||||||||||||
| 960 | I32 count = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 961 | I32 i; | ||||||||||||||||||||||||||||||||||||||||||
| 962 | I32 vlimit, dlimit; | ||||||||||||||||||||||||||||||||||||||||||
| 963 | #define DOSE_SIZE 100 | ||||||||||||||||||||||||||||||||||||||||||
| 964 | double doses[DOSE_SIZE]; | ||||||||||||||||||||||||||||||||||||||||||
| 965 | double values[DOSE_SIZE]; | ||||||||||||||||||||||||||||||||||||||||||
| 966 | Inline_Stack_Vars; | ||||||||||||||||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||||||||||||||||
| 968 | extract_double_array(valuesp, values, DOSE_SIZE, &vlimit); | ||||||||||||||||||||||||||||||||||||||||||
| 969 | extract_double_array(dosesp, doses, DOSE_SIZE, &dlimit); | ||||||||||||||||||||||||||||||||||||||||||
| 970 | if (vlimit != dlimit) { | ||||||||||||||||||||||||||||||||||||||||||
| 971 | fprintf(stderr, "Error in compute_best_sse: limit mismatch. vlimit = %d dlimit = %s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 972 | vlimit, dlimit); | ||||||||||||||||||||||||||||||||||||||||||
| 973 | exit(1); | ||||||||||||||||||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||
| 976 | for (a = al; a < ah; a += astep) { | ||||||||||||||||||||||||||||||||||||||||||
| 977 | // fprintf(stderr, "a = %14.10g\n", a); | ||||||||||||||||||||||||||||||||||||||||||
| 978 | for (b = bh; b > bl && a <= b; b -= bstep) { | ||||||||||||||||||||||||||||||||||||||||||
| 979 | // fprintf(stderr, "b = %14.10g\n", b); | ||||||||||||||||||||||||||||||||||||||||||
| 980 | diff = b - a; | ||||||||||||||||||||||||||||||||||||||||||
| 981 | for (d = -6; d < 6.3; d += 0.3) { | ||||||||||||||||||||||||||||||||||||||||||
| 982 | // fprintf(stderr, "d = %14.10g dlimit = %d\n", d, dlimit); | ||||||||||||||||||||||||||||||||||||||||||
| 983 | sse = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 984 | for (i = 0; i <= dlimit; i++) { | ||||||||||||||||||||||||||||||||||||||||||
| 985 | tmp = doses[i] / dose; | ||||||||||||||||||||||||||||||||||||||||||
| 986 | tmp = pow(tmp, d); | ||||||||||||||||||||||||||||||||||||||||||
| 987 | y_hat = a + diff / (1 + tmp); | ||||||||||||||||||||||||||||||||||||||||||
| 988 | d2 = (y_hat - values[i]); | ||||||||||||||||||||||||||||||||||||||||||
| 989 | sse += d2 * d2; | ||||||||||||||||||||||||||||||||||||||||||
| 990 | } | ||||||||||||||||||||||||||||||||||||||||||
| 991 | if (++count == 1 || sse < sse_best) { | ||||||||||||||||||||||||||||||||||||||||||
| 992 | a_best = a; | ||||||||||||||||||||||||||||||||||||||||||
| 993 | b_best = b; | ||||||||||||||||||||||||||||||||||||||||||
| 994 | d_best = d; | ||||||||||||||||||||||||||||||||||||||||||
| 995 | sse_best = sse; | ||||||||||||||||||||||||||||||||||||||||||
| 996 | } | ||||||||||||||||||||||||||||||||||||||||||
| 997 | } | ||||||||||||||||||||||||||||||||||||||||||
| 998 | } | ||||||||||||||||||||||||||||||||||||||||||
| 999 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1000 | Inline_Stack_Reset; | ||||||||||||||||||||||||||||||||||||||||||
| 1001 | Inline_Stack_Push(sv_2mortal(newSVnv(a_best))); | ||||||||||||||||||||||||||||||||||||||||||
| 1002 | Inline_Stack_Push(sv_2mortal(newSVnv(b_best))); | ||||||||||||||||||||||||||||||||||||||||||
| 1003 | Inline_Stack_Push(sv_2mortal(newSVnv(d_best))); | ||||||||||||||||||||||||||||||||||||||||||
| 1004 | Inline_Stack_Push(sv_2mortal(newSVnv(sse_best))); | ||||||||||||||||||||||||||||||||||||||||||
| 1005 | Inline_Stack_Done; | ||||||||||||||||||||||||||||||||||||||||||
| 1006 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||
| 1008 | void extract_double_array(SV *arrayp, | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | double a[], | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | I32 asize, | ||||||||||||||||||||||||||||||||||||||||||
| 1011 | I32 *limitp) | ||||||||||||||||||||||||||||||||||||||||||
| 1012 | /* | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | * Extract the elements of the Perl array, pointed to by arrayp, | ||||||||||||||||||||||||||||||||||||||||||
| 1014 | * into the C array a. The size of a is asize, and the code will check | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | * for overflow. The limiting subscript for arrayp will be returned in | ||||||||||||||||||||||||||||||||||||||||||
| 1016 | * *limitp. */ | ||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||
| 1018 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1019 | AV* array; | ||||||||||||||||||||||||||||||||||||||||||
| 1020 | I32 limit, i; | ||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||
| 1022 | array = SvRV(arrayp); | ||||||||||||||||||||||||||||||||||||||||||
| 1023 | limit = av_len(array); | ||||||||||||||||||||||||||||||||||||||||||
| 1024 | if (limit+1 > asize) { | ||||||||||||||||||||||||||||||||||||||||||
| 1025 | fprintf(stderr, | ||||||||||||||||||||||||||||||||||||||||||
| 1026 | "extract_double_array: Perl array is too big. limit = %d asize = %d\n", | ||||||||||||||||||||||||||||||||||||||||||
| 1027 | limit, asize); | ||||||||||||||||||||||||||||||||||||||||||
| 1028 | exit(1); | ||||||||||||||||||||||||||||||||||||||||||
| 1029 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1030 | for (i = 0; i <= limit; i++) { | ||||||||||||||||||||||||||||||||||||||||||
| 1031 | SV *element, **elementp; | ||||||||||||||||||||||||||||||||||||||||||
| 1032 | elementp = av_fetch(array, i, 0); | ||||||||||||||||||||||||||||||||||||||||||
| 1033 | element = *elementp; | ||||||||||||||||||||||||||||||||||||||||||
| 1034 | a[i] = SvNV(element); | ||||||||||||||||||||||||||||||||||||||||||
| 1035 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1036 | *limitp = limit; | ||||||||||||||||||||||||||||||||||||||||||
| 1037 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||
| 1039 | END_OF_C_CODE | ||||||||||||||||||||||||||||||||||||||||||