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

Skip Loess normalization #21

Closed sarah872 closed 4 years ago

sarah872 commented 4 years ago

Is there a way to skip the loess normalization? I want to compare two already normalized matrices (with the same normalization method), and would like to compare.

Currently, this is the code I am running:

chr.table <- create.hic.table(bowtie2B, bwamemB, chr = 'chr1')
hic.table <- hic_loess(chr.table, Plot = TRUE) # normalization
filter_params(chr.table)
hic.table <- hic_compare(chr.table, A.min = 15, adjust.dist = TRUE, p.method = 'fdr', Plot = TRUE)

(I would like to skip this step because I am getting the following error:)

Error in .loess.as(x = hic.table$D, y = hic.table$M, degree = degree,  : 
  not enough observations! 
mdozmorov commented 4 years ago

The error is likely due to high sparsity in Hi-C matrices. Try to use a lower resolution, e.g., if your data is 40kb, try 100kb data.

And yes, you can skip Loess normalization. I won't recommend it, see our Figure 3, but in principle you can skip the loess normalization step.

sarah872 commented 4 years ago

Thank you! Could you give me the lines of code for that? Seems I couldn't find it in the vignette. Also, if I am comparing two matrices, do they need to have the same resolution, ie. same number of bins?

mdozmorov commented 4 years ago

If you follow the vignette, you will come to the differential analysis of normalized data:

hic.table <- hic_compare(hic.table, A.min = 15, adjust.dist = TRUE, p.method = 'fdr', Plot = TRUE)

You can as well use unnormalized data:

hic.table <- hic_compare(chr22.table, A.min = 15, adjust.dist = TRUE, p.method = 'fdr', Plot = TRUE)

And yes, the data must be the same resolution.

sarah872 commented 4 years ago

Ok so here I am failing, even with the test data

library(HiCcompare)
data("HMEC.chr22")
data("NHEK.chr22")
chr22.table = create.hic.table(HMEC.chr22, NHEK.chr22, chr = 'chr22')
hic.table <- hic_compare(chr22.table, A.min = 15, adjust.dist = TRUE, p.method = 'fdr', Plot = TRUE)
mdozmorov commented 4 years ago

I take it back - you need to do loess normalization. It adds additional columns used for differential analysis. Back to your original error, try to use a lower resolution of Hi-C matrices.