Skip to content

Commit 13a2dbc

Browse files
authored
Merge pull request #134 from netZoo/devel
Devel
2 parents b1b1705 + b37a0d5 commit 13a2dbc

File tree

11 files changed

+92
-25
lines changed

11 files changed

+92
-25
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ netZooM is tested on: (OS: Linux + Macos) X (Language: Octave)
1111
netZooM is a MATLAB package of network methods.
1212

1313
## Zoo animals
14-
(gpu)PANDA, (gpu)LIONESS, PUMA, SPIDER, optPANDA, and OTTER.
14+
(gpu)PANDA, (gpu)LIONESS, (gpu)PUMA, (gpu)SPIDER, optPANDA, and OTTER.
1515

1616
## Quick guide
1717
Clone the repository into your local disk:

netZooM/puma/RunPUMA.m

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
function RegNet=RunPUMA(outtag,alpha,motif_file,exp_file,ppi_file,mir_file)
1+
function RegNet=RunPUMA(outtag,alpha,motif_file,exp_file,ppi_file,mir_file,...
2+
computing)
23
% Description:
34
% PUMA can reconstruct gene regulatory networks using both transcription factors and microRNAs as regulators of mRNA expression levels.
45
% The script must be run with a regulatory prior (variable `motif_file` in the RunPUMA script) and expression data (variable `exp_file`).
@@ -23,14 +24,21 @@
2324
% outtag : path to save output PUMA network in .pairs format.
2425
% mir_file : path to file containing microRNA file
2526
% alpha : learning parameter for the PUMA algorithm
27+
% computing : 'cpu'(default)
28+
% 'gpu' uses GPU to compute distances
2629
% Outputs:
27-
% RegNet : Predicted TF-gene gene complete regulatory network using PANDA as a matrix of size (t,g).
30+
% RegNet : Predicted TF-gene gene complete regulatory network using PANDA as a matrix of size (t,g).
2831
% Author(s):
2932
% Marieke Kuijjer
3033
% Publications:
34+
% https://doi.org/10.1093/bioinformatics/btaa571
3135
% https://www.ncbi.nlm.nih.gov/pubmed/28506242
3236

3337
%% Read in Data %%
38+
if nargin<7
39+
computing='cpu';
40+
end
41+
3442
disp('Reading in data!')
3543

3644
% Expression Data
@@ -96,11 +104,15 @@
96104
GeneCoReg(isnan(GeneCoReg))=0; % change NaNs to 0
97105

98106
if(isempty(mir_file)) % run PANDA
99-
AgNet=PANDA(RegNet, GeneCoReg, TFCoop, alpha);
107+
respWeight=0.5;
108+
similarityMetric='Tfunction';
109+
AgNet=PANDA(RegNet, GeneCoReg, TFCoop, alpha, respWeight,...
110+
similarityMetric, computing);
100111
AgNet=AgNet(:);
101112
end
102113
if(~isempty(mir_file)) % run PUMA
103-
AgNet=PUMA(RegNet, GeneCoReg, TFCoop, alpha, s1, s2, t1, t2); % s1, s2, t1, t2 are indices of miR interactions in TFCoop
114+
AgNet=PUMA(RegNet, GeneCoReg, TFCoop, alpha, s1, s2, t1, t2,...
115+
computing); % s1, s2, t1, t2 are indices of miR interactions in TFCoop
104116
AgNet=AgNet(:);
105117
end
106118

netZooM/spider/spider_run.m

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
function SpiderNet=spider_run(lib_path, bedtoolspath, alpha, motifhitfile, annofile, chrinfo, ranges, regfile, outtag,motifdir, epifile,save_temp,save_pairs,spider_out,nTF )
1+
function SpiderNet=spider_run(lib_path, bedtoolspath, alpha, motifhitfile,...
2+
annofile, chrinfo, ranges, regfile, outtag, motifdir,...
3+
epifile, save_temp, save_pairs, spider_out, nTF, computing)
24
% Description:
35
% Using SPIDER to infer epigenetically-informed gene regulatory network.
46
% Optional steps that do not need to run everytime. The codes can be run once and parameters values can be saved
@@ -29,6 +31,8 @@
2931
% save_pairs: (Optional) boolean parameter
3032
% 1: the final network will be saved .pairs format where each line has a TF-gene edge (Cytoscape compatible)
3133
% 0: the final network will not be saved in .pairs format
34+
% computing : 'cpu'(default)
35+
% 'gpu' uses GPU to compute distances
3236
% Outputs:
3337
% SpiderNet : Predicted TF-gene gene complete regulatory network using SPIDER as a matrix of size (t,g).
3438
% Author(s):
@@ -37,7 +41,9 @@
3741
%% ============================================================================
3842
%% Set Program Parameters and Path
3943
%% ============================================================================
40-
44+
if nargin < 16
45+
computing='cpu';
46+
end
4147
% Run configuration to set parameter first (e.g., run('panda_config.m');)
4248

4349
fprintf('Input epigenetically informed motif file: %s\n', motifhitfile);
@@ -82,7 +88,7 @@
8288

8389

8490
% Run message-passing
85-
SpiderNet=SPIDER(PriorNet, eye(length(GeneNames)), eye(length(TFNames)), alpha);
91+
SpiderNet=SPIDER(PriorNet, eye(length(GeneNames)), eye(length(TFNames)), alpha, computing);
8692

8793
%% ============================================================================
8894
%% Saving SPIDER network output

netZooM/tools/PUMA.m

+26-8
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,46 @@
1-
function RegNet=PUMA(RegNet, GeneCoReg, TFCoop, alpha, s1, s2, t1, t2);
1+
function RegNet=PUMA(RegNet, GeneCoReg, TFCoop, alpha, s1, s2, t1, t2,...
2+
computing)
23
% Description:
34
% PUMA can reconstruct gene regulatory networks using both transcription factors and microRNAs as regulators
45
% of mRNA expression levels.
56
% Inputs:
6-
% RegNet : motif prior of gene-TF regulatory network
7-
% GeneCoReg: gene-gene co-regulatory network
8-
% TFCoop : PPI binding between transcription factors
9-
% alpha : learning rate
10-
% s1, s2, t1, t2 are indices of miR interactions in TFCoop, the TF-TF PPI network.
7+
% RegNet : motif prior of gene-TF regulatory network
8+
% GeneCoReg : gene-gene co-regulatory network
9+
% TFCoop : PPI binding between transcription factors
10+
% alpha : learning rate
11+
% s1, s2, t1, t2: indices of miR interactions in TFCoop, the TF-TF PPI network.
12+
% computing : 'cpu'(default)
13+
% 'gpu' uses GPU to compute distances
1114
% Outputs:
12-
% RegNet : inferred gene-TF regulatory network
15+
% RegNet : inferred gene-TF regulatory network
1316
% Author(s):
1417
% Marieke Kuijjer
1518
% Publications:
19+
% https://doi.org/10.1093/bioinformatics/btaa571
1620
% https://www.ncbi.nlm.nih.gov/pubmed/28506242
1721

1822
[NumTFs,NumGenes]=size(RegNet);
19-
23+
if nargin < 9
24+
computing='cpu';
25+
end
2026
%% Run PANDA %%
2127

2228
disp('Normalizing Networks!');
2329
RegNet=NormalizeNetwork(RegNet);
2430
GeneCoReg=NormalizeNetwork(GeneCoReg);
2531
TFCoop=NormalizeNetwork(TFCoop);
32+
if isequal(computing,'gpu')
33+
isPUMA = 1;
34+
respWeight = 0.5;
35+
similarityMetric= 'Tfunction';
36+
precision = 'double';
37+
verbose = 1;
38+
saveMemory = 0;
39+
RegNet = gpuPANDA(RegNet, GeneCoReg, TFCoop, alpha, respWeight,...
40+
similarityMetric,computing,precision,verbose,...
41+
saveMemory,isPUMA, s1, s2, t1, t2);
42+
return
43+
end
2644
TFCoopInit=TFCoop;% PUMA, keep a backup of the initial TFCoop
2745
% you should keep those values for the ismember(miR, TFNames)
2846

netZooM/tools/gpuPANDA.m

+22-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
function RegNet = gpuPANDA(RegNet, GeneCoReg, TFCoop, alpha, respWeight, similarityMetric,...
2-
computing,precision,verbose,saveMemory,gpuSave)
2+
computing, precision, verbose, saveMemory, gpuSave, isPUMA,...
3+
s1, s2, t1, t2)
34
% Description:
45
% GPU-accelerated PANDA, slightly different implmentation that is
56
% optimized for memory.
@@ -45,8 +46,12 @@
4546
% gpuSave : GPU flag for saving output network
4647
% 1 keep the final network in GPU memory
4748
% 0 (Default) send the final network to CPU and reset GPU memory
49+
% isPUMA : boolean, if gpuPANDA is called through PUMA then add
50+
% additional steps to keep the miRNA interactions.
51+
% s1,s2,t1,t2: when isPUMA==1, these are the indices of miR
52+
% interactions in TFCoop, the TF-TF PPI network.
4853
% Outputs:
49-
% RegNet : inferred gene-TF regulatory network
54+
% RegNet : inferred gene-TF regulatory network
5055
% Author(s):
5156
% Marouen Ben Guebila
5257

@@ -71,6 +76,9 @@
7176
if nargin<11
7277
gpuSave=0;
7378
end
79+
if nargin<12
80+
isPUMA=0;
81+
end
7482
if iscategorical(similarityMetric)
7583
similarityMetric=char(similarityMetric(1));
7684
end
@@ -114,6 +122,9 @@
114122
RegNet = gpuArray(RegNet);
115123
GeneCoReg= gpuArray(GeneCoReg);
116124
end
125+
if isPUMA==1
126+
TFCoopInit=TFCoop;
127+
end
117128
while hamming > 0.001
118129
if isequal(similarityMetric,'Tfunction')
119130
R = Tfunction(TFCoop, RegNet);
@@ -154,7 +165,15 @@
154165

155166
A = UpdateDiagonal(A, NumTFs, alpha, step);
156167
TFCoop = (1 - alpha) * TFCoop + alpha * A;%clear A;
157-
168+
169+
if isPUMA==1
170+
TFCoopDiag=diag(TFCoop);
171+
TFCoop(sub2ind([NumTFs, NumTFs],s1,s2))=...
172+
TFCoopInit(sub2ind([NumTFs, NumTFs],s1,s2));
173+
TFCoop(sub2ind([NumTFs, NumTFs],t1,t2))=...
174+
TFCoopInit(sub2ind([NumTFs, NumTFs],t1,t2));
175+
TFCoop(1:(size(TFCoop,1)+1):end) =TFCoopDiag;
176+
end
158177
if isequal(similarityMetric,'Tfunction')
159178
A = Tfunction(RegNet');
160179
else

netZooM/tools/spider/SPIDER.m

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function RegNet=SPIDER(RegNet, GeneCoReg, TFCoop, alpha);
1+
function RegNet=SPIDER(RegNet, GeneCoReg, TFCoop, alpha, computing)
22
% Description:
33
% Using SPIDER to infer epigenetically-informed gene regulatory network. This function uses PANDA at the back end of the computation
44
% 1. Normalizing networks
@@ -8,24 +8,36 @@
88
% alpha : parameter that determines the level of message-passing
99
% RegNet : motif prior of gene-TF regulatory network
1010
% GeneCoReg : Optional input for SPIDER: Identify matrix of size GeneNames by GeneNames is used as input by default where gene expression information is absent
11-
% TFCoop : Optional input for SPIDER: Identify matrix of size TFNames by TFNames is used as input by default if PPI network is not used as input
12-
% TFCoop : PPI binding between transcription factors
11+
% TFCoop : PPI binding between transcription factors.
12+
% Optional input for SPIDER: Identify matrix of size TFNames by TFNames is used as input by default if PPI network is not used as input
13+
% computing : 'cpu'(default)
14+
% 'gpu' uses GPU to compute distances
1315
% Outputs:
14-
% SpiderNet : Predicted TF-gene gene complete regulatory network for cell line using SPIDER and message-passing from PANDA as a matrix of size (t,g).
16+
% RegNet : Predicted TF-gene gene complete regulatory network for cell line using SPIDER and message-passing from PANDA as a matrix of size (t,g).
1517
% Author(s):
1618
% Abhijeet Sonawane, Kimberly Glass
1719

1820
[NumTFs,NumGenes]=size(RegNet);
1921

2022
%% Run PANDA %%
21-
23+
if nargin <5
24+
computing = 'cpu';
25+
end
26+
2227
disp('Adjusting the degree of prior network!');
2328
RegNet=DegreeAdjust(RegNet);
2429
disp('Normalizing Networks!');
2530
RegNet=NormalizeNetwork(RegNet);
2631
GeneCoReg=NormalizeNetwork(GeneCoReg);
2732
TFCoop=NormalizeNetwork(TFCoop);
2833

34+
if isequal(computing,'gpu')
35+
respWeight = 0.5;
36+
similarityMetric='Tfunction';
37+
RegNet = gpuPANDA(RegNet, GeneCoReg, TFCoop, alpha, respWeight,...
38+
similarityMetric,computing);
39+
return
40+
end
2941
tic;
3042
disp('Learning Network!')
3143
step=0;

tests/testSpider.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function testSpiderSimple()
3737
% Add path
3838
addpath(genpath(fullfile(pwd,'tests')));
3939

40-
% Create save folder
40+
% Call SPIDER
4141
SpiderNet = spider_run(lib_path, bedtoolspath, alpha, motifhitfile, annofile,...
4242
chrinfo, ranges, regfile, outtag,motifdir, epifile,save_temp,save_pairs,spider_out,nTF )
4343
% Call Panda
Binary file not shown.
Binary file not shown.

tutorials/gpuzoo/gpuZoo_tutorial.mlx

7.11 KB
Binary file not shown.

tutorials/gpuzoo/gpuZoo_tutorial.pdf

43.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)