nservant / HiC-Pro

HiC-Pro: An optimized and flexible pipeline for Hi-C data processing
Other
382 stars 183 forks source link

sparseToDense.py TypeError #456

Closed esebesty closed 2 years ago

esebesty commented 3 years ago

When tring to run sparseToDense.py using the -c option, I'm getting the following error:

/apps/users/user2031/mambaforge/envs/hicpro/lib/python3.7/site-packages/iced/normalization/_ca_utils.py:9: UserWarning: The API of this module is likely to change. Use only for testing purposes
  "The API of this module is likely to change. "
/apps/users/user2031/mambaforge/envs/hicpro/lib/python3.7/site-packages/iced/io/_io_pandas.py:57: UserWarning: Attempting to guess whether counts are 0 or 1 based
  "Attempting to guess whether counts are 0 or 1 based")
chr1...
Traceback (most recent call last):
  File "/home/user2031/work/repos/bcro/bit-bio/hicpro-install/HiC-Pro/bin/utils/sparseToDense.py", line 152, in <module>
    counts_perchr[np.diag_indices_from(counts_perchr)] /= 2
TypeError: No loop matching the specified signature and casting was found for ufunc true_divide

This seems to be a numpy issue.

If I change line 152 of the script to this:

counts_perchr[np.diag_indices_from(counts_perchr)] = counts_perchr[np.diag_indices_from(counts_perchr)] / 2

everything seems to be ok.

nservant commented 3 years ago

Hi Thanks for the comment. Which python/numpy versions are you using please ? N

esebesty commented 3 years ago

Using numpy 1.18.1, the one specified in environment.yml.

poflawless commented 2 years ago

Hello @esebesty,

Did you figure out how to convert hicPro ICE matrix to topDom input n*(n+3) matrix? I'm still struggling with it.

esebesty commented 2 years ago

Yes, something like this is accepted by TopDom (using the version available here):

Example code ```r library("data.table") library("readr") library("HiCcompare") library("TopDom") icematrix <- fread(file = "hicpro.icematrix", header = FALSE) icematrix <- icematrix %>% as.data.frame() bedfile <- read_delim("hicpro.bed", "\t", escape_double = FALSE, col_names = FALSE, trim_ws = TRUE) bedfile <- bedfile[, c(4, 1:3)] colnames(bedfile) <- c("id", "chr", "from.coord", "to.coord") bedfile <- bedfile %>% mutate(id = as.integer(id)) %>% mutate(from.coord = as.integer(from.coord)) %>% mutate(to.coord = as.integer(to.coord)) %>% as.data.frame() icematrix_m <- sparse2full(icematrix) icedata <- structure(list(bins = bedfile, counts = unname(icematrix_m)), class = "TopDomData") topdom <- TopDom(icedata, window.size = 5, debug = TRUE) ```

However, I gave up on TopDom, as using the correct data structure still produced errors, and there is zero support from the original developers, see here.

esebesty commented 2 years ago

BTW the original sparseToDense.py TypeError seems to be resolved now.

nservant commented 2 years ago

Thanks for the feedbacks @esebesty