diff --git a/mofapy2/build_model/build_model.py b/mofapy2/build_model/build_model.py index c827316..93f08da 100644 --- a/mofapy2/build_model/build_model.py +++ b/mofapy2/build_model/build_model.py @@ -149,7 +149,6 @@ def build_ThetaZ(self): # initTheta_qE = 1. self.init_model.initThetaZ( - self.data_opts["samples_groups"], qa=initTheta_a, qb=initTheta_b, qE=initTheta_qE, diff --git a/mofapy2/build_model/init_model.py b/mofapy2/build_model/init_model.py index f1f74ba..10da654 100644 --- a/mofapy2/build_model/init_model.py +++ b/mofapy2/build_model/init_model.py @@ -98,7 +98,6 @@ def initZ( # mean if qmean is not None: if isinstance(qmean, str): - # Random initialisation if qmean == "random": qmean = stats.norm.rvs(loc=0, scale=1, size=(self.N, self.K)) @@ -199,7 +198,6 @@ def initZ_smooth( # mean if qmean is not None: if isinstance(qmean, str): - # Random initialisation if qmean == "random": qmean = stats.norm.rvs(loc=0, scale=1, size=(self.N, self.K)) @@ -350,7 +348,6 @@ def initZgU( # mean if qmean is not None: if isinstance(qmean, str): - # Random initialisation if qmean == "random": qmean = stats.norm.rvs(loc=0, scale=1, size=(self.N, self.K)) @@ -415,7 +412,6 @@ def initSigma( model_groups=False, use_gpytorch=False, ): - self.Sigma = Sigma_Node( dim=(self.K,), sample_cov=sample_cov, @@ -437,7 +433,6 @@ def initSigma_sparse( model_groups=False, use_gpytorch=False, ): - self.Sigma = Sigma_Node_sparse( dim=(self.K,), sample_cov=sample_cov, @@ -464,7 +459,6 @@ def initSigma_warping( model_groups=False, use_gpytorch=False, ): - self.Sigma = Sigma_Node_warping( dim=(self.K,), sample_cov=sample_cov, @@ -514,7 +508,6 @@ def initSZ( ## Initialise variational distribution (Q) if isinstance(qmean_T1, str): - if qmean_T1 == "random": qmean_T1 = stats.norm.rvs(loc=0, scale=1, size=(self.N, self.K)) elif qmean_T1 == "pca": @@ -579,7 +572,6 @@ def initW( W_list = [None] * self.M for m in range(self.M): - ## Initialise prior distribution (P) ## # mean @@ -593,7 +585,6 @@ def initW( # mean if qmean is not None: if isinstance(qmean, str): - # Random initialisation if qmean == "random": qmean_m = stats.norm.rvs( @@ -665,12 +656,10 @@ def initSW( W_list = [None] * self.M for m in range(self.M): - ## Initialise prior distribution (P) ## Initialise variational distribution (Q) if isinstance(qmean_S1, str): - if qmean_S1 == "random": qmean_S1_tmp = stats.norm.rvs( loc=0, scale=1.0, size=(self.D[m], self.K) @@ -800,7 +789,6 @@ def initTau(self, pa=1e-3, pb=1e-3, qa=1.0, qb=1.0, qE=None): tau_list = [None] * self.M for m in range(self.M): - # Poisson noise model for count data if self.lik[m] == "poisson": tmp = 0.25 + 0.17 * np.nanmax(self.data[m], axis=0) diff --git a/mofapy2/build_model/save_model.py b/mofapy2/build_model/save_model.py index 393dcef..311bca1 100644 --- a/mofapy2/build_model/save_model.py +++ b/mofapy2/build_model/save_model.py @@ -55,7 +55,6 @@ def __init__( sort_factors=True, compression_level=9, ): - # Check that the model is trained # NOTE: it might be not trained if saving when training is interrupted if not model.trained: @@ -265,7 +264,6 @@ def saveData(self): data_subgrp = data_grp.create_group(self.views_names[m]) intercept_subgrp = intercept_grp.create_group(self.views_names[m]) for g in range(len(self.groups_names)): - # Subset group samples_idx = np.where( np.array(self.samples_groups) == self.groups_names[g] @@ -332,7 +330,6 @@ def saveImputedData(self, mean, variance): for m in range(len(mean)): view_subgrp = data_grp.create_group(self.views_names[m]) for g in range(len(self.groups_names)): - # Subset group samples_idx = np.where( np.array(self.samples_groups) == self.groups_names[g] @@ -391,7 +388,6 @@ def saveZpredictions(self, mean, variance, values, groups): ) def saveExpectations(self, nodes="all"): - # Get nodes from the model nodes_dic = self.model.getNodes() if type(nodes) is str: @@ -435,15 +431,12 @@ def saveExpectations(self, nodes="all"): # Multi-view nodes if isinstance(nodes_dic[n], Multiview_Node): for m in range(nodes_dic[n].M): - # Multi-groups nodes (Tau, Y, and Z) if n in multigroup_nodes: - # Create subgroup for the view view_subgrp = node_subgrp.create_group(self.views_names[m]) for g in self.groups_names: - # Add missing values to Tau and Y nodes exp[m][self.mask[m]] = np.nan @@ -471,7 +464,6 @@ def saveExpectations(self, nodes="all"): # Single-view nodes else: - # Multi-group nodes (Z) if n in multigroup_nodes: for g in self.groups_names: @@ -548,13 +540,11 @@ def saveParameters(self, nodes="all"): # Multi-view nodes if isinstance(nodes_dic[n], Multiview_Node): for m in range(nodes_dic[n].M): - # Create subgroup for the view view_subgrp = node_subgrp.create_group(self.views_names[m]) # Multi-groups nodes if n in multigroup_nodes: - for g in self.groups_names: grp_subgrp = view_subgrp.create_group(g) @@ -586,7 +576,6 @@ def saveParameters(self, nodes="all"): # Single-view nodes else: - # Multi-group nodes if n in multigroup_nodes: for g in self.groups_names: @@ -615,7 +604,6 @@ def saveParameters(self, nodes="all"): pass def saveModelOptions(self): - # Subset model options options_to_save = [ "likelihoods", @@ -717,7 +705,6 @@ def saveSmoothOptions(self, smooth_opts): grp[k].attrs["names"] = np.asarray(list(opts.keys())).astype("S") def saveVarianceExplained(self): - # Sort values by alphabetical order of views # order = np.argsort(self.views_names) # # order = [ i[0] for i in sorted(enumerate(self.views_names), key=lambda x:x[1]) ] diff --git a/mofapy2/build_model/train_model.py b/mofapy2/build_model/train_model.py index dc3132a..df9bdc9 100644 --- a/mofapy2/build_model/train_model.py +++ b/mofapy2/build_model/train_model.py @@ -10,7 +10,6 @@ def train_model(model): - # Sanity check on the Bayesian Network assert isinstance(model, BayesNet), "'model' has to be a BayesNet class" diff --git a/mofapy2/build_model/utils.py b/mofapy2/build_model/utils.py index ba61548..6f91c8c 100644 --- a/mofapy2/build_model/utils.py +++ b/mofapy2/build_model/utils.py @@ -53,9 +53,7 @@ def gaussianise(Y_m, axis=0): def process_data(data, likelihoods, data_opts, samples_groups): - for m in range(len(data)): - # For some wierd reason, when using reticulate from R, missing values are stored as -2147483648 data[m][data[m] == -2147483648] = np.nan @@ -79,7 +77,6 @@ def process_data(data, likelihoods, data_opts, samples_groups): # Centering and scaling is only appropriate for gaussian data if likelihoods[m] in ["gaussian"]: - # Center features per group if data_opts["center_groups"]: for g in data_opts["groups_names"]: diff --git a/mofapy2/core/BayesNet.py b/mofapy2/core/BayesNet.py index 562866a..b7f1309 100644 --- a/mofapy2/core/BayesNet.py +++ b/mofapy2/core/BayesNet.py @@ -133,7 +133,6 @@ def getNodes(self): return self.nodes def calculate_variance_explained(self, total=False): - # Collect relevant expectations Z = self.nodes["Z"].getExpectation() W = self.nodes["W"].getExpectation() @@ -384,7 +383,7 @@ def iterate(self): "time": iter_time, "number_factors": number_factors, "elbo": elbo["total"].values, - "elbo_terms": elbo.drop("total", 1), + "elbo_terms": elbo.drop("total", axis=1), } if "Sigma" in self.nodes.keys(): tmp = self.nodes["Sigma"].getParameters() # save only last iteration diff --git a/mofapy2/core/distributions/basic_distributions.py b/mofapy2/core/distributions/basic_distributions.py index 062c797..af238e8 100644 --- a/mofapy2/core/distributions/basic_distributions.py +++ b/mofapy2/core/distributions/basic_distributions.py @@ -19,6 +19,7 @@ # from mofapy2.config import settings # from mofapy2.core.utils import * # TODO prob not necessary ? + # General class for probability distributions class Distribution(object): """General class for a statistical distribution""" diff --git a/mofapy2/core/distributions/bernoulli_gaussian.py b/mofapy2/core/distributions/bernoulli_gaussian.py index 243c7e2..2c8a059 100644 --- a/mofapy2/core/distributions/bernoulli_gaussian.py +++ b/mofapy2/core/distributions/bernoulli_gaussian.py @@ -107,7 +107,6 @@ def updateExpectations(self): # self.expectations = {'E':E, 'EB':EB, 'EN':EN, 'E2':E2, 'ENN':ENN, 'EXXT':EXXT } def removeDimensions(self, axis, idx): - # Method to remove undesired dimensions # - axis (int): axis from where to remove the elements # - idx (numpy array): indices of the elements to remove diff --git a/mofapy2/core/gpu_utils.py b/mofapy2/core/gpu_utils.py index bf77af3..afbe3bc 100644 --- a/mofapy2/core/gpu_utils.py +++ b/mofapy2/core/gpu_utils.py @@ -11,6 +11,7 @@ # -------------------------------------------------------- gpu_mode = False + # -------------------------------------------------------- # operations on single matrices # -------------------------------------------------------- diff --git a/mofapy2/core/nodes/Kc_node.py b/mofapy2/core/nodes/Kc_node.py index 3520a29..b76b606 100644 --- a/mofapy2/core/nodes/Kc_node.py +++ b/mofapy2/core/nodes/Kc_node.py @@ -80,7 +80,6 @@ def compute_kernel(self, spectral_decomp=True): self.compute_kernel_at_gridpoint(i, spectral_decomp=spectral_decomp) def compute_kernel_at_gridpoint(self, i, spectral_decomp=True): - # build kernel matrix based on given covariance function if not spectral_decomp: self.Kmat[i, :, :] = SE(self.covariates, self.l_grid[i], zeta=0) @@ -118,7 +117,6 @@ def set_gridix(self, lidx, k): # no recomputation required as stored on grid def eval_at_newpoints_k(self, new_cov, k): - Kc_new = SE(new_cov, self.l_grid[self.gridix[k]], zeta=0) return Kc_new diff --git a/mofapy2/core/nodes/Kg_node.py b/mofapy2/core/nodes/Kg_node.py index e4d8e98..af79fd4 100644 --- a/mofapy2/core/nodes/Kg_node.py +++ b/mofapy2/core/nodes/Kg_node.py @@ -6,6 +6,7 @@ from mofapy2.core.nodes.variational_nodes import * from mofapy2.core.gp_utils import * + # TODO: for large number of groups avoid constructing Kmat if spectral decomp and only save x at the end (getParameters in SigmaNode) class Kg_Node(Node): """ diff --git a/mofapy2/core/nodes/Sigma_node.py b/mofapy2/core/nodes/Sigma_node.py index 71a0e8e..82596ee 100644 --- a/mofapy2/core/nodes/Sigma_node.py +++ b/mofapy2/core/nodes/Sigma_node.py @@ -345,7 +345,6 @@ def removeFactors(self, idx, axis=1): self.Sigma_inv_logdet = np.delete(self.Sigma_inv_logdet, axis=0, obj=idx) def calc_neg_elbo_k(self, par, lidx, k, var): - self.zeta[k] = par[0] self.Kc.set_gridix(lidx, k) @@ -624,7 +623,6 @@ def optimise(self, var): # optimise hyperparamters of GP for k in range(K): - best_zeta = -1 best_elbo = -np.Inf @@ -751,7 +749,6 @@ def __init__( rankx=None, model_groups=False, ): - super().__init__( dim, sample_cov, groups, start_opt, opt_freq, n_grid, rankx, model_groups ) @@ -812,7 +809,6 @@ def __init__( model_groups=False, idx_inducing=None, ): - super().__init__( dim, sample_cov, groups, start_opt, opt_freq, n_grid, rankx, model_groups ) @@ -946,7 +942,6 @@ def __init__( warping_open_end=True, warping_groups=None, ): - super().__init__( dim, sample_cov, groups, start_opt, opt_freq, n_grid, rankx, model_groups ) diff --git a/mofapy2/core/nodes/Theta_nodes.py b/mofapy2/core/nodes/Theta_nodes.py index d680a79..b7fe738 100644 --- a/mofapy2/core/nodes/Theta_nodes.py +++ b/mofapy2/core/nodes/Theta_nodes.py @@ -66,7 +66,6 @@ def _updateParameters(self): self.Q.setParameters(a=Qa, b=Qb) def calculateELBO(self): - # Collect parameters and expectations Qpar, Qexp = self.Q.getParameters(), self.Q.getExpectations() Pa, Pb, Qa, Qb = self.Ppar["a"], self.Ppar["b"], Qpar["a"], Qpar["b"] @@ -91,7 +90,6 @@ class ThetaZ_Node(Beta_Unobserved_Variational_Node): """ def __init__(self, dim, pa, pb, qa, qb, groups, qE=None): - self.groups = groups self.factors_axis = 1 self.N = len(self.groups) @@ -159,7 +157,6 @@ def updateParameters(self, ix=None, ro=1.0): self.Q.setParameters(a=Qa, b=Qb) def _updateParameters(self, S, groups, ro): - Q = self.Q.getParameters() Qa, Qb = Q["a"], Q["b"] Qa *= 1 - ro @@ -186,7 +183,6 @@ def _updateParameters(self, S, groups, ro): return Qa, Qb def calculateELBO(self): - # Collect parameters and expectations Qpar, Qexp = self.Q.getParameters(), self.Q.getExpectations() Pa, Pb, Qa, Qb = self.Ppar["a"], self.Ppar["b"], Qpar["a"], Qpar["b"] diff --git a/mofapy2/core/nodes/U_nodes.py b/mofapy2/core/nodes/U_nodes.py index 1503e9c..a862237 100644 --- a/mofapy2/core/nodes/U_nodes.py +++ b/mofapy2/core/nodes/U_nodes.py @@ -10,6 +10,7 @@ # TODO: # - integrate into Z node using ix + # U_GP_Node_mv class U_GP_Node_mv(MultivariateGaussian_Unobserved_Variational_Node): """ @@ -64,7 +65,6 @@ def get_mini_batch(self): return self.mini_batch def updateParameters(self, ix=None, ro=1.0): - # Get expectations from other nodes W = self.markov_blanket["W"].getExpectations() Y = self.markov_blanket["Y"].get_mini_batch() diff --git a/mofapy2/core/nodes/W_nodes.py b/mofapy2/core/nodes/W_nodes.py index 596948d..089dc61 100755 --- a/mofapy2/core/nodes/W_nodes.py +++ b/mofapy2/core/nodes/W_nodes.py @@ -69,7 +69,6 @@ def updateParameters(self, ix=None, ro=1.0): self._updateParameters(Y, Z, tau, Mu, Alpha, Qmean, Qvar, coeff, ro) def _updateParameters(self, Y, Z, tau, Mu, Alpha, Qmean, Qvar, coeff, ro): - for k in range(self.dim[1]): foo = coeff * np.dot(Z["E2"][:, k], tau) @@ -96,7 +95,6 @@ def _updateParameters(self, Y, Z, tau, Mu, Alpha, Qmean, Qvar, coeff, ro): ) def calculateELBO(self): - # Collect parameters and expectations of current node Qpar, Qexp = self.Q.getParameters(), self.Q.getExpectations() Qmean, Qvar = Qpar["mean"], Qpar["var"] @@ -175,7 +173,6 @@ def removeFactors(self, idx): super().removeFactors(idx, axis=1) def updateParameters(self, ix=None, ro=1.0): - # Collect expectations from other nodes Y = self.markov_blanket["Y"].get_mini_batch() Z = self.markov_blanket["Z"].get_mini_batch() @@ -235,7 +232,6 @@ def _updateParameters( coeff, ro, ): - # Mask matrices tau[mask] = 0.0 @@ -255,7 +251,6 @@ def _updateParameters( # Update each latent variable in turn for k in range(self.dim[1]): - # Compute terms term1 = (theta_lnE - theta_lnEInv)[:, k] diff --git a/mofapy2/core/nodes/Z_nodes.py b/mofapy2/core/nodes/Z_nodes.py index e45f354..bceb892 100755 --- a/mofapy2/core/nodes/Z_nodes.py +++ b/mofapy2/core/nodes/Z_nodes.py @@ -150,7 +150,6 @@ def _updateParameters(self, Y, W, tau, Mu, Alpha, Qmean, Qvar, mask): return {"Qmean": Qmean, "Qvar": Qvar} def calculateELBO(self): - # Collect parameters and expectations of current node Qpar, Qexp = self.Q.getParameters(), self.Q.getExpectations() Qmean, Qvar = Qpar["mean"], Qpar["var"] @@ -432,7 +431,6 @@ def _updateParameters( return {"mean_B1": Qmean_T1, "var_B1": Qvar_T1, "theta": Qtheta} def calculateELBO(self): - # Collect parameters and expectations Qpar, Qexp = self.Q.getParameters(), self.Q.getExpectations() T, ZZ = Qexp["EB"], Qexp["ENN"] diff --git a/mofapy2/core/nodes/Z_nodes_GP.py b/mofapy2/core/nodes/Z_nodes_GP.py index ed7e3ce..e01627f 100644 --- a/mofapy2/core/nodes/Z_nodes_GP.py +++ b/mofapy2/core/nodes/Z_nodes_GP.py @@ -9,6 +9,7 @@ UnivariateGaussian_Unobserved_Variational_Node_with_MultivariateGaussian_Prior, ) + # Z_Node_GP class Z_GP_Node( UnivariateGaussian_Unobserved_Variational_Node_with_MultivariateGaussian_Prior @@ -65,7 +66,6 @@ def get_mini_batch(self): return self.mini_batch def updateParameters(self, ix=None, ro=1.0): - # Get expectations from other nodes W = self.markov_blanket["W"].getExpectations() Y = self.markov_blanket["Y"].get_mini_batch() diff --git a/mofapy2/core/nodes/Z_nodes_GP_mv.py b/mofapy2/core/nodes/Z_nodes_GP_mv.py index ece293c..11843b2 100644 --- a/mofapy2/core/nodes/Z_nodes_GP_mv.py +++ b/mofapy2/core/nodes/Z_nodes_GP_mv.py @@ -7,6 +7,7 @@ # Import manually defined functions from .variational_nodes import MultivariateGaussian_Unobserved_Variational_Node + # Z_GP_Node_mv class Z_GP_Node_mv(MultivariateGaussian_Unobserved_Variational_Node): """ @@ -45,7 +46,6 @@ def get_mini_batch(self): return self.mini_batch def updateParameters(self, ix=None, ro=1.0): - # Get expectations from other nodes W = self.markov_blanket["W"].getExpectations() Y = self.markov_blanket["Y"].get_mini_batch() diff --git a/mofapy2/core/nodes/ZgU_node.py b/mofapy2/core/nodes/ZgU_node.py index 51d3e55..4439358 100644 --- a/mofapy2/core/nodes/ZgU_node.py +++ b/mofapy2/core/nodes/ZgU_node.py @@ -11,6 +11,7 @@ # could be integrated in usual Z node (using a check if U is in Markov blanket) # currentyl takes as N(0,1) prior for nonstuctured factors not flexible using pvar pmean + # ZgU_node class ZgU_node(UnivariateGaussian_Unobserved_Variational_Node): """ @@ -59,7 +60,6 @@ def get_mini_batch(self): return self.mini_batch def updateParameters(self, ix=None, ro=1.0): - # Get expectations from other nodes U = self.markov_blanket["U"].getExpectations() @@ -185,7 +185,6 @@ def calculateELBO_k(self, k): # only non-stucutred nodes contribute here, else p(z|u) = q(z|u) --> ELBO is zero unstructured = (p_cov[k] == np.eye(p_cov[k].shape[0])).all() if unstructured: - tmp1 = -0.5 * (QE2[:, k]).sum() tmp2 = 0 diff --git a/mofapy2/notebooks/run_mofa_cpu_vs_gpu.py b/mofapy2/notebooks/run_mofa_cpu_vs_gpu.py index 6ec64fd..6db8fa6 100644 --- a/mofapy2/notebooks/run_mofa_cpu_vs_gpu.py +++ b/mofapy2/notebooks/run_mofa_cpu_vs_gpu.py @@ -8,7 +8,7 @@ ##################### parser = argparse.ArgumentParser() -parser.add_argument('--gpu', action='store_true') +parser.add_argument("--gpu", action="store_true") args, _ = parser.parse_known_args() @@ -30,7 +30,9 @@ ## Load data in data.frame format ## #################################### -data = pd.read_csv("ftp://ftp.ebi.ac.uk/pub/databases/mofa/getting_started/data.txt.gz", sep="\t") +data = pd.read_csv( + "ftp://ftp.ebi.ac.uk/pub/databases/mofa/getting_started/data.txt.gz", sep="\t" +) ########## ## MOFA ## @@ -49,7 +51,16 @@ ent.set_model_options(factors=15) # Set training options -ent.set_train_options(iter=50, freqELBO=1, dropR2=None, startELBO=1, verbose=False, seed=42, convergence_mode="fast", gpu_mode=args.gpu) +ent.set_train_options( + iter=50, + freqELBO=1, + dropR2=None, + startELBO=1, + verbose=False, + seed=42, + convergence_mode="fast", + gpu_mode=args.gpu, +) # Build the model ent.build() diff --git a/mofapy2/notebooks/test_cupy.py b/mofapy2/notebooks/test_cupy.py index 7f30a78..aebc1e9 100644 --- a/mofapy2/notebooks/test_cupy.py +++ b/mofapy2/notebooks/test_cupy.py @@ -2,8 +2,9 @@ import cupy as cp import time -x_cpu = np.ones((1000,1000,500)) -x_gpu = cp.ones((1000,1000,500)) +x_cpu = np.ones((1000, 1000, 500)) +x_gpu = cp.ones((1000, 1000, 500)) + def do_some_math(x): x *= 10 @@ -11,12 +12,13 @@ def do_some_math(x): x += x x /= x + # CPU (numpy) t = time.time() do_some_math(x_cpu) -print(time.time()-t) +print(time.time() - t) # GPU (CuPy) t = time.time() do_some_math(x_gpu) -print(time.time()-t) \ No newline at end of file +print(time.time() - t) diff --git a/mofapy2/run/entry_point.py b/mofapy2/run/entry_point.py index 943d3db..def0094 100644 --- a/mofapy2/run/entry_point.py +++ b/mofapy2/run/entry_point.py @@ -19,37 +19,6 @@ from mofapy2 import config -def keyboardinterrupt_saver(func): - @wraps(func) - def saver(self, *args, **kwargs): - try: - func(self, *args, **kwargs) - # Internal methods will raise TypeError when interrupted - except (KeyboardInterrupt, TypeError): - if self.train_opts["save_interrupted"]: - print("Attempting to save the model at the current iteration...") - if self.train_opts["outfile"] is not None and self.train_opts != "": - tmp_file = self.train_opts["outfile"] - tmp_file = tmp_file.rstrip(".hdf5") + "_interrupted.hdf5" - else: - tmp_file = os.path.join( - "/tmp", - "mofa_{}_interrupted.hdf5".format(strftime("%Y%m%d-%H%M%S")), - ) - self.save(outfile=tmp_file) - print( - "Saved partially trained model in {}. Exiting now.".format(tmp_file) - ) - else: - print( - "Exiting now without saving the partially trained model. To save a partially trained model, set save_interrupted in the training options to true." - ) - sys.stdout.flush() - sys.exit() - - return saver - - def keyboardinterrupt_saver(func): @wraps(func) def saver(self, *args, **kwargs): @@ -1066,7 +1035,6 @@ def set_train_options( def set_stochastic_options( self, learning_rate=1.0, forgetting_rate=0.0, batch_size=1.0, start_stochastic=1 ): - # Sanity checks if hasattr(self, "smooth_opts"): print( @@ -1113,7 +1081,6 @@ def set_smooth_options( frac_inducing=None, warping_groups=None, ): - """ Method to activate and set options for a functional MOFA model (MEFISTO). This requires to specify a covariate using set_covariates. @@ -1261,7 +1228,6 @@ def set_smooth_options( ) print("##") else: - self.smooth_opts["sparseGP"] = False # Define whether to model a group covariance structure @@ -1434,7 +1400,6 @@ def run(self): train_model(self.model) def mask_outliers(self): - Z = self.model.nodes["Z"].getExpectation() zscore_cutoff = 3 * 1.96 # z-score cutoff value_cutoff = 1 # max factor value diff --git a/mofapy2/simulate/simulate_mofa.py b/mofapy2/simulate/simulate_mofa.py index ef2bc76..dd65808 100644 --- a/mofapy2/simulate/simulate_mofa.py +++ b/mofapy2/simulate/simulate_mofa.py @@ -113,11 +113,7 @@ def simulate_data( Z = [] for g in range(G): - Z.append( - Zks[ - groupidx == g, - ] - ) + Z.append(Zks[groupidx == g,]) # simulate alpha and theta, each factor should be active in at least one view theta = 0.5 * np.ones([M, K]) diff --git a/pyproject.toml b/pyproject.toml index a279fe9..063dc91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "mofapy2" -version = "0.7.0" +version = "0.7.1" description = "Multi-omics factor analysis" authors = ['Ricard Argelaguet', 'Damien Arnol', 'Danila Bredikhin', 'Britta Velten'] license = "LGPL-3.0" @@ -14,13 +14,13 @@ homepage = "https:/biofam.github.io/MOFA2/" [tool.poetry.dependencies] python = "^3.8" -numpy = "^1.21.0" -pandas = "^1.2.0" +numpy = "^1" +pandas = "> 1" scipy = "~1" scikit-learn = "~1" h5py = "~3" -anndata = { version = "~0.8", optional = true } +anndata = { version = "> 0.8", optional = true } [tool.poetry.dev-dependencies] -pytest = "^6.2.5" -anndata = "~0.8" +pytest = "^7.4.2" +anndata = "~0.9"