diff --git a/R/ALPACA.R b/R/ALPACA.R index c4c6ad00..6b0d4e6e 100644 --- a/R/ALPACA.R +++ b/R/ALPACA.R @@ -70,19 +70,22 @@ alpaca <- function(net.table,file.stem,verbose=FALSE) louv.Bscores <- NULL for (i in seq_len(max(louv.memb))) { + print(i) this.comm <- names(louv.memb)[louv.memb==i] this.tfs <- this.comm[grep("_A$",this.comm)] this.genes <- this.comm[grep("_B$",this.comm)] if (length(this.tfs)>=1){ if (length(this.tfs)>1){ - tf.sums <- apply(dwbm[this.tfs,this.genes],1,sum) - gene.sums <- apply(dwbm[this.tfs,this.genes],2,sum) + if (length(this.genes)==1){ + gene.sums <- sum(dwbm[this.tfs,this.genes]) + tf.sums <- dwbm[this.tfs,this.genes] + }else if (length(this.genes)>1){ + tf.sums <- apply(dwbm[this.tfs,this.genes],1,sum) + gene.sums <- apply(dwbm[this.tfs,this.genes],2,sum) + } } else if (length(this.tfs)==1) { tf.sums <- sum(dwbm[this.tfs,this.genes]) gene.sums <- dwbm[this.tfs,this.genes] - } else if (length(this.genes)==1){ - gene.sums <- sum(dwbm[this.tfs,this.genes]) - tf.sums <- dwbm[this.tfs,this.genes] } this.denom <- sum(dwbm[this.tfs,this.genes]) louv.Ascores <- c(louv.Ascores,tf.sums/this.denom) diff --git a/inst/extdata/panda.py b/inst/extdata/panda.py index ae4a7685..4f534239 100644 --- a/inst/extdata/panda.py +++ b/inst/extdata/panda.py @@ -4,6 +4,7 @@ import pandas as pd from scipy.stats import zscore import numpy as np +import os # this scirpt is derived from https://github.com/netZoo/netZooPy/blob/master/netZooPy/panda/panda.py # and https://github.com/netZoo/netZooPy/blob/master/netZooPy/panda/timer.py @@ -91,9 +92,9 @@ def __init__(self, expression_file, motif_file, ppi_file, computing='cpu',precis if save_tmp: with Timer('Saving expression matrix and normalized networks ...'): if self.expression_data is not None: - np.save('/tmp/expression.npy', self.expression_data.values) - np.save('/tmp/motif.normalized.npy', self.motif_matrix) - np.save('/tmp/ppi.normalized.npy', self.ppi_matrix) + np.save('expression.npy', self.expression_data.values) + np.save('motif.normalized.npy', self.motif_matrix) + np.save('ppi.normalized.npy', self.ppi_matrix) # delete expression data del self.expression_data