ALBD - a perl implementation of Literature Based Discovery
use ALBD; %options = (); $options{'lbdConfig'} = 'configFile' my $lbd = LiteratureBasedDiscovery->new(\%options); $lbd->performLBD();
This package consists of Perl modules along with supporting Perl programs that perform Literature Based Discovery (LBD). The core data from which LBD is performed are co-occurrences matrices generated from UMLS::Association. ALBD is based on the ABC co-occurrence model. Many options can be specified, and many ranking methods are available. The novel ranking methods that use association measure are available as well as frequency based ranking methods. See samples/lbd for more info. Can perform open and closed LBD as well as time slicing evaluation.
To install the module, run the following magic commands:
perl Makefile.PL make make test make install
This will install the module in the standard location. You will, most probably, require root privileges to install in standard system directories. To install in a non-standard directory, specify a prefix during the 'perl Makefile.PL' stage as:
perl Makefile.PL PREFIX=/home/sid
It is possible to modify other parameters during installation. The details of these can be found in the ExtUtils::MakeMaker documentation. However, it is highly recommended not messing around with other parameters, unless you know what you're doing.
There are many parameters that can be specified, both for open and close discovery as well as time slicing evaluation. Please see the samples folder for info and sample configuration files.
#Get inputs my $startCuisRef = $self->_getStartCuis(); my $linkingAcceptTypesRef = $self->_getAcceptTypes('linking'); my $targetAcceptTypesRef = $self->_getAcceptTypes('target'); print "startCuis = ".(join(',', @{$startCuisRef}))."\n"; print "linkingAcceptTypes = ".(join(',', keys %{$linkingAcceptTypesRef}))."\n"; print "targetAcceptTypes = ".(join(',', keys %{$targetAcceptTypesRef}))."\n";
#Score Implicit Connections $start = time(); my $scoresRef; $scoresRef = Rank::scoreImplicit_fromImplicitMatrix($startCuisRef, $lbdOptions{'implicitInputFile'}, $lbdOptions{rankingMeasue}, $umls_association); print "Scored in: ".(time()-$start)."\n";
#Rank Implicit Connections $start = time(); my $ranksRef = Rank::rankDescending($scoresRef); print "Ranked in: ".(time()-$start)."\n";
#Output The Results open OUT, ">$lbdOptions{implicitOutputFile}" or die "unable to open implicit ouput file: " ."$lbdOptions{implicitOutputFile}\n"; my $outputString = $self->_rankedTermsToString($scoresRef, $ranksRef); my $paramsString = $self->_parametersToString(); print OUT $paramsString; print OUT $outputString; close OUT;
#Done print "DONE!\n\n"; }
print "Starting CUIs = ".(join(',', @{$startingCuisRef}))."\n";
#Get the Explicit Matrix my ($explicitMatrixRef, $cuiToIndexRef, $indexToCuiRef, $matrixSize) = Discovery::tableToSparseMatrix('N_11', $cuiFinder); print "Explicit Matrix:\n"; _printMatrix($explicitMatrixRef, $matrixSize, $indexToCuiRef); print "-----------------------\n";
#Get the Starting Matrix my $startingMatrixRef = Discovery::getRows($startingCuisRef, $explicitMatrixRef); print "Starting Matrix:\n"; _printMatrix($startingMatrixRef, $matrixSize, $indexToCuiRef); print "-----------------------\n";
#Get Implicit Connections my $implicitMatrixRef = Discovery::findImplicit($explicitMatrixRef, $startingMatrixRef, $indexToCuiRef, $matrixSize); print "Implicit Matrix:\n"; _printMatrix($implicitMatrixRef, $matrixSize, $indexToCuiRef); print "-----------------------\n";
#Remove Known Connections $implicitMatrixRef = Discovery::removeExplicit($explicitMatrixRef, $implicitMatrixRef); print "Implicit Matrix with Explicit Removed\n"; _printMatrix($implicitMatrixRef, $matrixSize, $indexToCuiRef); print "-----------------------\n"; print "\n\n";
#Test N11, N1P, etc... #NOTE...always do n11 first, if n11 = -1, no need to compute the others...there is no co-occurrence between them my $n11 = Rank::getN11('C0','C2',$explicitMatrixRef); my $npp = Rank::getNPP($explicitMatrixRef); my $n1p = Rank::getN1P('C0', $explicitMatrixRef); my $np1 = Rank::getNP1('C2', $explicitMatrixRef); print "Contingency Table Values from Explicit Matrix\n"; print "n11 = $n11\n"; print "npp = $npp\n"; print "n1p = $n1p\n"; print "np1 = $np1\n";
#Test other rank methods my $scoresRef = Rank::scoreImplicit_fromAllPairs($startingMatrixRef, $explicitMatrixRef, $implicitMatrixRef, $lbdOptions{rankingMethod}, $umls_association); my $ranksRef = Rank::rankDescending($scoresRef); print "Scores: \n"; foreach my $cui (keys %{$scoresRef}) { print " scores{$cui} = ${$scoresRef}{$cui}\n"; } print "Ranks = ".join(',', @{$ranksRef})."\n"; }
sub _printMatrix { my $matrixRef = shift; my $matrixSize = shift; my $indexToCuiRef = shift;
for (my $i = 0; $i < $matrixSize; $i++) { my $index1 = ${$indexToCuiRef}{$i}; for (my $j = 0; $j < $matrixSize; $j++) { my $printed = 0; my $index2 = ${$indexToCuiRef}{$j}; my $hash1Ref = ${$matrixRef}{$index1}; if (defined $hash1Ref) { my $val = ${$hash1Ref}{$index2}; if (defined $val) { print $val."\t"; $printed = 1; } } if (!$printed) { print "0\t"; } } print "\n"; } }
2 POD Errors
The following errors were encountered while parsing the POD:
Unknown directive: =comment
To install ALBD, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ALBD
CPAN shell
perl -MCPAN -e shell install ALBD
For more information on module installation, please visit the detailed CPAN module installation guide.