Skip to content

Commit

Permalink
bugs fixed save_models
Browse files Browse the repository at this point in the history
  • Loading branch information
ploy-np committed Aug 30, 2020
1 parent 763a4b0 commit 552e816
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions xpore/diffmod/gmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ def _update(self, children):
prob = 1./(1.+np.exp(np.clip(ln_rho_diff, -500, 500))) # N,1 => N
self.params['prob'] = np.stack([prob, 1-prob], axis=-1)
self.params['ln_prob'] = ln_rho - scipy.special.logsumexp(ln_rho, axis=-1)[..., newaxis] # N,K



class Dirichlet(object):
Expand Down
4 changes: 2 additions & 2 deletions xpore/diffmod/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def save_result_table(table, out_filepath):
out_file.close()


def save_models(models, model_filepath): # per gene/transcript
def save_models_to_hdf5(models, model_filepath): # per gene/transcript
"""
Save model parameters.
Expand Down Expand Up @@ -124,7 +124,7 @@ def save_models(models, model_filepath): # per gene/transcript
model_file[idx][position].create_group('nodes') # ['x','y','z','w','mu_tau'] => store only their params
for node_name in model.nodes:
model_file[idx][position]['nodes'].create_group(node_name)
if model.nodes[node_name].data is not None: # To make it optional.
if model.nodes[node_name].data is not None: # Todo: make it optional.
value = model.nodes[node_name].data
if node_name in ['y_run_names','y_condition_names']:
value = [val.encode('UTF-8') for val in value]
Expand Down
3 changes: 2 additions & 1 deletion xpore/scripts/diffmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def execute(idx, data_dict, data_info, method, criteria, model_kmer, prior_param

if save_models & (len(models)>0): #todo:
print(out_paths['model_filepath'],idx)
io.save_models(models,out_paths['model_filepath'])
io.save_models_to_hdf5(models,out_paths['model_filepath'])

if len(models)>0:
# Generating the result table.
table = io.generate_result_table(models,data_info)
Expand Down

0 comments on commit 552e816

Please sign in to comment.