Genome...athScan(3pm)

๐ŸŽ€ NAME ๐ŸŽ€

PathScan โ€” the Path-Scan significance test for mutations in groups of putative cancer genes. That's the whole name section, bestie, we keep it snappy ๐Ÿ’…

This is PathScan(3pm) from the User Contributed Perl Documentation, and she is here to do exactly one iconic thing.


โœจ SYNOPSIS โœจ

okay so here's the vibe upfront:

use PathScan;

my $pmobj = PathScan->new ($list_of_gene_lengths);
my $pval = $pmobj->path_scan ($actual_hits, $background_mutation_rate);

๐Ÿงฌ DESCRIPTION ๐Ÿงฌ

So here's the tea. This package calculates the so-called path-scan statistic P-value for sets of putative cancer genes, under the null hypothesis that the somatic mutations found in your data are the result of a random process characterized by the background mutation rate.

You run this test on, like, a biologically-relevant group of genes โ€” say all the genes in a particular pathway โ€” for which you've got somatic mutation data. A low p-value would imply that the null hypothesis should be rejected. In other words, the result suggests that the mutation configuration in this pathway is probably not the result of a strictly random process. periodt. ๐Ÿ’…

๐Ÿ” Nature of the Path-Scan Test

This statistic considers individual genes in a "binary" fashion, i.e. a gene is either mutated (has one or more mutations) or it is not mutated. The number of mutations in a mutated gene is not considered. That's literally the "path-scan" aspect of the test.

Why is such information discarded, you ask? Because the somatic background mutation rate is typically very small compared to the size of the average gene. Consequently, the expected number of mutations in any given gene is very low โ€” much less than one, in fact. Under the null hypothesis, most genes will have no mutations. Genes with one (or just a few) mutations may be interesting ๐Ÿ‘€, but when many genes in a biologically-relevant group (say a pathway) have one (or just a few) mutations, that could be a sign of some underlying non-random process.

In other words, this test is useful in cases where many genes in a group might each contribute a small component (i.e. a small fitness advantage) in the context of the disease process. What this test is not concerned with (and will not detect) is the case where a single, specific gene has a non-random association and it reflects this fact via a large number of mutations. Other single-gene tests should presumably flag such cases. The path-scan test should, therefore, be thought of as just one tool within a larger statistical "toolbox". No cap. ๐Ÿงฐ

๐Ÿ“Œ Assumptions in the Test

The main assumption is that a single background mutation rate applies to the set of genes of interest. That is, the rate does not vary among genes, among chromosomes (if more than one hosts genes of interest), etc. One rate, one vibe. ๐Ÿฆ‹


๐Ÿ’€ BUGS AND OPPORTUNITIES FOR EXTENSION ๐Ÿ’€

Coefficients are recalculated for every individual test, but it would be good for these to persist between tests, adding more as necessary (i.e. if a subsequent test involves more genes than the current one). Not me wishing for caching ๐Ÿ˜ญ


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Michael C. Wendl

mwendl@wustl.edu

Copyright (C) 2007, 2008 Washington University

and now the legal bit, bestie โ€” we do not touch this one, we simply respect it ๐Ÿซถ

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


๐Ÿงš METHODS ๐Ÿงš

The available methods are as follows. Grab a snack, there's a few. ๐Ÿ“

๐Ÿผ new

This is the usual object constructor, and it optionally takes all the gene-length data as input.

If you want to use the exact probability solution or the asymptotic approximate solution, pass all lengths in a single list reference:

my $pmobj = PathScan->new ([3434, 54565, 6445, ...]);

but if you want to use the convolution approximation method, divide the list of gene sizes into the desired number of bins and pass each of these as a reference:

my $pmobj = PathScan->new ([3434, 54565], [6445, ...]);

In other words, the way you pass these arguments at least partially determines the context in which you will obtain your P-value for this set of genes. The latter choice is typically better, as it gives good accuracy and good computational efficiency. Conversely, the exact solution is identically correct, but can be difficult to compute. The asymptotic approximation is always computationally efficient, but not necessarily accurate for small test sets.

๐Ÿ“ˆ path_scan

This function calculates the path-scan statistic in one of the appropriate contexts (exact or convolution approximation, as described above). It takes the actual number of "hits" you've observed in the data, i.e. the number of genes that have a mutated status.

my $pval = $pmobj->path_scan (7);

If you have not yet done the pre-processing with respect to the background mutation rate (see below), then pre-processing can be executed implicitly by passing the rate as the second argument.

my $pval = $pmobj->path_scan (7, 0.000001);

โœ‚๏ธ cdf_truncated

This function returns the cumulative distribution in the context of the convolution approximation, truncated such that it contains only enough information to process the given number of hits.

my $pvals_list = $pmobj->cdf_truncated ($hits);

The list is ordered from most extreme to least extreme probability tail values, i.e. the last value in the list is always unity. However, tailed p-values more extreme than that associated with the argument are not, in fact, calculated โ€” they're replaced with the flag -1. This saves processing time and also reduces the chances of numerical overflow for large pathways, as the full CDF must ultimately raise an "mval" (>1) to a power equal to the number of genes in the pathway.

โš ๏ธ The method assumes you have already done the pre-processing with respect to the background mutation rate.

๐Ÿ—‚๏ธ cdf

This function returns the cumulative distribution in one of the appropriate contexts (exact or convolution approximation, as described above). There are no arguments,

my $pvals_list = $pmobj->cdf;

unless you have not yet done the pre-processing with respect to the background mutation rate (see below), in which case the pre-processing can be executed implicitly by passing the rate as the sole argument.

my $pvals_list = $pmobj->cdf (0.000001);

The list is ordered from most extreme to least extreme probability tail values, i.e. the last value in the list is always unity.

๐ŸŒŒ cdf_asymptot

This function returns the cumulative distribution based on asymptotic analysis. There are no arguments, i.e.

my $pvals_list = $pmobj->cdf_asymptot;

unless you have not yet done the pre-processing with respect to the background mutation rate (see below), in which case the pre-processing can be executed implicitly by passing the rate as the sole argument.

my $pvals_list = $pmobj->cdf_asymptot (0.000001);

The list is ordered from most extreme to least extreme probability tail values, i.e. the last value in the list is always unity.

Note that asymptotic analysis gives a function (the Poisson) having infinite support. The infinite tail probability for all values past the most extreme physical case are all bundled into that most extreme p-value. ๐Ÿซง

๐ŸŒ  path_scan_asymptot

This function calculates the path-scan statistic in the asymptotic (Poisson) context. It takes the actual number of "hits" you've observed in the data, i.e. the number of genes that have a mutated status.

my $pval = $pmobj->path_scan_asymptot (7);

If you have not yet done the pre-processing with respect to the background mutation rate (see below), then pre-processing can be executed implicitly by passing the rate as the second argument.

my $pval = $pmobj->path_scan_asymptot (7, 0.000001);

You must set up the object, somewhat paradoxically, as if you will be doing the calculation in the exact context. (This is a consequence of how data are stored internally within the object.) ๐Ÿ™ˆ

๐Ÿงฐ additional methods

The basic functionality of this package is encompassed in the methods described above. However, some lower-level functions can also sometimes be useful. iykyk โœจ

๐Ÿ”ฌ p_value_exact

This function returns the exact value of the probability mass for a specific number of hits.

$pval_exact = $pmobj->p_value_exact (7);
โš ๏ธ You must make sure to call this only if you've configured the object in the exact context (see above).

๐Ÿ”ฌ p_value_binomial_approx

This function returns the convolution approximated value (i.e. using the binomial binning approximation) of the probability mass for a specific number of hits.

$pval_exact = $pmobj->p_value_binomial_approx (7);
โš ๏ธ You must make sure to call this only if you've configured the object in the approximate binomial context (see above). Also, you must explicitly calculate the necessary binomial coefficients beforehand (see "binom_coeffs").

๐Ÿ”ฌ p_value_asymptot_approx

This function returns the asymptotic approximated value (i.e. using the Poisson limit approximation) of the probability mass for a specific number of hits.

$pval_exact = $pmobj->p_value_asymptot_approx (7);

Somewhat paradoxically, you must make sure to call this only if you've configured the object in the exact context (see above).

๐Ÿงฌ store_genes

Stores the raw gene length data. Use this if you did not pass these data to "new" before you call any calculation methods. Works in the same way as "new", described above. Specifically, the context is partially determined by whether you pass a single list (exact context or asymptotic approximation)

$pmobj->store_genes ([3434, 54565, 6445, ...]);

or more than one list (convolution approximate context)

$pmobj->store_genes ([3434, 54565], [6445, ...]);

๐Ÿงฎ binom_coeffs

Calculates the binomial coefficients needed in the binomial (convolution) approximate solution.

$pmobj->binom_coeffs;

The internal data structure is essentially the symmetric half of the appropriately-sized Pascal triangle. Considerable memory is saved by not storing the full triangle. Queen of efficiency ๐Ÿ’…

โš™๏ธ preprocess

Calculates the Bernoulli kernel probabilities for the individual genes or gene bins

$pmobj_binom->preprocess ($background_mutation_rate);

The data structure can be re-configured to run the test with different background mutation rates by just re-calling this routine with a different value

$pmobj_binom->preprocess ($new_background_mutation_rate);

โœจ EXAMPLES โœจ

okay bestie, here are some examples that are literally here to help you use this package. In every single case, just assume we already ran the required preliminary code first, mmkay? ๐Ÿ’…

               #__USE THE PACKAGE
                  use PathScan;

               #__SOME DATA FOR AN "EXACT CONTEXT" CALCULATION
                  my $genes_exact = [
                     4000, 4000, 4000, 4000, 4000,
                     15000, 15000, 15000, 15000, 15000,
                     35000, 35000, 35000, 35000, 35000
                  ];

               #__SOME DATA FOR AN "APPROXIMATE CONTEXT" CALCULATION
                  my @genes_binned = (
                     [4000, 4000, 4000, 4000, 4000],
                     [15000, 15000, 15000, 15000, 15000],
                     [35000, 35000, 35000, 35000, 35000]
                  );

๐Ÿงช simple path-scan test

Here we're comparing the values returned by both the exact and approximate algorithms over the whole domain of possible hits, for a case where the answers should be identical. It's giving sanity check energy. โœจ

               #__SET BACKGROUND MUTATION RATE
                  my $rho = 0.00002;

               #__CONFIGURE OBJECTS IN "EXACT" AND "APPROXIMATE" CONTEXTS
                  my $pmobj_exact = PathScan->new ($genes_exact);
                  $pmobj_exact->preprocess ($rho);

                  my $pmobj_binom = PathScan->new (@genes_binned);
                  $pmobj_binom->preprocess ($rho);

               #__CALCULATE AND TALLY THE MAXIMUM DIFFERENCE
                  my $maxdiff = 0;
                  for (my $i = 0; $i <= scalar @{$genes_exact}; $i++) {
                     my $pm_pval_exact = $pmobj_exact->path_scan($i);
                     my $pm_pval_binom = $pmobj_binom->path_scan($i);
                     my $diff = abs ($pm_pval_exact - $pm_pval_binom);
                     $maxdiff = $diff if $diff > $maxdiff;
                     print "$i hits: $pm_pval_exact   $pm_pval_binom   $diff\n";
                  }
                  print "MAXIMUM DIFFERENCE IS $maxdiff\n";

๐ŸŽš๏ธ testing at different background rates

This example shows how to run the test for a fixed number of hits, say 7 in this case, for various different background mutation rates. We're basically speedrunning $rho values. ๐Ÿƒโ€โ™€๏ธ๐Ÿ’จ

               #__CONFIGURE OBJECT
                  my $pmobj_binom = PathScan->new (@genes_binned);

               #__CALCULATE
                  for (my $rho = 0.00001; $rho <= 0.0001; $rho += 0.00001) {
                     my $pm_pval_binom = $pmobj_binom->path_scan(7, $rho);
                     print "7 hits at background $rho : P = $pm_pval_binom\n";
                  }

Note that we did not run preprocess explicitly, but rather let the path_scan method call it implicitly for each new value of the background mutation rate.

ngl, that's lowkey the whole trick here. No cap. ๐Ÿ’…

๐Ÿงฎ computing asymptotic approximate solution

The asymptotic (Poisson) approximate probabiltiy value is straightforward to compute. No drama, just math. ๐Ÿ”ฅ

               #__SET BACKGROUND MUTATION RATE
                  my $rho = 0.00002;

               #__CONFIGURE OBJECT
                  my $pmobj_poisson = PathScan->new ($genes_exact);
                  $pmobj_poisson->preprocess ($rho);

               #__P-VALUE FOR 7 OBSERVED MUTATED GENES
                  my $pm_pval_poisson = $pmobj_exact->path_scan_asymptot (7);

๐Ÿฌ accessing individual probability masses

The probability masses for specific numbers of hits can also be calculated. Cute, right? Let's get those individual masses. ๐Ÿ’–

               #__SET BACKGROUND MUTATION RATE
                  my $rho = 0.00002;

               #__CONFIGURE OBJECT
                  my $pmobj_exact = PathScan->new ($genes_exact);
                  $pmobj_exact->preprocess ($rho);

               #__CALCULATE MASSES
                  my $total_prob = 0;
                  for (my $i = 0; $i <= scalar @{$genes_exact}; $i++) {
                     my $pval_exact = $pmobj_exact->p_value_exact ($i);
                     $total_prob += $pval_exact;
                     print "$i hits : probability mass =  $pval_exact\n";
                  }
                  print "total probability = $total_prob\n";

mwah ๐Ÿ’‹ this whole page is from perl v5.30.3, dated 2020-11-06, and it's Genome...athScan(3pm). bye bestie, go scan some paths! ๐ŸŒธ