Code Monkey home page Code Monkey logo

vigipy's Introduction

vigipy

vigipy is a project to bring modern disproportionality analyses and pharmacovigilance techniques into the Python ecosystem with a simple, intuitive interface. Many of the disproportionality functions are adapted and extended versions from Ismail Ahmed and Antoine Poncet's amazing work. Top-level functions:

  • bcpnn() - Bayesian confidence propogation neural network
  • gps() - Multi-item gamma poisson shrinker
  • prr() - Proportional reporting ratio
  • ror() - Reporting odds ratio
  • rfet() - Reporting fisher's exact test
  • LongitudinalModel() - Apply any model across time to view signal evolution
  • convert() - Convert a table of AEs, product and counts into a format for analysis

Getting Started

Dependencies

For vigipy

  • pandas
  • numpy
  • scipy
  • sympy
  • statsmodels
  • patsy

Installation

To install, navigate to the root directory of the repository and from the command line/terminal run:

python setup.py bdist_wheel
pip install dist\vigipy-1.0.0-py3-none-any.whl

You should now be able to import the vigipy library in your code.

Unit Tests

From the root directory of the repository, run:

python -m unittest discover -s test -p "*Test.py"

Usage

Load data and apply model

from vigipy import *
import pandas as pd

#This is expected to have columns: ['AE', 'name', 'count'] ('date' is optional for longitudinal models)
df = pd.read_csv('AE_count_data.csv')
vivipy_data = convert(df)

#My personal favorite model to run. With 'log2' or 'quantile' as the statistic.
results = gps(vigipy_data, min_events=5, decision_metric='rank',
              decision_thres=1, ranking_statistic='log2')
results.signals.to_excel('possible_signals.xlsx', index=False)

Making any model longitudinal:

from vigipy import *
import pandas as pd

df = pd.read_csv('AE_count_data.csv')
#Apply model to each calendar year, cumulative
LM = LongitudinalModel(df, 'A')
LM.run(gps, False, decision_metric='rank', ranking_statistic='quantile')

#Change model time slice to quarterly
LM.regroup_dates('Q')
LM.run(gps, False, decision_metric='rank', ranking_statistic='quantile')

#LM produces a list of timestamps and results
for timestamp, result in LM.results:
    print("Signals produced prior to {0}:".format(timestamp))
    print(result.signals.head())

TODO

  • Create a data set for demonstrating usage more thoroughly and to run tests
  • Improve high-level documentation of the methods and their parameters
  • Integrate with mmappy and spotlight (coming soon) for an end-to-end device surveillance/pharmacovigilance pipeline

Authors

David Beery

License

GNU GPLv3

Acknowledgements

  • Ismail Ahmed and Antoine Poncet for the original leg work in designing and implementing a good disproportionality analysis library in R
  • Ross Ihaka for his implementation of the log|gamma(x)| function
  • Catherine Loader for her Stirling's formula log error and deviance functions.

vigipy's People

Contributors

shakesbeery avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.