This function performs FreeHiC based on contact matrix only.

FreeHiC(
  contacts,
  seqDepth = NULL,
  countScale = 1,
  noiseRate = 0,
  neighborZeroRate = 0,
  resolution = 50000L
)

Arguments

contacts

A list of contacts matrix. The list element should named by chromosome pair.

  • matrixA matrix with columns (x, y, counts).

  • data.frameA data.frame with columns (chr1, x, y, chr2, counts).

  • listA list of matrix, where the matrix has columns (x, y, counts).

where x stands for the first chromosome location, y stands for the second chromosome location and counts is the interaction counts.

seqDepth

The desired sequence depth.

countScale

The scale of counts. A number larger than 0. If both seqDepth and countScale are provided. Choose the larger one.

noiseRate

The noise rate for contact matrix. 0 - 1 scale

neighborZeroRate

The rate for neighborhood noise rate. 0 - 1 scale

resolution

The resolution used in the contacts matrix. A positive number.

Value

A list or matrix or data.frame with the same format as contacts

References

Zheng, Ye, Keles, Sunduz FreeHi-C simulates high-fidelity Hi-C data for benchmarking and data augmentation. Nature Methods 17, 37–40 (2020). doi

Examples

library(FreeHiCLite) N <- 2000 maxBinX <- maxBinY <- 2000000L maxCounts <- 10 binX <- sample(1:maxBinX, N, replace=TRUE) binY <- sample(1:maxBinY, N, replace=TRUE) counts <- sample(1:10, N, replace=TRUE) seqDepth <- 20000 countScale <- 0 noiseRate <- 0.1 neighborZeroRate <- 0 resolution <- 5000 ## Matrix version ## matrix layout as x, y, counts contacts <- matrix(0, N, 3) contacts[,1] <- binX contacts[,2] <- binY contacts[,3] <- counts res <- FreeHiC(contacts, seqDepth, countScale, noiseRate, neighborZeroRate, resolution) head(res)
#> x y counts #> [1,] 1902912 988 16 #> [2,] 1993687 1073 12 #> [3,] 1047284 1341 4 #> [4,] 922396 2227 10 #> [5,] 1647076 3340 13 #> [6,] 1673148 4468 11
## List version N2 = 3000 binX2 <- sample(1:maxBinX, N2, replace=TRUE) binY2 <- sample(1:maxBinY, N2, replace=TRUE) counts2 <- sample(1:10, N2, replace=TRUE) contacts2 <- matrix(0, N2, 3) contacts2[,1] <- binX2 contacts2[,2] <- binY2 contacts2[,3] <- counts2 contactsMap <- list('1_1' = contacts, '2_2' = contacts2) res <- FreeHiC(contactsMap, seqDepth, countScale, noiseRate, neighborZeroRate, resolution) str(res)
#> List of 2 #> $ 2_2: int [1:2715, 1:3] 1438739 1515769 226756 1285103 909010 27773 1219428 1046613 1530112 1023819 ... #> ..- attr(*, "dimnames")=List of 2 #> .. ..$ : NULL #> .. ..$ : chr [1:3] "x" "y" "counts" #> $ 1_1: int [1:1829, 1:3] 1902912 1993687 1047284 922396 1647076 1673148 934434 1914771 1043449 46432 ... #> ..- attr(*, "dimnames")=List of 2 #> .. ..$ : NULL #> .. ..$ : chr [1:3] "x" "y" "counts"
## Dataframe version chr1 <- c(rep('1', N), rep('2', N2)) chr2 <- c(rep('1', N), rep('2', N2)) contactsAll <- rbind(contacts, contacts2) contactsDf <- data.frame(chr1 = chr1, x = contactsAll[,1], chr2 = chr2, y = contactsAll[,2], counts = contactsAll[,3]) res <- FreeHiC(contactsDf, seqDepth, countScale, noiseRate, neighborZeroRate, resolution) head(res)
#> chr1 x chr2 y counts #> 1 2 1438739 2 8 3 #> 2 2 1515769 2 2134 5 #> 3 2 226756 2 2376 2 #> 4 2 1285103 2 3500 9 #> 5 2 909010 2 3950 8 #> 6 2 27773 2 4715 1