dozmorovlab / HiCcompare

Joint normalization of two Hi-C matrices, visualization and detection of differential chromatin interactions. See multiHiCcompare for the analysis of multiple Hi-C matrices
https://dozmorovlab.github.io/HiCcompare/
Other
19 stars 3 forks source link

object 'temp' not found #20

Closed sarah872 closed 3 years ago

sarah872 commented 3 years ago

Hi, I cannot read in a matrix from cooler dump --join into HiCcompare:

> cool_mat = read.table("matrix.txt")
> sparse_mats = HiCcompare::cooler2sparse(cool_mat)
Error in HiCcompare::cooler2sparse(cool_mat) : object 'temp' not found
mdozmorov commented 3 years ago

That's unusual. Can you provide a subset of matrix.txt that can reproduce the error? I'll also check my .cool files, but your example will help to speed it up.

sarah872 commented 3 years ago

the data.table package is apparently not loaded.

As I have only one chromosome, I can easily add the function directly to my script:

library(data.table)
library(SpectralTAD)

cool_mat = read.table("bwa.txt", header=F, col.names = c("chr1", "start1", "end1", "chr2", "start2", "end2", "IF"))
#Convert to sparse 3-column matrix using cooler2sparse from HiCcompare
#sparse_mats = HiCcompare::cooler2sparse(cool_mat)
cooler <- as.data.table(cool_mat)
colnames(cooler) <- c("chr1", "start1", "end1", "chr2", "start2", 
                      "end2", "IF")
if (is.factor(cooler$chr1)) {
  chroms <- levels(cooler$chr1)
}
if (is.character(cooler$chr1)) {
  chroms <- unique(cooler$chr1)
}
temp <- cooler[, c("start1", "start2", "IF"), with = FALSE]
colnames(temp) <- c("region1", "region2", "IF")
sparse_mats <- subset(temp, IF != 0)
mdozmorov commented 3 years ago

Yes, this is the problem. I'll add data.table as a required dependency. In a meantime, please, load it separately.