Skip to content

Commit

Permalink
Merge pull request #48 from yuukiiwa/gtf
Browse files Browse the repository at this point in the history
gtf option, fastdataprep, and dataprep intermediate file removal
  • Loading branch information
ploy-np committed Feb 9, 2021
2 parents 07bf790 + 011eaac commit 4fa705c
Show file tree
Hide file tree
Showing 7 changed files with 276 additions and 225 deletions.
Empty file added gtf
Empty file.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
'scipy>=1.4.1',
'PyYAML',
'h5py>=2.10.0',
'pyensembl>=1.8.5'
'pyensembl>=1.8.5',
'ujson>=4.0.1'
],
python_requires=">=3.8",
entry_points={'console_scripts': ["xpore-dataprep={}.scripts.dataprep:main".format(__pkg_name__),
Expand Down
2 changes: 1 addition & 1 deletion xpore/diffmod/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_method(self):

method.setdefault('name', 'gmm')
method.setdefault('max_iters', 500)
method.setdefault('stopping_criteria', 0.0001)
method.setdefault('stopping_criteria', 0.00001)
method.setdefault('compute_elbo', True)
method.setdefault('verbose', False)
method.setdefault('update', ['z','y','w','mu_tau'])
Expand Down
481 changes: 261 additions & 220 deletions xpore/scripts/dataprep.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions xpore/scripts/diffmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pandas
import os
import multiprocessing
import json
import ujson
from collections import defaultdict
import csv

Expand Down Expand Up @@ -187,7 +187,7 @@ def main():
json_str = f_data[run_name].read(pos_end-pos_start)
# print(json_str[:50])
# json_str = '{%s}' %json_str # used for old dataprep
data_dict[(condition_name,run_name)] = json.loads(json_str) # A data dict for each gene.
data_dict[(condition_name,run_name)] = ujson.loads(json_str) # A data dict for each gene.

# tmp
out_paths['model_filepath'] = os.path.join(paths['models'],'%s.hdf5' %idx)
Expand Down
3 changes: 3 additions & 0 deletions xpore/scripts/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
def close(self):
self._handle.close()

def readline(self):
self._handle.readline()

def __iter__(self):
return self

Expand Down
8 changes: 7 additions & 1 deletion xpore/utils/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ def z_test(y1, y2, n1, n2):
def calc_prob_overlapping(means, variances):
sigma1, sigma2 = np.sqrt(variances)
mu1, mu2 = means
return NormalDist(mu=mu1, sigma=sigma1).overlap(NormalDist(mu=mu2, sigma=sigma2))
### the bug causing entry had sigma1 == sigma2 and mu1 == mu2
#print("sigma1: ",sigma1,"sigma2: ",sigma2)
#print("mu1: ",mu1,"mu2: ",mu2)
if sigma1 != sigma2 and mu1 != mu2:
return NormalDist(mu=mu1, sigma=sigma1).overlap(NormalDist(mu=mu2, sigma=sigma2))
else:
return np.nan,[np.nan,np.nan,np.nan,np.nan]

class NormalDist(object):
"Modified from the library statistics.py (Authors)(https://github.com/python/cpython/blob/3.8/Lib/statistics.py) which is under GPL-compatible license."
Expand Down

0 comments on commit 4fa705c

Please sign in to comment.