Bug report [BUG] AttributeError: module 'numpy' has no attribute 'int' group_pr.to_bigwig
Hi Seppe,
Thank you so much for fixing Scenic+! I'm still having an issue with pycisTopic.
For both the human cerebellum and the pbmc tutorials, when I run:
from pycisTopic.pseudobulk_peak_calling import *
bw_paths, bed_paths = export_pseudobulk(input_data = cell_data,
variable = 'GEX_Seurat_cell_type',
sample_id_col = 'GEX_VSN_sample_id',
chromsizes = chromsizes,
bed_path = outDir + 'consensus_peak_calling/pseudobulk_bed_files/',
bigwig_path = outDir + 'consensus_peak_calling/pseudobulk_bw_files/',
path_to_fragments = fragments_dict,
n_cpu = 1,
normalize_bigwig = True,
remove_duplicates = True,
_temp_dir = tmpDir + 'ray_spill',
split_pattern = '-',
use_polars = True)
I get the following error message:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[15], line 2
1 from pycisTopic.pseudobulk_peak_calling import *
----> 2 bw_paths, bed_paths = export_pseudobulk(input_data = cell_data,
3 variable = 'GEX_Seurat_cell_type',
4 sample_id_col = 'GEX_VSN_sample_id',
5 chromsizes = chromsizes,
6 bed_path = outDir + 'consensus_peak_calling/pseudobulk_bed_files/',
7 bigwig_path = outDir + 'consensus_peak_calling/pseudobulk_bw_files/',
8 path_to_fragments = fragments_dict,
9 n_cpu = 1,
10 normalize_bigwig = True,
11 remove_duplicates = True,
12 _temp_dir = tmpDir + 'ray_spill',
13 split_pattern = '-',
14 use_polars = True)
File ~/Documents/tools/pycisTopic/pycisTopic/pseudobulk_peak_calling.py:186, in export_pseudobulk(input_data, variable, chromsizes, bed_path, bigwig_path, path_to_fragments, sample_id_col, n_cpu, normalize_bigwig, remove_duplicates, split_pattern, use_polars, **kwargs)
184 ray.shutdown()
185 else:
--> 186 [
187 export_pseudobulk_one_sample(
188 cell_data,
189 group,
190 fragments_df_dict,
191 chromsizes,
192 bigwig_path,
193 bed_path,
194 sample_id_col,
195 normalize_bigwig,
196 remove_duplicates,
197 split_pattern,
198 )
199 for group in groups
200 ]
202 return bw_paths, bed_paths
File ~/Documents/tools/pycisTopic/pycisTopic/pseudobulk_peak_calling.py:187, in <listcomp>(.0)
184 ray.shutdown()
185 else:
186 [
--> 187 export_pseudobulk_one_sample(
188 cell_data,
189 group,
190 fragments_df_dict,
191 chromsizes,
192 bigwig_path,
193 bed_path,
194 sample_id_col,
195 normalize_bigwig,
196 remove_duplicates,
197 split_pattern,
198 )
199 for group in groups
200 ]
202 return bw_paths, bed_paths
File ~/Documents/tools/pycisTopic/pycisTopic/pseudobulk_peak_calling.py:285, in export_pseudobulk_one_sample(cell_data, group, fragments_df_dict, chromsizes, bigwig_path, bed_path, sample_id_col, normalize_bigwig, remove_duplicates, split_pattern)
283 bigwig_path_group = os.path.join(bigwig_path, str(group) + ".bw")
284 if remove_duplicates:
--> 285 group_pr.to_bigwig(
286 path=bigwig_path_group,
287 chromosome_sizes=chromsizes,
288 rpm=normalize_bigwig,
289 )
290 else:
291 group_pr.to_bigwig(
292 path=bigwig_path_group,
293 chromosome_sizes=chromsizes,
294 rpm=normalize_bigwig,
295 value_col="Score",
296 )
File ~/Documents/tools/miniconda3/envs/scenicplus/lib/python3.8/site-packages/pyranges/pyranges.py:5381, in PyRanges.to_bigwig(self, path, chromosome_sizes, rpm, divide, value_col, dryrun, chain)
5378 if chromosome_sizes is None:
5379 chromosome_sizes = pr.data.chromsizes()
-> 5381 result = _to_bigwig(self, path, chromosome_sizes, rpm, divide, value_col, dryrun)
5383 if dryrun:
5384 return result
File ~/Documents/tools/miniconda3/envs/scenicplus/lib/python3.8/site-packages/pyranges/out.py:189, in _to_bigwig(self, path, chromosome_sizes, rpm, divide, value_col, dryrun)
186 sys.exit(1)
188 if not divide:
--> 189 gr = self.to_rle(rpm=rpm, strand=False, value_col=value_col).to_ranges()
190 else:
191 gr = self.to_rle(rpm=rpm, strand=False, value_col=value_col)
File ~/Documents/tools/miniconda3/envs/scenicplus/lib/python3.8/site-packages/pyranges/pyranges.py:5745, in PyRanges.to_rle(self, value_col, strand, rpm, nb_cpu)
5741 strand = self.stranded
5743 from pyranges.methods.to_rle import _to_rle
-> 5745 return _to_rle(self, value_col, strand=strand, rpm=rpm, nb_cpu=nb_cpu)
File ~/Documents/tools/miniconda3/envs/scenicplus/lib/python3.8/site-packages/pyranges/methods/to_rle.py:22, in _to_rle(ranges, value_col, strand, rpm, **kwargs)
13 _kwargs = {
14 "strand": strand,
15 "value_col": value_col,
(...)
18 }
19 } # already sparse
20 kwargs.update(_kwargs)
---> 22 result = pyrange_apply_single(coverage, ranges, **kwargs)
24 if rpm:
25 multiplier = 1e6 / len(ranges)
File ~/Documents/tools/miniconda3/envs/scenicplus/lib/python3.8/site-packages/pyranges/multithreaded.py:361, in pyrange_apply_single(function, self, **kwargs)
358 kwargs["chromosome"] = c
360 df = make_unary_sparse(kwargs, df)
--> 361 result = call_f_single(function, nparams, df, **kwargs)
362 results.append(result)
363 keys.append(c)
File ~/Documents/tools/miniconda3/envs/scenicplus/lib/python3.8/site-packages/pyranges/multithreaded.py:31, in call_f_single(f, nparams, df, **kwargs)
28 def call_f_single(f, nparams, df, **kwargs):
30 if nparams == 2:
---> 31 return f.remote(df, **kwargs)
32 else:
33 return f.remote(df)
File ~/Documents/tools/miniconda3/envs/scenicplus/lib/python3.8/site-packages/pyrle/methods.py:167, in coverage(df, **kwargs)
164 if _df.Position.dtype.name == "int32":
165 _df.Position = _df.Position.astype(np.int64)
--> 167 runs, values = _coverage(_df.Position.values, _df.Value.values)
169 return Rle(runs, values)
File ~/Documents/tools/miniconda3/envs/scenicplus/lib/python3.8/site-packages/pyrle/src/coverage.pyx:67, in pyrle.src.coverage._coverage()
File ~/Documents/tools/miniconda3/envs/scenicplus/lib/python3.8/site-packages/numpy/__init__.py:305, in __getattr__(attr)
300 warnings.warn(
301 f"In the future `np.{attr}` will be defined as the "
302 "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
304 if attr in __former_attrs__:
--> 305 raise AttributeError(__former_attrs__[attr])
307 # Importing Tester requires importing all of UnitTest which is not a
308 # cheap import Since it is mainly used in test suits, we lazy import it
309 # here to save on the order of 10 ms of import time for most users
310 #
311 # The previous way Tester was imported also had a side effect of adding
312 # the full `numpy.testing` namespace
313 if attr == 'testing':
**AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations**
I reinstalled pycisTopic and I still get the error message with the tutorials. The version of pycisTopic I have is: 1.0.2.dev21+g219225d.d20230522
Can you replicate this issue? Is there anything I can do to fix this issue?
Thank you very much in advance.
Best, Etienne
Installing a less recent version of numpy, might work.
Hi @etiennedanis
Seems to be an issue related to pyranges. What is the version of your pyranges?
For me it worked with version 0.0.127.
Best,
Seppe