Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binarize function error #575

Open
apal6 opened this issue Sep 13, 2024 · 0 comments
Open

binarize function error #575

apal6 opened this issue Sep 13, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@apal6
Copy link

apal6 commented Sep 13, 2024

Hi,

I have been trying to look for tutorials to do the downstream analysis from the outputs i got from the pyscenic. I have three files:
regulons.csv
expr_mat.adjacencies.tsv
auc_mtx.csv
and exprMat_T.tsv (expression matrix)
I was trying to run the binarize function but it gave this error-

auc_matrix = pd.read_csv("/scratch/users/apal6/scenic/auc_mtx.csv") auc_mtx_bi = binarize(auc_matrix)
error:
`The above exception was the direct cause of the following exception:

UFuncTypeError Traceback (most recent call last)
/tmp/ipykernel_5764/2213639410.py in
----> 1 auc_mtx_bi = binarize(auc_matrix)

~/.local/lib/python3.9/site-packages/pyscenic/binarization.py in binarize(auc_mtx, threshold_overides, seed, num_workers)
92 return pd.Series(index=auc_mtx.columns, data=thrs)
93
---> 94 thresholds = derive_thresholds(auc_mtx)
95 if threshold_overides is not None:
96 thresholds[list(threshold_overides.keys())] = list(threshold_overides.values())

~/.local/lib/python3.9/site-packages/pyscenic/binarization.py in derive_thresholds(auc_mtx, seed)
87 def derive_thresholds(auc_mtx, seed=seed):
88 with Pool(processes=num_workers) as p:
---> 89 thrs = p.starmap(
90 derive_threshold, [(auc_mtx, c, seed) for c in auc_mtx.columns]
91 )

/share/software/user/open/python/3.9.0/lib/python3.9/multiprocessing/pool.py in starmap(self, func, iterable, chunksize)
370 func and (a, b) becomes func(a, b).
371 '''
--> 372 return self._map_async(func, iterable, starmapstar, chunksize).get()
373
374 def starmap_async(self, func, iterable, chunksize=None, callback=None,

/share/software/user/open/python/3.9.0/lib/python3.9/multiprocessing/pool.py in get(self, timeout)
769 return self._value
770 else:
--> 771 raise self._value
772
773 def _set(self, i, obj):

/share/software/user/open/python/3.9.0/lib/python3.9/multiprocessing/pool.py in worker()
123 job, i, func, args, kwds = task
124 try:
--> 125 result = (True, func(*args, **kwds))
126 except Exception as e:
127 if wrap_exception and func is not _helper_reraises_exception:

/share/software/user/open/python/3.9.0/lib/python3.9/multiprocessing/pool.py in starmapstar()
49
50 def starmapstar(args):
---> 51 return list(itertools.starmap(args[0], args[1]))
52
53 #

~/.local/lib/python3.9/site-packages/pyscenic/binarization.py in derive_threshold()
54 return gmm2.bic(X) <= gmm1.bic(X)
55
---> 56 if not isbimodal(data, method):
57 # For a unimodal distribution the threshold is set as mean plus two standard deviations.
58 return data.mean() + 2.0 * data.std()

~/.local/lib/python3.9/site-packages/pyscenic/binarization.py in isbimodal()
41 if method == "hdt":
42 # Use Hartigan's dip statistic to decide if distribution deviates from unimodality.
---> 43 _, pval, _ = diptst(np.msort(data))
44 return (pval is not None) and (pval <= 0.05)
45 else:

~/.local/lib/python3.9/site-packages/pyscenic/diptest.py in diptst()
52 """diptest with pval"""
53 # sample dip
---> 54 d, (_, idxs, left, _, right, _) = dip_fn(dat, is_hist)
55
56 # simulate from null uniform

~/.local/lib/python3.9/site-packages/pyscenic/diptest.py in dip_fn()
100
101 while True:
--> 102 left_part, left_touchpoints = gcm(work_cdf - work_histogram, work_idxs)
103 right_part, right_touchpoints = lcm(work_cdf, work_idxs)
104

~/.local/lib/python3.9/site-packages/pyscenic/diptest.py in gcm()
28 touchpoints = [0]
29 while len(work_cdf) > 1:
---> 30 distances = work_idxs[1:] - work_idxs[0]
31 slopes = (work_cdf[1:] - work_cdf[0]) / distances
32 minslope = slopes.min()

UFuncTypeError: ufunc 'subtract' did not contain a loop with signature matching types (dtype('<U20'), dtype('<U20')) -> None
`

It looks like something is clashing due to mismatch in a NumPy operation. I wonder if my inputs were processed in a way that pyscenic isnt optimised for? Any help? I would also appreciate if you could direct me to a tutorial to perform downstream analysis usign these outputs?

Thank you,
Aastha

@apal6 apal6 added the bug Something isn't working label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant