forked from solgenomics/yapri
-
Notifications
You must be signed in to change notification settings - Fork 0
aubombarely/yapri
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
YapRI, is "Yet another perl R interface" developed initially to work with different blocks of commands. It run the commands esentially as: R [options] --file=inputcommandfile > outputresultfile So the YapRI::Base module, create files, put them in a temp dir by default, open these files, write the R commands to them, execute the files and store all of them as variables in this object. Here a synopsis of how works: use YapRI::Base; ## WORKING WITH THE DEFAULT MODE: my $rih = YapRI::Base->new(); $rih->add_command('bmp(filename="myfile.bmp", width=600, height=800)'); $rih->add_command('dev.list()'); $rih->add_command('plot(c(1, 5, 10), type = "l")'); $rih->add_command('dev.off()'); $rih->run_command(); my $result_file = $rih->get_resultfiles('default'); ## WORKING WITH COMMAND BLOCKS: my $rih = YapRI::Base->new(); ## Create a file-block_1 $rih->add_cmdfile('BLOCK1'); $rih->add_command('x <- c(10, 9, 8, 5)', 'BLOCK1'); $rih->add_command('z <- c(12, 8, 8, 4)', 'BLOCK1'); $rih->add_command('x + z', 'BLOCK1') ## Create a file-block_2 $rih->add_cmdfile('BLOCK2'); $rih->add_command('bmp(filename="myfile.bmp", width=600, height=800)', 'BLOCK2'); $rih->add_command('dev.list()', 'BLOCK2'); $rih->add_command('plot(c(1, 5, 10), type = "l")', 'BLOCK2'); ## Run each block $rih->run_command({ alias => 'BLOCK1' }); $rih->run_command({ alias => 'BLOCK2' }); ## Get the results my $resultfile1 = $rih->get_resultfiles('BLOCK1'); my $resultfile2 = $rih->get_resultfiles('BLOCK2'); Example of a module that uses YapRI::Base, and YapRI::Data::Matrix to calculate the transpose of the matrix my $matrix = YapRI::Data::Matrix( { name => 'matrix1', rown => 3, coln => 4, ` rownames => ['A', 'B', 'C'], colnames => ['alpha', 'beta', 'gamma', 'delta'], data => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], }); my $rih2 = YapRI::Base->new(); $matrix->send_rbase($rih2); $rih2->create_block('TRMATRIX', $matrix->get_name()); $rih2->add_command('trmatrix1 <- t('.$matrix->get_name().')', 'TRMATRIX'); $rih2->run_block('TRMATRIX'); my $trmatrix = YapRI::Data::Matrix->read_rbase($rih2, 'TRMATRIX', 'trmatrix1');
About
Yet Another Perl R Inteface.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- Perl 100.0%