1 package CXGN
::Trial
::TrialDesign
;
5 CXGN::Trial::TrialDesign - a module to create a trial design using the R CRAN package Agricolae.
10 my $trial_design = CXGN::Trial::TrialDesign->new({schema => $schema} );
15 This module uses the the R CRAN package "Agricolae" to calculate experimental designs for field layouts.
19 Jeremy D. Edwards (jde22@cornell.edu)
20 Aimin Yan (ay247@cornell.edu)
24 use MooseX
::FollowPBP
;
25 use Moose
::Util
::TypeConstraints
;
28 use R
::YapRI
::Data
::Matrix
;
31 has
'trial_name' => (isa
=> 'Str', is
=> 'rw', predicate
=> 'has_trial_name', clearer
=> 'clear_trial_name');
32 has
'stock_list' => (isa
=> 'ArrayRef[Str]', is
=> 'rw', predicate
=> 'has_stock_list', clearer
=> 'clear_stock_list');
33 has
'control_list' => (isa
=> 'ArrayRef[Str]', is
=> 'rw', predicate
=> 'has_control_list', clearer
=> 'clear_control_list');
34 has
'control_list_crbd' => (isa
=> 'ArrayRef[Str]', is
=> 'rw', predicate
=> 'has_control_list_crbd', clearer
=> 'clear_control_list_crbd');
35 has
'number_of_blocks' => (isa
=> 'Int', is
=> 'rw', predicate
=> 'has_number_of_blocks', clearer
=> 'clear_number_of_blocks');
36 has
'block_row_numbers' => (isa
=> 'Int', is
=> 'rw', predicate
=> 'has_block_row_numbers', clearer
=> 'clear_block_row_numbers');
37 has
'block_col_numbers' => (isa
=> 'Int', is
=> 'rw', predicate
=> 'has_block_col_numbers', clearer
=> 'clear_block_col_numbers');
38 has
'number_of_rows' => (isa
=> 'Int',is
=> 'rw',predicate
=> 'has_number_of_rows',clearer
=> 'clear_number_of_rows');
39 has
'number_of_cols' => (isa
=> 'Int',is
=> 'rw',predicate
=> 'has_number_of_cols',clearer
=> 'clear_number_of_cols');
40 has
'number_of_reps' => (isa
=> 'Int', is
=> 'rw', predicate
=> 'has_number_of_reps', clearer
=> 'clear_number_of_reps');
41 has
'block_size' => (isa
=> 'Int', is
=> 'rw', predicate
=> 'has_block_size', clearer
=> 'clear_block_size');
42 has
'greenhouse_num_plants' => (isa
=> 'ArrayRef[Int]', is
=> 'rw', predicate
=> 'has_greenhouse_num_plants', clearer
=> 'clear_greenhouse_num_plants');
43 has
'maximum_block_size' => (isa
=> 'Int', is
=> 'rw', predicate
=> 'has_maximum_block_size', clearer
=> 'clear_maximum_block_size');
44 has
'plot_name_prefix' => (isa
=> 'Str', is
=> 'rw', predicate
=> 'has_plot_name_prefix', clearer
=> 'clear_plot_name_prefix');
45 has
'plot_name_suffix' => (isa
=> 'Str', is
=> 'rw', predicate
=> 'has_plot_name_suffix', clearer
=> 'clear_plot_name_suffix');
46 has
'plot_start_number' => (isa
=> 'Int', is
=> 'rw', predicate
=> 'has_plot_start_number', clearer
=> 'clear_plot_start_number', default => 1);
47 has
'plot_number_increment' => (isa
=> 'Int', is
=> 'rw', predicate
=> 'has_plot_number_increment', clearer
=> 'clear_plot_number_increment', default => 1);
48 has
'randomization_seed' => (isa
=> 'Int', is
=> 'rw', predicate
=> 'has_randomization_seed', clearer
=> 'clear_randomization_seed');
49 has
'blank' => ( isa
=> 'Str', is
=> 'rw', predicate
=> 'has_blank' );
51 subtype
'RandomizationMethodType',
53 where
{ $_ eq "Wichmann-Hill" || $_ eq "Marsaglia-Multicarry" || $_ eq "Super-Duper" || $_ eq "Mersenne-Twister" || $_ eq "Knuth-
54 TAOCP" || $_ eq "Knuth-TAOCP-2002"},
55 message
{ "The string, $_, was not a valid randomization method"};
57 has
'randomization_method' => (isa
=> 'RandomizationMethodType', is
=> 'rw', default=> "Mersenne-Twister");
61 where
{ $_ eq "CRD" || $_ eq "RCBD" || $_ eq "Alpha" || $_ eq "Augmented" || $_ eq "MAD" || $_ eq "genotyping_plate" || $_ eq "greenhouse" },
62 message
{ "The string, $_, was not a valid design type" };
64 has
'design_type' => (isa
=> 'DesignType', is
=> 'rw', predicate
=> 'has_design_type', clearer
=> 'clear_design_type');
72 sub calculate_design
{
74 if (!$self->has_design_type()) {
78 if ($self->get_design_type() eq "CRD") {
79 $design = _get_crd_design
($self);
81 elsif ($self->get_design_type() eq "RCBD") {
82 $design = _get_rcbd_design
($self);
84 elsif ($self->get_design_type() eq "Alpha") {
85 $design = _get_alpha_lattice_design
($self);
87 elsif ($self->get_design_type() eq "Augmented") {
88 $design = _get_augmented_design
($self);
89 # $design = _get_alpha_lattice_design($self);
92 # elsif ($self->get_design_type() eq "MADII") {
93 # $design = _get_madii_design($self);
96 elsif($self->get_design_type() eq "MAD") {
97 $design = _get_madiii_design
($self);
99 elsif ($self->get_design_type() eq "genotyping_plate") {
100 $design = $self->_get_genotyping_plate();
102 # elsif($self->get_design_type() eq "MADIV") {
103 # $design = _get_madiv_design($self);
105 elsif($self->get_design_type() eq "greenhouse") {
106 $design = _get_greenhouse_design
($self);
109 die "Trial design" . $self->get_design_type() ." not supported\n";
119 sub _get_genotyping_plate
{
123 my $number_of_stocks;
124 if ($self->has_stock_list()) {
125 @stock_list = @
{$self->get_stock_list()};
126 $number_of_stocks = scalar(@stock_list);
127 if ($number_of_stocks > 95) {
128 die "Need fewer than 96 stocks per plate (at least one blank!)";
132 die "No stock list specified\n";
136 if ($self->has_blank()) {
137 $blank = $self->get_blank();
138 print STDERR
"Using previously set blank $blank\n";
141 my $well_no = int(rand() * $number_of_stocks)+1;
142 my $well_row = chr(int(($well_no-1) / 12) + 65);
143 my $well_col = ($well_no -1) % 12 +1;
144 $blank = sprintf "%s%02d", $well_row, $well_col;
145 print STDERR
"Using randomly assigned blank $blank\n";
150 foreach my $row ("A".."H") {
151 foreach my $col (1..12) {
153 my $well= sprintf "%s%02d", $row, $col;
154 #my $well = $row.$col;
156 if ($well eq $blank) {
157 $gt_design{$well} = {
158 plot_name
=> $self->get_trial_name()."_".$well."_BLANK",
159 stock_name
=> "BLANK",
162 elsif (@stock_list) {
164 { plot_name
=> $self->get_trial_name()."_".$well,
165 stock_name
=> shift(@stock_list),
168 #print STDERR Dumper(\%gt_design);
175 sub _get_crd_design
{
178 #$self->set_number_of_blocks(1);
179 #%crd_design=%{_get_rcbd_design($self)};
180 my $rbase = R
::YapRI
::Base
->new();
182 my $number_of_blocks;
184 my $stock_data_matrix;
191 my @converted_plot_numbers;
192 my $number_of_stocks;
193 if ($self->has_stock_list()) {
194 @stock_list = @
{$self->get_stock_list()};
195 $number_of_stocks = scalar(@stock_list);
197 die "No stock list specified\n";
199 if ($self->has_number_of_reps()) {
200 $number_of_reps = $self->get_number_of_reps();
202 die "Number of reps not specified\n";
205 if (scalar(@stock_list)>1) {
207 $stock_data_matrix = R
::YapRI
::Data
::Matrix
->new({
208 name
=> 'stock_data_matrix',
210 coln
=> scalar(@stock_list),
211 data
=> \
@stock_list,
213 #print STDERR Dumper $stock_data_matrix;
215 $r_block = $rbase->create_block('r_block');
216 $stock_data_matrix->send_rbase($rbase, 'r_block');
218 $r_block->add_command('library(agricolae)');
219 $r_block->add_command('trt <- stock_data_matrix[1,]');
220 $r_block->add_command('rep_vector <- rep('.$number_of_reps.',each='.$number_of_stocks.')');
221 $r_block->add_command('randomization_method <- "'.$self->get_randomization_method().'"');
223 if ($self->has_randomization_seed()){
224 $r_block->add_command('randomization_seed <- '.$self->get_randomization_seed());
225 $r_block->add_command('crd<-design.crd(trt,rep_vector,serie=1,kinds=randomization_method, seed=randomization_seed)');
228 $r_block->add_command('crd<-design.crd(trt,rep_vector,serie=1,kinds=randomization_method)');
230 $r_block->add_command('crd<-crd$book'); #added for agricolae 1.1-8 changes in output
231 $r_block->add_command('crd<-as.matrix(crd)');
232 $r_block->run_block();
233 $result_matrix = R
::YapRI
::Data
::Matrix
->read_rbase( $rbase,'r_block','crd');
234 #print STDERR Dumper $result_matrix;
236 @plot_numbers = $result_matrix->get_column("plots");
237 #print STDERR Dumper \@plot_numbers;
239 @rep_numbers = $result_matrix->get_column("r");
240 @stock_names = $result_matrix->get_column("trt");
241 @converted_plot_numbers=@
{_convert_plot_numbers
($self,\
@plot_numbers)};
242 #print STDERR Dumper \@converted_plot_numbers;
244 } else { #only a single stock was given, so no randomization can occur.
245 @converted_plot_numbers = (1...$number_of_reps);
246 @rep_numbers = (1...$number_of_reps);
247 @stock_names = ($stock_list[0]) x
$number_of_reps;
250 for (my $i = 0; $i < scalar(@converted_plot_numbers); $i++) {
252 $plot_info{'stock_name'} = $stock_names[$i];
253 $plot_info{'block_number'} = 1;
254 $plot_info{'rep_number'} = $rep_numbers[$i];
255 $plot_info{'plot_name'} = $converted_plot_numbers[$i];
256 $crd_design{$converted_plot_numbers[$i]} = \
%plot_info;
259 #print STDERR Dumper \%crd_design;
261 %crd_design = %{_build_plot_names
($self,\
%crd_design)};
265 sub _get_rcbd_design
{
268 my $rbase = R
::YapRI
::Base
->new();
270 my $number_of_blocks;
271 my $stock_data_matrix;
276 my @control_names_crbd;
278 my @converted_plot_numbers;
279 my @control_list_crbd;
280 my %control_names_lookup;
283 if ($self->has_stock_list()) {
284 @stock_list = @
{$self->get_stock_list()};
286 die "No stock list specified\n";
288 if ($self->has_control_list_crbd()) {
289 @control_list_crbd = @
{$self->get_control_list_crbd()};
290 %control_names_lookup = map { $_ => 1 } @control_list_crbd;
291 foreach $stock_name_iter (@stock_names) {
292 if (exists($control_names_lookup{$stock_name_iter})) {
293 die "Names in stock list cannot be used also as controls\n";
297 if ($self->has_number_of_blocks()) {
298 $number_of_blocks = $self->get_number_of_blocks();
300 die "Number of blocks not specified\n";
303 $stock_data_matrix = R
::YapRI
::Data
::Matrix
->new(
305 name
=> 'stock_data_matrix',
307 coln
=> scalar(@stock_list),
308 data
=> \
@stock_list,
312 $r_block = $rbase->create_block('r_block');
313 $stock_data_matrix->send_rbase($rbase, 'r_block');
314 $r_block->add_command('library(agricolae)');
315 $r_block->add_command('trt <- stock_data_matrix[1,]');
316 $r_block->add_command('number_of_blocks <- '.$number_of_blocks);
317 $r_block->add_command('randomization_method <- "'.$self->get_randomization_method().'"');
318 if ($self->has_randomization_seed()){
319 $r_block->add_command('randomization_seed <- '.$self->get_randomization_seed());
320 $r_block->add_command('rcbd<-design.rcbd(trt,number_of_blocks,serie=1,kinds=randomization_method, seed=randomization_seed)');
323 $r_block->add_command('rcbd<-design.rcbd(trt,number_of_blocks,serie=1,kinds=randomization_method)');
325 $r_block->add_command('rcbd<-rcbd$book'); #added for agricolae 1.1-8 changes in output
326 $r_block->add_command('rcbd<-as.matrix(rcbd)');
327 $r_block->run_block();
328 $result_matrix = R
::YapRI
::Data
::Matrix
->read_rbase( $rbase,'r_block','rcbd');
329 @plot_numbers = $result_matrix->get_column("plots");
330 @block_numbers = $result_matrix->get_column("block");
331 @stock_names = $result_matrix->get_column("trt");
332 @converted_plot_numbers=@
{_convert_plot_numbers
($self,\
@plot_numbers)};
333 for (my $i = 0; $i < scalar(@converted_plot_numbers); $i++) {
335 $plot_info{'stock_name'} = $stock_names[$i];
336 $plot_info{'block_number'} = $block_numbers[$i];
337 $plot_info{'plot_name'} = $converted_plot_numbers[$i];
338 $plot_info{'rep_number'} = 1;
339 $plot_info{'is_a_control'} = exists($control_names_lookup{$stock_names[$i]});
340 $rcbd_design{$converted_plot_numbers[$i]} = \
%plot_info;
342 %rcbd_design = %{_build_plot_names
($self,\
%rcbd_design)};
343 return \
%rcbd_design;
346 sub _get_alpha_lattice_design
{
349 my $rbase = R
::YapRI
::Base
->new();
352 my $number_of_blocks;
354 my $stock_data_matrix;
361 my @converted_plot_numbers;
362 my @control_list_crbd;
363 my %control_names_lookup;
365 if ($self->has_stock_list()) {
366 @stock_list = @
{$self->get_stock_list()};
368 die "No stock list specified\n";
370 if ($self->has_control_list_crbd()) {
371 @control_list_crbd = @
{$self->get_control_list_crbd()};
372 %control_names_lookup = map { $_ => 1 } @control_list_crbd;
373 foreach $stock_name_iter (@stock_names) {
374 if (exists($control_names_lookup{$stock_name_iter})) {
375 die "Names in stock list cannot be used also as controls\n";
379 if ($self->has_block_size()) {
380 $block_size = $self->get_block_size();
381 print STDERR
"block size = $block_size\n";
382 if ($block_size < 3) {
383 die "Block size must be greater than 2 for alpha lattice design\n";
385 # print "stock_list: ".scalar(@stock_list)."block_size: $block_size\n";
386 if (scalar(@stock_list) % $block_size != 0) {
387 #die "Number of stocks (".scalar(@stock_list).") for alpha lattice design is not divisible by the block size ($block_size)\n";
390 my $dummy_var = scalar(@stock_list) % $block_size;
391 my $stocks_to_add = $block_size - $dummy_var;
392 # print "$stock_list\n";
393 foreach my $stock_list_rep(1..$stocks_to_add) {
394 push(@stock_list, $stock_list[0]);
396 $self->set_stock_list(\
@stock_list);
399 $number_of_blocks = scalar(@stock_list)/$block_size;
400 if ($number_of_blocks < $block_size) {
401 die "The number of blocks ($number_of_blocks) for alpha lattice design must not be less than the block size ($block_size)\n";
404 die "No block size specified\n";
406 if ($self->has_number_of_reps()) {
407 $number_of_reps = $self->get_number_of_reps();
408 if ($number_of_reps < 2) {
409 die "Number of reps for alpha lattice design must be 2 or greater\n";
412 die "Number of reps not specified\n";
414 $stock_data_matrix = R
::YapRI
::Data
::Matrix
->new(
416 name
=> 'stock_data_matrix',
418 coln
=> scalar(@stock_list),
419 data
=> \
@stock_list,
422 $r_block = $rbase->create_block('r_block');
423 $stock_data_matrix->send_rbase($rbase, 'r_block');
425 $r_block->add_command('library(agricolae)');
426 $r_block->add_command('trt <- stock_data_matrix[1,]');
427 $r_block->add_command('block_size <- '.$block_size);
428 $r_block->add_command('number_of_reps <- '.$number_of_reps);
429 $r_block->add_command('randomization_method <- "'.$self->get_randomization_method().'"');
430 if ($self->has_randomization_seed()){
431 $r_block->add_command('randomization_seed <- '.$self->get_randomization_seed());
432 $r_block->add_command('alpha<-design.alpha(trt,block_size,number_of_reps,serie=1,kinds=randomization_method, seed=randomization_seed)');
435 $r_block->add_command('alpha<-design.alpha(trt,block_size,number_of_reps,serie=1,kinds=randomization_method)');
437 $r_block->add_command('alpha_book<-alpha$book');
438 $r_block->add_command('alpha_book<-as.matrix(alpha_book)');
440 my @commands = $r_block->read_commands();
441 print STDERR
join "\n", @commands;
445 $r_block->run_block();
447 $result_matrix = R
::YapRI
::Data
::Matrix
->read_rbase( $rbase,'r_block','alpha_book');
448 @plot_numbers = $result_matrix->get_column("plots");
449 @block_numbers = $result_matrix->get_column("block");
450 @rep_numbers = $result_matrix->get_column("replication");
451 @stock_names = $result_matrix->get_column("trt");
452 @converted_plot_numbers=@
{_convert_plot_numbers
($self,\
@plot_numbers)};
453 for (my $i = 0; $i < scalar(@converted_plot_numbers); $i++) {
455 $plot_info{'stock_name'} = $stock_names[$i];
456 $plot_info{'block_number'} = $block_numbers[$i];
457 $plot_info{'plot_name'} = $converted_plot_numbers[$i];
458 $plot_info{'rep_number'} = $rep_numbers[$i];
459 $plot_info{'is_a_control'} = exists($control_names_lookup{$stock_names[$i]});
460 $alpha_design{$converted_plot_numbers[$i]} = \
%plot_info;
462 %alpha_design = %{_build_plot_names
($self,\
%alpha_design)};
463 return \
%alpha_design;
466 sub _get_augmented_design
{
468 my %augmented_design;
469 my $rbase = R
::YapRI
::Base
->new();
472 my $maximum_block_size;
473 my $number_of_blocks;
474 my $stock_data_matrix;
475 my $control_stock_data_matrix;
481 my @converted_plot_numbers;
482 my %control_names_lookup;
485 if ($self->has_stock_list()) {
486 @stock_list = @
{$self->get_stock_list()};
488 die "No stock list specified\n";
491 if ($self->has_control_list()) {
492 @control_list = @
{$self->get_control_list()};
493 %control_names_lookup = map { $_ => 1 } @control_list;
494 foreach $stock_name_iter (@stock_names) {
495 if (exists($control_names_lookup{$stock_name_iter})) {
496 die "Names in stock list cannot be used also as controls\n";
500 die "No list of control stocks specified. Required for augmented design.\n";
503 if ($self->has_maximum_block_size()) {
504 $maximum_block_size = $self->get_maximum_block_size();
505 if ($maximum_block_size <= scalar(@control_list)) {
506 die "Maximum block size must be greater the number of control stocks for augmented design\n";
508 if ($maximum_block_size >= scalar(@control_list)+scalar(@stock_list)) {
509 die "Maximum block size must be less than the number of stocks plus the number of controls for augmented design\n";
511 $number_of_blocks = ceil
(scalar(@stock_list)/($maximum_block_size-scalar(@control_list)));
513 die "No block size specified\n";
516 $stock_data_matrix = R
::YapRI
::Data
::Matrix
->new(
518 name
=> 'stock_data_matrix',
520 coln
=> scalar(@stock_list),
521 data
=> \
@stock_list,
525 $control_stock_data_matrix = R
::YapRI
::Data
::Matrix
->new(
527 name
=> 'control_stock_data_matrix',
529 coln
=> scalar(@control_list),
530 data
=> \
@control_list,
533 $r_block = $rbase->create_block('r_block');
534 $stock_data_matrix->send_rbase($rbase, 'r_block');
535 $control_stock_data_matrix->send_rbase($rbase, 'r_block');
536 $r_block->add_command('library(agricolae)');
537 $r_block->add_command('trt <- stock_data_matrix[1,]');
538 $r_block->add_command('control_trt <- control_stock_data_matrix[1,]');
539 $r_block->add_command('number_of_blocks <- '.$number_of_blocks);
540 $r_block->add_command('randomization_method <- "'.$self->get_randomization_method().'"');
541 if ($self->has_randomization_seed()){
542 $r_block->add_command('randomization_seed <- '.$self->get_randomization_seed());
543 $r_block->add_command('augmented<-design.dau(control_trt,trt,number_of_blocks,serie=1,kinds=randomization_method, seed=randomization_seed)');
546 $r_block->add_command('augmented<-design.dau(control_trt,trt,number_of_blocks,serie=1,kinds=randomization_method)');
548 $r_block->add_command('augmented<-augmented$book'); #added for agricolae 1.1-8 changes in output
549 $r_block->add_command('augmented<-as.matrix(augmented)');
551 $r_block->run_block();
552 $result_matrix = R
::YapRI
::Data
::Matrix
->read_rbase( $rbase,'r_block','augmented');
553 @plot_numbers = $result_matrix->get_column("plots");
554 @block_numbers = $result_matrix->get_column("block");
555 @stock_names = $result_matrix->get_column("trt");
556 @converted_plot_numbers=@
{_convert_plot_numbers
($self,\
@plot_numbers)};
558 for (my $i = 0; $i < scalar(@converted_plot_numbers); $i++) {
560 $plot_info{'stock_name'} = $stock_names[$i];
561 $plot_info{'block_number'} = $block_numbers[$i];
562 $plot_info{'plot_name'} = $converted_plot_numbers[$i];
563 $plot_info{'is_a_control'} = exists($control_names_lookup{$stock_names[$i]});
564 $augmented_design{$converted_plot_numbers[$i]} = \
%plot_info;
566 %augmented_design = %{_build_plot_names
($self,\
%augmented_design)};
567 return \
%augmented_design;
571 sub _get_madii_design
{
575 my $rbase = R
::YapRI
::Base
->new();
579 my $maximum_block_size;
580 my $number_of_blocks;
582 my $stock_data_matrix;
583 my $control_stock_data_matrix;
589 my @converted_plot_numbers;
590 my %control_names_lookup;
596 my $block_row_number;
597 my $block_col_number;
598 my @block_row_numbers;
599 my @block_col_numbers;
602 if ($self->has_stock_list()) {
603 @stock_list = @
{$self->get_stock_list()};
605 die "No stock list specified\n";
608 if ($self->has_control_list()) {
609 @control_list = @
{$self->get_control_list()};
610 %control_names_lookup = map { $_ => 1 } @control_list;
611 foreach $stock_name_iter (@stock_names) {
612 if (exists($control_names_lookup{$stock_name_iter})) {
613 die "Names in stock list cannot be used also as controls\n";
617 die "No list of control stocks specified. Required for augmented design.\n";
620 # if ($self->has_number_of_blocks()) {
621 # $number_of_blocks = $self->get_number_of_blocks();
623 # die "Number of blocks not specified\n";
626 if ($self->has_number_of_rows()) {
627 $number_of_rows = $self->get_number_of_rows();
629 die "Number of rows not specified\n";
632 #system("R --slave --args $tempfile $tempfile_out < R/MADII_layout_function.R");
633 # system("R --slave < R/MADII_layout_function.R");
636 # if ($self->has_maximum_row_number()) {
637 # $maximum_row_number = $self->get_maximum_row_number();
638 # if ($maximum_block_size <= scalar(@control_list)) {
639 # die "Maximum block size must be greater the number of control stocks for augmented design\n";
641 # if ($maximum_block_size >= scalar(@control_list)+scalar(@stock_list)) {
642 # die "Maximum block size must be less than the number of stocks plus the number of controls for augmented design\n";
644 # $number_of_blocks = ceil(scalar(@stock_list)/($maximum_block_size-scalar(@control_list)));
647 # die "No block size specified\n";
651 # if ($self->has_maximum_block_size()) {
652 # $maximum_block_size = $self->get_maximum_block_size();
653 # if ($maximum_block_size <= scalar(@control_list)) {
654 # die "Maximum block size must be greater the number of control stocks for augmented design\n";
656 # if ($maximum_block_size >= scalar(@control_list)+scalar(@stock_list)) {
657 # die "Maximum block size must be less than the number of stocks plus the number of controls for augmented design\n";
659 # $number_of_blocks = ceil(scalar(@stock_list)/($maximum_block_size-scalar(@control_list)));
661 # die "No block size specified\n";
666 print STDERR
join "\n", "@stock_list\n";
668 print STDERR
join "\n", "$number_of_rows\n";
670 $stock_data_matrix = R
::YapRI
::Data
::Matrix
->new(
672 name
=> 'stock_data_matrix',
674 coln
=> scalar(@stock_list),
675 data
=> \
@stock_list,
678 $control_stock_data_matrix = R
::YapRI
::Data
::Matrix
->new(
680 name
=> 'control_stock_data_matrix',
682 coln
=> scalar(@control_list),
683 data
=> \
@control_list,
688 $r_block = $rbase->create_block('r_block');
689 $stock_data_matrix->send_rbase($rbase, 'r_block');
690 $control_stock_data_matrix->send_rbase($rbase, 'r_block');
692 #$r_block->add_command('library(agricolae)');
694 $r_block->add_command('library(MAD)');
697 $r_block->add_command('trt <- as.array(stock_data_matrix[1,])');
698 $r_block->add_command('control_trt <- as.array(control_stock_data_matrix[1,])');
701 # $r_block->add_command('trt <- stock_data_matrix[1,]');
702 # $r_block->add_command('control_trt <- control_stock_data_matrix[1,]');
706 # $r_block->add_command('acc<-c(seq(1,330,1))');
707 # $r_block<-add_command('chk<-c(seq(1,4,1))');
709 # $r_block->add_command('trt <- acc');
710 # $r_block->add_command('control_trt <- chk');
711 # $r_block->add_command('number_of_blocks <- '.$number_of_blocks);
713 $r_block->add_command('number_of_rows <- '.$number_of_rows);
715 # $r_block->add_command('randomization_method <- "'.$self->get_randomization_method().'"');
717 # if ($self->has_randomization_seed()){
718 # $r_block->add_command('randomization_seed <- '.$self->get_randomization_seed());
719 # $r_block->add_command('augmented<-design.dau(control_trt,trt,number_of_blocks,serie=1,kinds=randomization_method, seed=randomization_seed)');
722 # $r_block->add_command('augmented<-design.dau(control_trt,trt,number_of_blocks,serie=1,kinds=randomization_method)');
725 #$r_block->add_command('test.ma<-design.dma(entries=c(seq(1,330,1)),chk.names=c(seq(1,4,1)),num.rows=9, num.cols=NULL, num.sec.chk=3)');
727 # $r_block->add_command('test.ma<-design.dma(entries=trt,chk.names=control_trt,num.rows=number_of_rows, num.cols=NULL, num.sec.chk=3)');
729 # $r_block->add_command('test.ma<-design.dma.0(entries=trt,chk.names=control_trt, nFieldRow=number_of_rows)');
731 $r_block->add_command('test.ma<-design.dma(entries=trt,chk.names=control_trt, nFieldRow=number_of_rows)');
733 # design.dma.0(entries=c(seq(1,300,1)),chk.names= c(seq(1,4,1)),nFieldRow=10)
735 # $r_block->add_command('augmented<-design.dau(control_trt,trt,number_of_blocks,serie=1,kinds=randomization_method)');
737 # $r_block->add_command('augmented<-augmented$book'); #added for agricolae 1.1-8 changes in output
739 $r_block->add_command('augmented<-test.ma[[2]]'); #added for agricolae 1.1-8 changes in output
740 # $r_block->add_command('print(augmented)');
741 $r_block->add_command('augmented<-as.matrix(augmented)');
742 # $r_block->add_command('augmented<-as.data.frame(augmented)');
744 # $r_block<-add_command('colnames(augmented)[2]<-"plots"');
745 # $r_block<-add_command('colnames(augmented)[3]<-"trt"');
746 # $r_block<-add_command('colnames(augmented)[7]<-"block"');
748 my @commands = $r_block->read_commands();
749 print STDERR
join "\n", @commands;
752 $r_block->run_block();
754 $result_matrix = R
::YapRI
::Data
::Matrix
->read_rbase( $rbase,'r_block','augmented');
756 @plot_numbers = $result_matrix->get_column("Plot");
757 @row_numbers = $result_matrix->get_column("Row");
758 @col_numbers = $result_matrix->get_column("Col");
759 @block_row_numbers=$result_matrix->get_column("Row.Blk");
760 @block_col_numbers=$result_matrix->get_column("Col.Blk");
761 @block_numbers = $result_matrix->get_column("Blk");
762 @stock_names = $result_matrix->get_column("Entry");
763 @check_names=$result_matrix->get_column("Check");
767 @converted_plot_numbers=@
{_convert_plot_numbers
($self,\
@plot_numbers)};
769 for (my $i = 0; $i < scalar(@converted_plot_numbers); $i++) {
772 $plot_info{'row_number'} =$row_numbers[$i];
773 $plot_info{'col_number'} =$col_numbers[$i];
774 $plot_info{'check_name'} =$check_names[$i];
775 $plot_info{'stock_name'} = $stock_names[$i];
776 $plot_info{'block_number'} = $block_numbers[$i];
777 $plot_info{'block_row_number'}=$block_row_numbers[$i];
778 $plot_info{'block_col_number'}=$block_col_numbers[$i];
779 $plot_info{'plot_name'} = $converted_plot_numbers[$i];
780 $plot_info{'is_a_control'} = exists($control_names_lookup{$stock_names[$i]});
781 $madii_design{$converted_plot_numbers[$i]} = \
%plot_info;
784 %madii_design = %{_build_plot_names
($self,\
%madii_design)};
786 # return \%augmented_design;
788 #call R code and create design data structure
790 return \
%madii_design;
796 sub _get_madiii_design
{
801 my $rbase = R
::YapRI
::Base
->new();
805 my $maximum_block_size;
806 my $number_of_blocks;
809 my $number_of_rows_per_block;
810 my $number_of_cols_per_block;
814 my $stock_data_matrix;
815 my $control_stock_data_matrix;
821 my @converted_plot_numbers;
822 my %control_names_lookup;
828 my @block_row_numbers;
829 my @block_col_numbers;
832 if ($self->has_stock_list()) {
833 @stock_list = @
{$self->get_stock_list()};
835 die "No stock list specified\n";
838 if ($self->has_control_list()) {
839 @control_list = @
{$self->get_control_list()};
840 %control_names_lookup = map { $_ => 1 } @control_list;
841 foreach $stock_name_iter (@stock_names) {
842 if (exists($control_names_lookup{$stock_name_iter})) {
843 die "Names in stock list cannot be used also as controls\n";
847 die "No list of control stocks specified. Required for augmented design.\n";
851 if ($self->has_number_of_rows()) {
852 $number_of_rows = $self->get_number_of_rows();
854 die "Number of rows not specified\n";
857 if ($self->has_block_row_numbers()) {
858 $number_of_rows_per_block = $self->get_block_row_numbers();
860 die "Number of block row not specified\n";
863 if ($self->has_block_col_numbers()) {
864 $number_of_cols_per_block = $self->get_block_col_numbers();
866 die "Number of block col not specified\n";
869 if ($self->has_number_of_cols()) {
870 $number_of_cols = $self->get_number_of_cols();
872 die "Number of blocks not specified\n";
875 #system("R --slave --args $tempfile $tempfile_out < R/MADII_layout_function.R");
876 # system("R --slave < R/MADII_layout_function.R");
879 # if ($self->has_maximum_row_number()) {
880 # $maximum_row_number = $self->get_maximum_row_number();
881 # if ($maximum_block_size <= scalar(@control_list)) {
882 # die "Maximum block size must be greater the number of control stocks for augmented design\n";
884 # if ($maximum_block_size >= scalar(@control_list)+scalar(@stock_list)) {
885 # die "Maximum block size must be less than the number of stocks plus the number of controls for augmented design\n";
887 # $number_of_blocks = ceil(scalar(@stock_list)/($maximum_block_size-scalar(@control_list)));
890 # die "No block size specified\n";
894 # if ($self->has_maximum_block_size()) {
895 # $maximum_block_size = $self->get_maximum_block_size();
896 # if ($maximum_block_size <= scalar(@control_list)) {
897 # die "Maximum block size must be greater the number of control stocks for augmented design\n";
899 # if ($maximum_block_size >= scalar(@control_list)+scalar(@stock_list)) {
900 # die "Maximum block size must be less than the number of stocks plus the number of controls for augmented design\n";
902 # $number_of_blocks = ceil(scalar(@stock_list)/($maximum_block_size-scalar(@control_list)));
904 # die "No block size specified\n";
909 print "@stock_list\n";
912 $stock_data_matrix = R
::YapRI
::Data
::Matrix
->new(
914 name
=> 'stock_data_matrix',
916 coln
=> scalar(@stock_list),
917 data
=> \
@stock_list,
920 $control_stock_data_matrix = R
::YapRI
::Data
::Matrix
->new(
922 name
=> 'control_stock_data_matrix',
924 coln
=> scalar(@control_list),
925 data
=> \
@control_list,
930 $r_block = $rbase->create_block('r_block');
931 $stock_data_matrix->send_rbase($rbase, 'r_block');
932 $control_stock_data_matrix->send_rbase($rbase, 'r_block');
934 #$r_block->add_command('library(agricolae)');
936 $r_block->add_command('library(MAD)');
938 $r_block->add_command('trt <- as.array(stock_data_matrix[1,])');
939 $r_block->add_command('control_trt <- as.array(control_stock_data_matrix[1,])');
941 # $r_block->add_command('acc<-c(seq(1,330,1))');
942 # $r_block<-add_command('chk<-c(seq(1,4,1))');
944 # $r_block->add_command('trt <- acc');
945 # $r_block->add_command('control_trt <- chk');
946 # $r_block->add_command('number_of_blocks <- '.$number_of_blocks);
948 # $r_block->add_command('randomization_method <- "'.$self->get_randomization_method().'"');
950 # if ($self->has_randomization_seed()){
951 # $r_block->add_command('randomization_seed <- '.$self->get_randomization_seed());
952 # $r_block->add_command('augmented<-design.dau(control_trt,trt,number_of_blocks,serie=1,kinds=randomization_method, seed=randomization_seed)');
955 # $r_block->add_command('augmented<-design.dau(control_trt,trt,number_of_blocks,serie=1,kinds=randomization_method)');
958 #$r_block->add_command('test.ma<-design.dma(entries=c(seq(1,330,1)),chk.names=c(seq(1,4,1)),num.rows=9, num.cols=NULL, num.sec.chk=3)');
960 $r_block->add_command('number_of_rows <- '.$number_of_rows);
961 $r_block->add_command('number_of_cols <- '.$number_of_cols);
962 $r_block->add_command('number_of_rows_per_block <- '.$number_of_rows_per_block);
963 $r_block->add_command('number_of_cols_per_block <- '.$number_of_cols_per_block);
965 $r_block->add_command('test.ma<-design.dma(entries=trt,chk.names=control_trt,nFieldRow=number_of_rows,nFieldCols=number_of_cols,nRowsPerBlk=number_of_rows_per_block, nColsPerBlk=number_of_cols_per_block)');
968 # $r_block->add_command('test.ma<-design.dma(entries=trt,chk.names=control_trt,num.rows=9, num.cols=NULL, num.sec.chk=3)');
970 #$r_block->add_command('test.ma<-design.dma(entries=trt,chk.names=control_trt,num.rows=9, num.cols=NULL, num.sec.chk=3)');
972 # $r_block->add_command('augmented<-design.dau(control_trt,trt,number_of_blocks,serie=1,kinds=randomization_method)');
974 # $r_block->add_command('augmented<-augmented$book'); #added for agricolae 1.1-8 changes in output
976 $r_block->add_command('augmented<-test.ma[[2]]'); #added for agricolae 1.1-8 changes in output
977 $r_block->add_command('augmented<-as.matrix(augmented)');
979 # $r_block<-add_command('colnames(augmented)[2]<-"plots"');
980 # $r_block<-add_command('colnames(augmented)[3]<-"trt"');
981 # $r_block<-add_command('colnames(augmented)[7]<-"block"');
984 my @commands = $r_block->read_commands();
985 print STDERR
join "\n", @commands;
989 $r_block->run_block();
991 $result_matrix = R
::YapRI
::Data
::Matrix
->read_rbase( $rbase,'r_block','augmented');
993 @plot_numbers = $result_matrix->get_column("Plot");
994 @row_numbers = $result_matrix->get_column("Row");
995 @col_numbers = $result_matrix->get_column("Col");
996 @block_row_numbers=$result_matrix->get_column("Row.Blk");
997 @block_col_numbers=$result_matrix->get_column("Col.Blk");
998 @block_numbers = $result_matrix->get_column("Blk");
999 @stock_names = $result_matrix->get_column("Entry");
1000 @check_names=$result_matrix->get_column("Check");
1007 @converted_plot_numbers=@
{_convert_plot_numbers
($self,\
@plot_numbers)};
1009 for (my $i = 0; $i < scalar(@converted_plot_numbers); $i++) {
1012 $plot_info{'row_number'} =$row_numbers[$i];
1013 $plot_info{'col_number'} =$col_numbers[$i];
1014 $plot_info{'check_name'} =$check_names[$i];
1015 $plot_info{'stock_name'} = $stock_names[$i];
1016 $plot_info{'block_number'} = $block_numbers[$i];
1017 $plot_info{'block_row_number'}=$block_row_numbers[$i];
1018 $plot_info{'block_col_number'}=$block_col_numbers[$i];
1019 $plot_info{'plot_name'} = $converted_plot_numbers[$i];
1020 $plot_info{'is_a_control'} = exists($control_names_lookup{$stock_names[$i]});
1021 $madiii_design{$converted_plot_numbers[$i]} = \
%plot_info;
1024 %madiii_design = %{_build_plot_names
($self,\
%madiii_design)};
1026 # return \%augmented_design;
1028 #call R code and create design data structure
1030 return \
%madiii_design;
1036 sub _get_madiv_design
{
1041 my $rbase = R
::YapRI
::Base
->new();
1045 my $maximum_block_size;
1046 my $number_of_blocks;
1049 my $number_of_rows_per_block;
1050 my $number_of_cols_per_block;
1054 my $stock_data_matrix;
1055 my $control_stock_data_matrix;
1061 my @converted_plot_numbers;
1062 my %control_names_lookup;
1063 my $stock_name_iter;
1068 my @block_row_numbers;
1069 my @block_col_numbers;
1072 if ($self->has_stock_list()) {
1073 @stock_list = @
{$self->get_stock_list()};
1075 die "No stock list specified\n";
1078 if ($self->has_control_list()) {
1079 @control_list = @
{$self->get_control_list()};
1080 %control_names_lookup = map { $_ => 1 } @control_list;
1081 foreach $stock_name_iter (@stock_names) {
1082 if (exists($control_names_lookup{$stock_name_iter})) {
1083 die "Names in stock list cannot be used also as controls\n";
1087 die "No list of control stocks specified. Required for augmented design.\n";
1091 if ($self->has_number_of_rows()) {
1092 $number_of_rows = $self->get_number_of_rows();
1094 die "Number of rows not specified\n";
1097 if ($self->has_block_row_numbers()) {
1098 $number_of_rows_per_block = $self->get_block_row_numbers();
1100 die "Number of block row not specified\n";
1103 # if ($self->has_block_col_numbers()) {
1104 # $number_of_cols_per_block = $self->get_block_col_numbers();
1106 # die "Number of block col not specified\n";
1109 # if ($self->has_number_of_cols()) {
1110 # $number_of_cols = $self->get_number_of_cols();
1112 # die "Number of blocks not specified\n";
1115 #system("R --slave --args $tempfile $tempfile_out < R/MADII_layout_function.R");
1116 # system("R --slave < R/MADII_layout_function.R");
1119 # if ($self->has_maximum_row_number()) {
1120 # $maximum_row_number = $self->get_maximum_row_number();
1121 # if ($maximum_block_size <= scalar(@control_list)) {
1122 # die "Maximum block size must be greater the number of control stocks for augmented design\n";
1124 # if ($maximum_block_size >= scalar(@control_list)+scalar(@stock_list)) {
1125 # die "Maximum block size must be less than the number of stocks plus the number of controls for augmented design\n";
1127 # $number_of_blocks = ceil(scalar(@stock_list)/($maximum_block_size-scalar(@control_list)));
1130 # die "No block size specified\n";
1134 # if ($self->has_maximum_block_size()) {
1135 # $maximum_block_size = $self->get_maximum_block_size();
1136 # if ($maximum_block_size <= scalar(@control_list)) {
1137 # die "Maximum block size must be greater the number of control stocks for augmented design\n";
1139 # if ($maximum_block_size >= scalar(@control_list)+scalar(@stock_list)) {
1140 # die "Maximum block size must be less than the number of stocks plus the number of controls for augmented design\n";
1142 # $number_of_blocks = ceil(scalar(@stock_list)/($maximum_block_size-scalar(@control_list)));
1144 # die "No block size specified\n";
1149 print "@stock_list\n";
1152 $stock_data_matrix = R
::YapRI
::Data
::Matrix
->new(
1154 name
=> 'stock_data_matrix',
1156 coln
=> scalar(@stock_list),
1157 data
=> \
@stock_list,
1160 $control_stock_data_matrix = R
::YapRI
::Data
::Matrix
->new(
1162 name
=> 'control_stock_data_matrix',
1164 coln
=> scalar(@control_list),
1165 data
=> \
@control_list,
1170 $r_block = $rbase->create_block('r_block');
1171 $stock_data_matrix->send_rbase($rbase, 'r_block');
1172 $control_stock_data_matrix->send_rbase($rbase, 'r_block');
1174 #$r_block->add_command('library(agricolae)');
1176 $r_block->add_command('library(MAD)');
1178 $r_block->add_command('trt <- as.array(stock_data_matrix[1,])');
1179 $r_block->add_command('control_trt <- as.array(control_stock_data_matrix[1,])');
1181 # $r_block->add_command('acc<-c(seq(1,330,1))');
1182 # $r_block<-add_command('chk<-c(seq(1,4,1))');
1184 # $r_block->add_command('trt <- acc');
1185 # $r_block->add_command('control_trt <- chk');
1186 # $r_block->add_command('number_of_blocks <- '.$number_of_blocks);
1188 # $r_block->add_command('randomization_method <- "'.$self->get_randomization_method().'"');
1190 # if ($self->has_randomization_seed()){
1191 # $r_block->add_command('randomization_seed <- '.$self->get_randomization_seed());
1192 # $r_block->add_command('augmented<-design.dau(control_trt,trt,number_of_blocks,serie=1,kinds=randomization_method, seed=randomization_seed)');
1195 # $r_block->add_command('augmented<-design.dau(control_trt,trt,number_of_blocks,serie=1,kinds=randomization_method)');
1198 #$r_block->add_command('test.ma<-design.dma(entries=c(seq(1,330,1)),chk.names=c(seq(1,4,1)),num.rows=9, num.cols=NULL, num.sec.chk=3)');
1200 $r_block->add_command('number_of_rows <- '.$number_of_rows);
1201 # $r_block->add_command('number_of_cols <- '.$number_of_cols);
1202 $r_block->add_command('number_of_rows_per_block <- '.$number_of_rows_per_block);
1203 # $r_block->add_command('number_of_cols_per_block <- '.$number_of_cols_per_block);
1205 #$r_block->add_command('test.ma<-design.dma(entries=trt,chk.names=control_trt,nFieldRow=number_of_rows,nFieldCols=number_of_cols,nRowsPerBlk=number_of_rows_per_block, nColsPerBlk=number_of_cols_per_block)');
1207 $r_block->add_command('test.ma<-design.dma(entries=trt,chk.names=control_trt,nFieldRow=number_of_rows,nRowsPerBlk=number_of_rows_per_block)');
1208 # $r_block->add_command('test.ma<-design.dma(entries=trt,chk.names=control_trt,num.rows=9, num.cols=NULL, num.sec.chk=3)');
1210 #$r_block->add_command('test.ma<-design.dma(entries=trt,chk.names=control_trt,num.rows=9, num.cols=NULL, num.sec.chk=3)');
1212 # $r_block->add_command('augmented<-design.dau(control_trt,trt,number_of_blocks,serie=1,kinds=randomization_method)');
1214 # $r_block->add_command('augmented<-augmented$book'); #added for agricolae 1.1-8 changes in output
1216 $r_block->add_command('augmented<-test.ma[[2]]'); #added for agricolae 1.1-8 changes in output
1217 $r_block->add_command('augmented<-as.matrix(augmented)');
1219 # $r_block<-add_command('colnames(augmented)[2]<-"plots"');
1220 # $r_block<-add_command('colnames(augmented)[3]<-"trt"');
1221 # $r_block<-add_command('colnames(augmented)[7]<-"block"');
1224 my @commands = $r_block->read_commands();
1225 print STDERR
join "\n", @commands;
1229 $r_block->run_block();
1231 $result_matrix = R
::YapRI
::Data
::Matrix
->read_rbase( $rbase,'r_block','augmented');
1233 @plot_numbers = $result_matrix->get_column("Plot");
1234 @row_numbers = $result_matrix->get_column("Row");
1235 @col_numbers = $result_matrix->get_column("Col");
1236 @block_row_numbers=$result_matrix->get_column("Row.Blk");
1237 @block_col_numbers=$result_matrix->get_column("Col.Blk");
1238 @block_numbers = $result_matrix->get_column("Blk");
1239 @stock_names = $result_matrix->get_column("Entry");
1240 @check_names=$result_matrix->get_column("Check");
1247 @converted_plot_numbers=@
{_convert_plot_numbers
($self,\
@plot_numbers)};
1249 for (my $i = 0; $i < scalar(@converted_plot_numbers); $i++) {
1252 $plot_info{'row_number'} =$row_numbers[$i];
1253 $plot_info{'col_number'} =$col_numbers[$i];
1254 $plot_info{'check_name'} =$check_names[$i];
1255 $plot_info{'stock_name'} = $stock_names[$i];
1256 $plot_info{'block_number'} = $block_numbers[$i];
1257 $plot_info{'block_row_number'}=$block_row_numbers[$i];
1258 $plot_info{'block_col_number'}=$block_col_numbers[$i];
1259 $plot_info{'plot_name'} = $converted_plot_numbers[$i];
1260 $plot_info{'is_a_control'} = exists($control_names_lookup{$stock_names[$i]});
1261 $madiv_design{$converted_plot_numbers[$i]} = \
%plot_info;
1264 %madiv_design = %{_build_plot_names
($self,\
%madiv_design)};
1266 # return \%augmented_design;
1268 #call R code and create design data structure
1270 return \
%madiv_design;
1276 sub _convert_plot_numbers
{
1278 my $plot_numbers_ref = shift;
1279 my @plot_numbers = @
{$plot_numbers_ref};
1280 for (my $i = 0; $i < scalar(@plot_numbers); $i++) {
1282 my $first_plot_number;
1283 if ($self->has_plot_start_number()){
1284 $first_plot_number = $self->get_plot_start_number();
1286 $first_plot_number = 1;
1288 if ($self->has_plot_number_increment()){
1289 $plot_number = $first_plot_number + ($i * $self->get_plot_number_increment());
1292 $plot_number = $first_plot_number + $i;
1294 $plot_numbers[$i] = $plot_number;
1296 return \
@plot_numbers;
1299 sub _build_plot_names
{
1301 my $design_ref = shift;
1302 my %design = %{$design_ref};
1305 my $trial_name = $self->get_trial_name;
1306 if ($self->has_plot_name_prefix()) {
1307 $prefix = $self->get_plot_name_prefix();
1309 if ($self->has_plot_name_suffix()) {
1310 $suffix = $self->get_plot_name_suffix();
1312 foreach my $key (keys %design) {
1314 $design{$key}->{plot_name
} = $trial_name.$prefix.$key.$suffix;
1315 $design{$key}->{plot_number
} = $key;
1320 sub _get_greenhouse_design
{
1322 my %greenhouse_design;
1323 my @num_plants = @
{ $self->get_greenhouse_num_plants() };
1324 my @accession_list = @
{ $self->get_stock_list() };
1325 my $trial_name = $self->get_trial_name;
1326 my %num_accession_hash;
1327 @num_accession_hash{@accession_list} = @num_plants;
1329 my @plot_numbers = (1..scalar(@accession_list));
1330 for (my $i = 0; $i < scalar(@plot_numbers); $i++) {
1332 $plot_info{'stock_name'} = $accession_list[$i];
1333 $plot_info{'block_number'} = 1;
1334 $plot_info{'rep_number'} = 1;
1335 $plot_info{'plot_name'} = $plot_numbers[$i];
1336 $greenhouse_design{$plot_numbers[$i]} = \
%plot_info;
1338 %greenhouse_design = %{_build_plot_names
($self,\
%greenhouse_design)};
1340 foreach my $plot_num (keys %greenhouse_design) {
1342 my $plot_name = $greenhouse_design{$plot_num}->{'plot_name'};
1343 my $stock_name = $greenhouse_design{$plot_num}->{'stock_name'};
1344 for my $n (1..$num_accession_hash{$stock_name}) {
1345 my $plant_name = $plot_name."_plant_$n";
1346 push @plant_names, $plant_name;
1348 $greenhouse_design{$plot_num}->{'plant_names'} = \
@plant_names;
1351 #print STDERR Dumper \%greenhouse_design;
1352 return \
%greenhouse_design;