Code Monkey home page Code Monkey logo

bsel-uc3m / pmoss Goto Github PK

View Code? Open in Web Editor NEW
16.0 6.0 5.0 21.65 MB

pMoSS (p-value Model using the Sample Size) is a Python code to model the p-value as an n-dependent function using Monte Carlo cross-validation. Exploits the dependence on the sample size to characterize the differences among groups of large datasets

License: BSD 3-Clause "New" or "Revised" License

Python 99.20% Jupyter Notebook 0.80%
decay python statistics monte-carlo-sampling p-value nhst hypothesis-testing group-comparison big-data bioinformatics-analysis

pmoss's Introduction

pMoSS: p-value Model using the Sample Size

minimal Python version License

pMoSS (p-value Model using the Sample Size) is a Python code to model the p-value as an n-dependent function using Monte Carlo cross-validation.

This statistical method uses the relationship between the p-value and the sample size to characterize the data of an experiment and decide, robustly, when the null hypothesis can be rejected.

The method is presented at E. Gómez-de-Mariscal, V. Guerrero, A. Sneider, H. Jayatilaka, J. M. Phillip, D. Wirtz and A. Muñoz-Barrutia, "Use of the p-values as a size-dependent function to address practical differences when analyzing large datasets." Scientific Reports, 2021.

How to cite

@article{gomez2021pvalue,
  title={Use of the p-values as a size-dependent function to address practical differences when analyzing large datasets},
  author={G{\'o}mez-de-Mariscal, Estibaliz and Guerrero, Vanesa and Sneider, Alexandra and Jayatilaka, Hasini and Phillip, Jude M. and Wirtz, Denis and Mu{\~{n}}oz-Barrutia, Arrate},
  journal={Scientific Reports},
  year={2021},
  volume={11},
  number={20942},
  URL = {https://doi.org/10.1038/s41598-021-00199-5},
  doi = {10.1038/s41598-021-00199-5}
}

Conditions of use

pMoSS is an open-source software (OSS) under the BSD 2-Clause License. All the resources provided here are freely available for non-commercial and research purposes. Their use for any other purpose is generally possible, but solely with the explicit permission of the authors. You are expected to include adequate references whenever you present or publish results that are based on the resources provided.

Whatch these short tutorials to become an expert user of pMoSS

Get pMoSS ready in Google Colab Analysis of new data using Google Colab

Brief description

The method uses Monte Carlo cross-validation to estimate the distribution of the p-value using samples of different sizes, and fits an exponential curve. When the p-value of a certain statistical hypothesis test is treated as a function of n, it is possible to get quantitative indicators of the data, such as the decay of the function or the minimum data size needed to get statistically significant differences (nα).

The following figure illustrates a common output of the method. Here the cell body roundness is tested when cancer cells are treated with Taxol.

|

(Leftmost) The cell roundness distribution of control cells and cells treated at 1 nM Taxol have lower values than that of cells treated at 50 nM. (Right) The three groups were compared, the p-values were estimated and p(n) was fitted for each pair of compared groups. When Taxol at 50 nM is evaluated (blue and yellow dashed curves), nα is lower and the decay of p(n) is higher (a and c parameters of the exponential function ), i.e. it decreases much faster than the one corresponding comparison of control and Taxol at 1 nM (orange curve).

Installation

This package is tested on Python 3.6 and 3.7. The code can be used either in a local machine or in

Local Machine

You need to have Python installed previously. For non-expert users, it is highly recommended to download the Anaconda distribution of Python to obtain the dependencies easily.

Create a new virtual environment with Python 3.6 to avoid any version compatibility issues. There are three different ways to do it:

  • Create a virtual environment with Python (advanced users).
  • Open Anaconda Prompt and create a virtual environment called your_virtualenv using conda create:
    conda create -n your_virtualenv python=3.6
  • Open Anaconda Navigator and create a virtual environment using the GUI.

Open Anaconda Prompt and activate your virtual environment using conda activate:

conda activate your_virtualenv

Once your_virtualnv is activated, install the pmoss python package using pip:

pip install pmoss

Examples

We provide two notebooks as examples with the data used in the reference manuscript. You need to install Jupyter Notebook. Do not forget to do it in your virtual environment: activate your_virtualenv using conda activate (as it was done in previous lines) and install Jupyter with the following command:

pip install jupyter
jupyter notebook

In Jupyter, you have access to the directories in your local machine. Once you have downloaded one of the example jupyter notebooks, open it and run the cells.

Please, note that the software is not implemented for GPU, so Monte Carlo cross-validation takes quite a long time. The user can target the process by observing for a certain n-value, when a entire cross-validation has finished.

Play with already computed p-values

In Releases, you will find a data.zip file which contains the estimated p-values of the examples:

  • p-values for the morphology changes with the increase of cellular age.
  • p-values for the morphology changes in cancer cells and their protrusions after being treated with Taxol.

To avoid heavy computations and make a quick test of the code, download the data. Then, place it into the folder of the cloned repository, so the links in the notebooks work properly. Otherwise, change the links in the notebooks.

Google Colab

You could run the notebooks in Google Colab. Open the notebook of the examples in Google Colab (File -> Open notebook... -> GitHub -> URL to the notebook). Note that you need to save a copy of this notebook in your drive to keep any change (File -> Save a copy in Drive)

Add the following code lines at the beginning of the notebook:

  • If the code and data are located in your drive, then you need to mount it so Google Colab can access to your private files. Otherwise, you can skip this step.
from google.colab import drive
drive.mount('/content/drive')
  • Install the package using pip as before or clone this github repository and install the package using
!git clone https://github.com/BIIG-UC3M/pMoSS.git
!pip install /content/pMoSS/.
  • Modify the paths to access your data considering that your drive is mounted in Google Colab:
path = '/content/MyDrive/path_to_the_data_in_your_drive/'

You are ready to run the code in the notebook!

System requirements

Operating systems.

  • Windows
  • Mac OSX
  • Linux

Python version and packages:

  • Python 3.6 (or newer)
  • numpy
  • scipy>=1.1.0
  • pandas
  • matplotlib
  • xlrd>=1.0.0
  • seaborn
  • statsmodels>=0.9.0
  • glob2
  • pytest-shutil

Feedback and contributions

  • All kind of feedback is welcome. Specially if it supports the use of the code and a better understanding on how to work with it.
  • Controbutions are also welcome. Please, create a new pull request on a new development branch to add new features, correct bugs or make changes in the code.
  • Please, if possible, use GitHub Issues to report any bug or ask questions.

pmoss's People

Contributors

esgomezm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pmoss's Issues

pip-installable python package on pypi?

Hi @esgomezm et al.,

this is a super cool repository! Congratulations to the paper that just came out!

I was wondering if you would be interested in publishing the code as pip-installable python package on pypi. It could then be reused in other projects and libraries. I presume this would very useful! However, it may also cost mid-/long-term maintenance efforts.

Let me know what your plans are in this context and/or if I can assist converting this repository into a python package on pypi.

Best,
Robert

using with gene expression data

Hi,

I wonder that can I use this approach with gene expression data.
I have ~15.000 genes with expressions for 200 samples.
I have tried to use with same parameters in example script, however it returns an error pMoSS/cross_validation.py:146, in read_pvalues(file_list) IndexError: index 0 is out of bounds for axis 1 with size 0 because computed pvalues files empty there is no array in it.

Is there anything I can do about it?
My input like this:

A1BG | A1BG-AS1 | A2M | A2ML1 | A3GALT2
0.348415 | 0.418065 | 0.458255 | 0.515604 | 0.450486
0.231103 | 0.389840 | 0.483299 | 0.408892 | 0.454666
0.234935 | 0.272578 | 0.465594 | 0.423093 | 0.347355
0.230452 | 0.286263 | 0.619479 | 0.457346 | 0.516015
0.396523 | 0.519556 | 0.323117 | 0.396117 | 0.421616

df.shape: (200, 15633)

Thank you.

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.