Package: powerball
PowerballA Tool for Competitive Lottery Analysis of Bacterial Groupsby Matthew Marshall and John DarcyWhat is Competitive Lottery Analysis?Competitive Lottery Analysis is examining the competitiveness and "lottery-ness" of a number of groups in a specific kind of environment. A competitive lottery environment is one where many species are competing for dominance of a small number of sites or patches. Species in these environments will either dominate a site, forcing all other species out, or will coexist with other species on that patch. Here we define competitiveness as the degree to which a group is consistently dominated by a small number of species within that group, and lottery-ness, which we define as the extent to which the same species will always dominate within a particular group of species. Competitive lottery analysis allows us to explore those metrics by analyzing population data to see which groups of species, are competitive, how competitive they are relative to other species, and how deterministically they dominate their groups.What is Powerball?Powerball is a Python 3 command-line tool that can be used to perform competitive lottery analysis of user-defined groups of species using Monte Carlo Simulation. It was developed for a research project as part of the Colorado Biomedical Informatics Summer Training Fellowship at the University of Colorado Anschutz Medical Campus. The use-cases for PowerBall are varied, and clinically relevant. For example, users can find which bacteria are competing with potential pathogens, and the extent to which that competition regularly occurs. Both the competitiveness and lottery-ness results of this analysis could inform patient outcome predictions as well as potential treatment plans. This knowledge provides valuable medical insight and may help inform the discovery of novel or probiotic treatments and inform treatment decisions for known pathogens. Additionally, PowerBall can be used in an ecological research framework using many different samples to better examine how competitiveness and/or lottery-ness change across environments, across patients, or across time.InstallationYou can install Powerball through the Python Package Index (PyPI) by runningpip install powerballUsagePowerball takes one mandatory argument: the name of an input csv file where each row represents a species and each column represents a sample of population data about that species. The final column of the table is a string used for grouping species based on some user-defined grouping parameter. For example, you could decide that all species that are taxonomically similar belong in the same group. An example of what an input file should look like is given by the table below and in data/example.csv:SpeciesSample ASample BSample CSample DSample EGroupsSpecies 13010301010Group 1Species 21520251115Group 1Species 320515180Group 1Species 45010135Group 2Species 510501420Group 2Species 6153001020Group 2Species 7101020534Group 3Species 85101700Group 3Species 951732520Group 3Powerball has a minimum group size of 3 (each group must have at least 3 rows). Any groups below that minimum will be ignored. A warning will be displayed if any groups are ignored, and the names of the groups will be shown. This minimum group size can be changed through the command line argument-gsor--groupSizeby specifying a number after it.Basic usage for Powerball ispython powerball.py filename.csvThis is run from the root directory of the project and filename.csv can be renamed to anything as long as it ends in .csvThis will show the competitiveness score, lottery score, and p-values for all groups, all rounded to 4 decimal places. See the image below for an example:This data is also saved to an output csv file (default name is Output.csv)For more advanced usage, Powerball has many different command line arguments. A full list can be shown by running `python powerball.py --help` or `python powerball.py -h`Powerball automatically generates an interactive graph of the output data using Bokeh (this can be silenced using the --chartStyle argument with a value greater than 3)How Does it Work?The input data specified in the csv file is used to generate a list ofShannon Diversityscores for each group. Shannon Diversity 	diversity is a statistical measure of the diversity of a community given by the formula:where piis the proportion of individuals belonging to the ith species in the group and R is the richness or number of species within a group.The diversity scores for a group are then compared against a null distribution of scores generated throughPermutational Monte Carlo simulation.The scores within the null distribution are diversity scores for a random group of the same size created by permuting all rows (including species not within the group of interest) of the input matrix.This process is repeated until a sufficiently large distribution is generated for each group (number of simulations is controlled by the--nullSizeargument, with a default value of 1000)Observing diversity scores which are higher than expected by the null hypothesis would imply relatively even population distribution between the species of a group. This would also imply that more competition exists within that group. We define competitiveness as theStandardized Effect Sizeof the group, given by the formula:where Î¼1is the mean for our empirical Shannon Diversity data, Î¼2is the mean for the null distribution, and Ïƒ is the standard deviation based on the null distribution.Lottery scores, which represent how deterministically a species dominates its group, are also generated through Permutational Monte Carlo simulation, with two key differences:Instead of generating diversity scores by permuting the rows of the input matrix, we permute the columns within each group.Diversity scores are taken from row sums instead of the entire row.Competitiveness scores and lottery scores both have1-tailed P-values, calculated permutationally as the proportion of values in the null distribution more extreme than the observed value.