robinweide / GENOVA

GENome Organisation Visual Analytics
GNU General Public License v3.0
69 stars 15 forks source link

Unable to compare compartment_score with .hic files loaded #261

Open bharaths24 opened 3 years ago

bharaths24 commented 3 years ago

Hi, I had contacts loaded from a juicer .hic files of different conditions. Upon using compartment_score() for the 2 conditions I get the following error:

Error: Indices of experiment(s) 2 are not equal to indices of experiment 1

I see that the IDs and MAT entries in the 2 files are not of the same number. I am not sure why this would be so and am not sure how to go ahead. Any ideas as to how to proceed would be much appreciated. Thank you very much

teunbrand commented 3 years ago

You can use sync_indices(list(exp1, exp2)) to match up the indices between multiple experiments at the same resolution.

bharaths24 commented 3 years ago

Hi, Thank you for the reply. Upon using the synched file for compartment_score in the following way

CS_out = compartment_score(list(synched)

I get the following error:

Error in if (attr(explist[[1]], "resolution") <= 19999) { : argument is of length zero

Thank you

teunbrand commented 3 years ago

If synched <- sync_indices(list(exp1, exp2)) then synced is already a list of experiments. The first argument in comparment_score() accepts an experiment or list of experiments, but not a list of a list of experiments (which I think you might be doing). Here is my attempt at reproducing the problem:

library(GENOVA)
library(data.table)

exp1 <- exp2 <- get_test_data("150k")

# Make exp2 out of sync by making a gap
expnames(exp2) <- "test2"
exp2$IDX$V4[500:664] <- exp2$IDX$V4[500:664] + 5
exp2$MAT <- exp2$MAT[V1 >= 500, V1 := V1 + 5]
exp2$MAT <- exp2$MAT[V2 >= 500, V2 := V2 + 5]
exp2$IDX$V3 <- exp2$IDX$V3 - 1

# Reproduce error
cs <- compartment_score(list(exp1, exp2))
#> Error: Indices of experiment(s) 2 are not equal to indices of experiment 1

# Synchronise indices
synced <- sync_indices(list(exp1, exp2))

# Error fixed
cs <- compartment_score(synced)
print(cs)
#> A GENOVA 'CS_discovery' object involving the following 2 experiment(s):
#> 'Hap1_WT_150k', 'test2' at a resolution of 150 kb.
#> 
#> Contains the following slots:
#>  - compart_scores:   A 664 x 6 data.frame containing unsigned compartment scores.
#> 
#> 2 centromeres spanning a total of 169 bins have been ignored.

Created on 2021-05-29 by the reprex package (v1.0.0)