Login | Register

Info | Home

BioPHP - Discriminatory Power

Original code submitted by joseba
Code bellow is covered by GNU GPL v2 license.


Last change: 2010/10/18 21:09 | Recent Changes | Original description
Computes discriminatory poweras described by Hunter.


Last change: 2010/10/18 21:09 | Recent Changes | Download | Original code and
<title>Discriminatory power Calculator</title>
<body bgcolor=FFFFFF>
<h1>Discriminatory Power Calculator</h1>
        <table width=600><tr><td>
        The <a href="<? print $_SERVER["PHP_SELF"]; ?>?show=formula">Discriminatory Power (D)</a>
        is the average probability that the typing system will assign a different type to <b>two
        unrelated strains randomly sampled</b> in the microbial population of a given taxon.
        <p>This tool has been created to help calculate this parameter, and source code is
        available at <a href=http://www.biophp.org/stats/discriminatory_power/>biophp.org</a>

// author    Joseba Bikandi
// license   GNU GPL v2
// biophp.org


// if formula is requested, show it
if ($_GET["show"]=="formula"){print_formula();die;}

if (!$_POST){
        // when nothing is posted, an example is shown
        // example is included within the form
        // example is explained
        // when data is posted, discriminatory power is computed
        // get the data
        $values=preg_replace("/ /","",$values);   // just in case there are spaces

        // parse data to an array

        // compute discriminatory power

        // print results


//######## compute discriminatory power
// input must be an array
function discriminatory_power($data_array) {
        $N=0;  // number of strains
        foreach($data_array as $key => $val){

        return $result;

//######## is integral
function str_is_int($str) {
        return ("$str"=="$var");
//########print form
function print_form($values,$N,$S,$result){
        <table width=600>
        <tr><td align=center bgcolor=DDDDFF>
                <form action="<? print $_SERVER["PHP_SELF"]; ?>" method=post>
                  Add number of samples assigned to each type separated by comma: <p>
                  <input type=text name=values value="<? print $values; ?>" size=60><p>
                  <input type=submit value="Calculate Discrimination Power">
                  <tr><td><b>Number of unrelated strains</b>:</td><td align=right><? print $N; ?></td></tr>
                  <tr><td><b>Number of types</b>:</td><td align=right><? print $S; ?></td></tr>
                  <tr><td><b>Discriminatory power</b>:</td><td align=right><? print $result; ?></td></tr>


//########print example
function print_example(){
        <table width=600>
                <b>Example</b>: a novel typing system was used to type 100 randomly sampled <i>E. coli</i> strains.
                Four types were obtained, and to each type the following number of strains was assigned:
                <p style="margin-left: 40px;">Type A: 40 strains
                <br>Type B: 30 strains
                <br>Type C: 20 strains
                <br>Type D: 10 strains</p>
                <p>With this data, discriminatory power was calculated and its value was 0.7071

// #################### print example
function print_formula(){
        <table width=600>
                <p>Hunter P. Reproducibility and indices of discriminatory power of microbial typing methods. J Clin Microbiol  1990; 28: 1903-5.
                <a href=http://www.pubmedcentral.gov/articlerender.fcgi?tool=pmcentrez&artid=268075>PubMed</a>.
                <p>A Discriminatory Power (D) value of 1.0 would indicate that a
                typing method was able to distinguish each member of a
                strain population from all other members of that population.
                Conversely, an index of 0.0 would indicate that all members
                of a strain population were of an identical type. An index of
                0.50 would mean that if one strain was chosen at random
                from a strain population, then there would be a 50% probability
                that the next strain chosen at random would be
                indistinguishable from the first.
                <div align=right><a href="<? print $_SERVER["PHP_SELF"]; ?>">Start using this tool</a></div>