Skip to content

Commit 763287f

Browse files
authored
Merge pull request #5 from netZoo/devel
Devel
2 parents 93cb02d + a2af9ad commit 763287f

File tree

13 files changed

+50
-46
lines changed

13 files changed

+50
-46
lines changed

.gitignore

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
*.bak
22
*.log
33
.pyc
4-
pypanda/*.pyc
5-
pypuma/*.pyc
6-
pypanda/output*
7-
pypuma/output*
4+
netZooPy/netZooPy/pypanda/*.pyc
5+
netZooPy/netZooPy/pypuma/*.pyc
6+
netZooPy/netZooPy/pypanda/output*
7+
netZooPy/netZooPy/pypuma/output*
88
dist/
99
*.egg-info/
1010
.DS_Store
@@ -20,10 +20,10 @@ pypuma.egg*
2020
test_*.txt
2121
pypandaenv/
2222
.idea/
23-
pypuma/__pycache__
24-
pypuma/__pycache__/*
23+
netZooPy/netZooPy/pypuma/__pycache__
24+
netZooPy/netZooPy/pypuma/__pycache__/*
2525
top*genes.png
2626
Toy_Panda.pairs.txt
2727
Toy_Puma.pairs.txt
2828
test.py
29-
files.txt
29+
files.txt

UserGuide.md

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
## Description
2-
Forked from [https://github.com/QuackenbushLab/pypanda](https://github.com/QuackenbushLab/pypanda),
3-
which was based on [https://github.com/davidvi/pypanda](https://github.com/davidvi/pypanda).
4-
Compared to QuackenbushLab/pypanda this repository adds the Python implementation of PUMA ([run_puma.py](run_puma.py) and [pypanda/puma.py](pypanda/puma.py)).
2+
This repo is based on the following repos:
3+
- [https://github.com/aless80/pypanda](https://github.com/aless80/pypanda),
4+
- [https://github.com/QuackenbushLab/pypanda](https://github.com/QuackenbushLab/pypanda),
5+
- which was based on [https://github.com/davidvi/pypanda](https://github.com/davidvi/pypanda).
6+
- Compared to QuackenbushLab/pypanda this repository adds the Python implementation of PUMA ([run_puma.py](netZooPy/netZooPy/pypuma/run_puma.py) and [netZooPy/netZooPy/pypuma/puma.py](pypanda/puma.py)).
57
NaN values in normalized matrices are replaced with values normalized by the overall z-score. This allows running the Toy Data provided in this repository.
68

79
## Table of Contents
@@ -25,7 +27,8 @@ C and MATLAB code: [https://github.com/mararie/PUMA](https://github.com/mararie/
2527
_Glass K, Huttenhower C, Quackenbush J, Yuan GC. Passing Messages Between Biological Networks to Refine Predicted Interactions, PLoS One, 2013 May 31;8(5):e64832_
2628
Original PANDA C++ code: [http://sourceforge.net/projects/panda-net/](http://sourceforge.net/projects/panda-net/).
2729

28-
* **[LIONESS](https://arxiv.org/abs/1505.06440)** (Linear Interpolation to Obtain Network Estimates for Single Samples)
30+
* **[LIONESS](https://arxiv.org/abs/1505.06440)** (Linear Interpolation to Obtain Network Estimates for Single Samples)
31+
* **[LIONESSR](https://doi.org/10.1016/j.isci.2019.03.02)** The R version
2932
_Marieke Lydia Kuijjer, Matthew Tung,GuoCheng Yuan,John Quackenbush, Kimberly Glass. Estimating sample-specific regulatory networks_
3033

3134
LIONESS can be used to estimate single-sample networks using aggregate networks made with any network reconstruction algorithm (http://arxiv.org/pdf/1505.06440.pdf).
@@ -61,22 +64,22 @@ Hamming distance is calculated every iteration.
6164

6265

6366
## Installation
64-
PyPanda runs on Python 2.7. You can either run the pypanda script directly (see [Usage](#usage)) or install it on your system. We recommend the following commands to install pypandas on UNIX systems:
67+
PyPanda runs on Python 3. You can either run the pypanda script directly (see [Usage](#usage)) or install it on your system. We recommend the following commands to install pypandas on UNIX systems:
6568
#### Using a virtual environment
6669
Using [python virtual environments](http://docs.python-guide.org/en/latest/dev/virtualenvs/) is the cleanest installation method.
6770

6871
Cloning git and setting up a [python virtual environment](http://docs.python-guide.org/en/latest/dev/virtualenvs/):
6972
```no-highlight
7073
pip install --user pipenv #Make sure you have pipenv
71-
git clone https://github.com/aless80/pypanda.git
72-
cd pypanda
74+
git clone https://github.com/netZoo/netZooPy.git
75+
cd netZooPy
7376
```
7477
Creating a virtual environment and installing pypanda:
7578
```no-highlight
7679
virtualenv pypandaenv #virtual environment created in a folder inside the git folder
7780
source pypandaenv/bin/activate
78-
(pypandaenv)$ pip install -r requirements.txt
79-
(pypandaenv)$ python setup.py install --record files.txt
81+
(pypandaenv)$ pip3 install -r requirements.txt
82+
(pypandaenv)$ python3 setup.py install --record files.txt
8083
```
8184
Uninstall pypanda from virtual environment:
8285
```no-highlight
@@ -91,9 +94,9 @@ rm -rf pypandaenv
9194
#### Using pip
9295
Never use ~~sudo pip~~. Instead you can use pip on the user's install directory:
9396
```no-highlight
94-
git clone https://github.com/aless80/pypanda.git
97+
git clone https://github.com/netZooPy/netZooPy.git
9598
cd pypanda
96-
python setup.py install --user
99+
python3 setup.py install --user
97100
#to run from the command line you will need to make pypanda executable and add the bin directory to your PATH:
98101
cd bin
99102
chmod +x pypanda
@@ -104,11 +107,11 @@ source ~/.bashrc
104107
```no-highlight
105108
pip uninstall pypanda
106109
```
107-
To run pypanda from Windows (tested on Windows 10) install Git (https://git-scm.com/downloads) and Anaconda Python2.7 (https://www.continuum.io/downloads) and from the Anaconda prompt run:
110+
To run pypanda from Windows (tested on Windows 10) install Git (https://git-scm.com/downloads) and Anaconda Python3 (https://www.continuum.io/downloads) and from the Anaconda prompt run:
108111
```no-highlight
109-
git clone https://github.com/aless80/pypanda.git
110-
cd pypanda
111-
python setup.py install
112+
git clone https://github.com/netZooPy/netZooPy.git
113+
cd netZooPy
114+
python3 setup.py install
112115
```
113116

114117
## Usage
@@ -130,18 +133,18 @@ python run_panda.py -e ./ToyData/ToyExpressionData.txt -m ./ToyData/ToyMotifData
130133
```
131134
To reconstruct a single sample Lioness Pearson correlation network (this can take some time):
132135
```python
133-
python run_panda.py -e ./ToyData/ToyExpressionData.txt -m ./ToyData/ToyMotifData.txt -p ./ToyData/ToyPPIData.txt -o output_panda.txt -q output_lioness.txt
136+
python3 run_panda.py -e ../../tests/ToyData/ToyExpressionData.txt -m ../../tests/ToyData/ToyMotifData.txt -p ../../tests/ToyData/ToyPPIData.txt -o output_panda.txt -q output_lioness.txt
134137
```
135138

136139
To run pypuma on toy data:
137140
```python
138-
python run_puma.py -e ./ToyData/ToyExpressionData.txt -m ./ToyData/ToyMotifData.txt -p ./ToyData/ToyPPIData.txt -o output_puma.txt -i ./ToyData/ToyMiRList.txt
141+
python3 run_puma.py -e ../../tests/ToyData/ToyExpressionData.txt -m ../../tests/ToyData/ToyMotifData.txt -p ../../tests/ToyData/ToyPPIData.txt -o output_puma.txt -i ../../tests//ToyData/ToyMiRList.txt
139142
```
140143
To reconstruct a single sample Lioness Pearson correlation network using pypuma (this can take some time):
141144
```python
142-
python run_puma.py -e ./ToyData/ToyExpressionData.txt -m ./ToyData/ToyMotifData.txt -p ./ToyData/ToyPPIData.txt -i ToyData/ToyMiRList.txt -o output_puma.txt -q output_lioness.txt
145+
python3 run_puma.py -e ../../tests/ToyData/ToyExpressionData.txt -m ../../tests/ToyData/ToyMotifData.txt -p ../../tests/ToyData/ToyPPIData.txt -i ../../tests/ToyData/ToyMiRList.txt -o output_puma.txt -q output_lioness.txt
143146
```
144-
For pypuma see also [PyPuma](https://github.com/aless80/pypuma#installation).
147+
For pypuma see also [PyPuma](https://github.com/netZooPy/netZooPy/pypuma#installation).
145148

146149
#### Run from python
147150
Fire up your python shell or ipython notebook. Use the python installation in the virtual environment if you installed pypanda there.
@@ -154,7 +157,7 @@ from pypanda.lioness import Lioness
154157
```
155158
Run the Panda algorithm, leave out motif and PPI data to use Pearson correlation network:
156159
```python
157-
panda_obj = Panda('ToyData/ToyExpressionData.txt', 'ToyData/ToyMotifData.txt', 'ToyData/ToyPPIData.txt', remove_missing=False)
160+
panda_obj = Panda('../../tests/ToyData/ToyExpressionData.txt', '../../tests/ToyData/ToyMotifData.txt', '../../tests/ToyData/ToyPPIData.txt', remove_missing=False)
158161
```
159162
Save the results:
160163
```python
@@ -172,7 +175,7 @@ outdegree = panda_obj.return_panda_outdegree()
172175
```
173176
To run the Lioness algorithm for single sample networks, first run panda (or puma) using the keep_expression_matrix flag, then use Lioness as follows:
174177
```python
175-
panda_obj = Panda('ToyData/ToyExpressionData.txt', 'ToyData/ToyMotifData.txt', 'ToyData/ToyPPIData.txt', remove_missing=False, keep_expression_matrix=True)
178+
panda_obj = Panda('../../tests/ToyData/ToyExpressionData.txt', '../../tests/ToyData/ToyMotifData.txt', '../../tests/ToyData/ToyPPIData.txt', remove_missing=False, keep_expression_matrix=True)
176179
lioness_obj = Lioness(panda_obj)
177180
```
178181
Save Lioness results:
@@ -187,7 +190,7 @@ plot.top_network_plot(column= 0, top=100, file='top_100_genes.png')
187190

188191
Run the Puma algorithm, leave out motif and PPI data to use Pearson correlation network:
189192
```python
190-
puma_obj = Puma('ToyData/ToyExpressionData.txt', 'ToyData/ToyMotifData.txt', 'ToyData/ToyPPIData.txt','ToyData/ToyMiRList.txt')
193+
puma_obj = Puma('../../tests/ToyData/ToyExpressionData.txt', '../../tests/ToyData/ToyMotifData.txt', '../../tests/ToyData/ToyPPIData.txt','../../tests/ToyData/ToyMiRList.txt')
191194
```
192195

193196
## Toy data
@@ -216,4 +219,4 @@ Sample1 Sample2 Sample3 Sample4
216219
-0.117475863987 0.494923925853 0.0518448588965 -0.0584810456421
217220
218221
TF, Gene and Motif order is identical to the panda output file.
219-
```
222+
```
-199 Bytes
Binary file not shown.
-2.97 KB
Binary file not shown.
-11.1 KB
Binary file not shown.
-900 Bytes
Binary file not shown.

netZooPy/pypanda/lioness.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import os, os.path
44
import numpy as np
5-
from .panda import Panda
6-
from .timer import Timer
5+
from panda import Panda
6+
from timer import Timer
77

88

99
class Lioness(Panda):

netZooPy/pypanda/panda.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pandas as pd
66
import numpy as np
77
from scipy.stats import zscore
8-
from .timer import Timer
8+
from timer import Timer
99

1010
class Panda(object):
1111
""" Using PANDA to infer gene regulatory network.
@@ -327,14 +327,15 @@ def split_label(label):
327327
plt.savefig(file, dpi=300)
328328
return None
329329

330-
def return_panda_indegree(self):
330+
def return_panda_indegree(self):
331331
'''Return Panda indegree.'''
332332
#subset_indegree = self.export_panda_results.loc[:,['gene','force']]
333333
export_panda_results_pd = pd.DataFrame(self.export_panda_results,columns=['tf','gene','motif','force'])
334334
subset_indegree = export_panda_results_pd.loc[:,['gene','force']]
335335
subset_indegree['force']=pd.to_numeric(subset_indegree.force)
336336
self.panda_indegree = subset_indegree.groupby('gene').sum()
337337
return self.panda_indegree
338+
338339
def return_panda_outdegree(self):
339340
'''Return Panda outdegree.'''
340341
export_panda_results_pd = pd.DataFrame(self.export_panda_results,columns=['tf','gene','motif','force'])

netZooPy/pypanda/run_lioness.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"""
1717
import sys
1818
import getopt
19-
import pypanda
19+
from lioness import Lioness
2020

2121
def main(argv):
2222
#Create variables
@@ -76,7 +76,7 @@ def main(argv):
7676

7777
# Run panda
7878
print('Start LIONESS run ...')
79-
L = pypanda.Lioness(expression_data, motif, ppi, panda_net, start=start, end=end, save_dir=save_dir, save_fmt=save_fmt)
79+
L = Lioness(expression_data, motif, ppi, panda_net, start=start, end=end, save_dir=save_dir, save_fmt=save_fmt)
8080
print('All done!')
8181

8282
if __name__ == '__main__':

netZooPy/pypanda/run_panda.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"""
1515
import sys
1616
import getopt
17-
import pypanda
17+
from panda import Panda
1818

1919
def main(argv):
2020
#Create variables
@@ -58,7 +58,7 @@ def main(argv):
5858

5959
# Run PANDA
6060
print('Start Panda run ...')
61-
panda_obj = pypanda.Panda(expression_data, motif, ppi, save_tmp=True, remove_missing=rm_missing, keep_expression_matrix=bool(lioness_file))
61+
panda_obj = Panda(expression_data, motif, ppi, save_tmp=True, remove_missing=rm_missing, keep_expression_matrix=bool(lioness_file))
6262
#panda_obj = pypanda.Panda(expression_data, motif, None, save_tmp=True, remove_missing=rm_missing)
6363
#panda_obj = pypanda.Panda(None, motif, ppi, save_tmp=True, remove_missing=rm_missing)
6464
#panda_obj = pypanda.Panda(None, motif, None, save_tmp=True, remove_missing=rm_missing)
@@ -69,7 +69,7 @@ def main(argv):
6969
#outdegree = panda_obj.return_panda_outdegree()
7070

7171
if lioness_file:
72-
from pypanda.lioness import Lioness
72+
from lioness import Lioness
7373
lioness_obj = Lioness(panda_obj)
7474
lioness_obj.save_lioness_results(lioness_file)
7575
print('All done!')

0 commit comments

Comments
 (0)