
R version 3.5.0 Patched (2018-04-30 r74679) -- "Joy in Playing"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> # Tests for zero-inputs into various diffHic functions.
> 
> suppressWarnings(suppressPackageStartupMessages(require(diffHic)))
> 
> # Testing what happens with an empty input file.
> 
> f.out <- "empty.h5"
> param <- pairParam(GRanges("chrA", IRanges(1:5, 1:5)))
> savePairs(data.frame(anchor1.id=integer(0), anchor2.id=integer(0)), file=f.out, param=param)
> 
> loadChromos(f.out) # While we're here, let's see what happens.
[1] anchor1 anchor2
<0 rows> (or 0-length row.names)
> 
> squareCounts(f.out, param)
class: InteractionSet 
dim: 0 1 
metadata(2): param width
assays(1): counts
rownames: NULL
rowData names(0):
colnames: NULL
colData names(1): totals
type: ReverseStrictGInteractions
regions: 1
> 
> marginCounts(f.out, param)
class: RangedSummarizedExperiment 
dim: 1 1 
metadata(1): param
assays(1): counts
rownames: NULL
rowData names(1): nfrags
colnames: NULL
colData names(1): totals
> 
> totalCounts(f.out, param)
[1] 0
> 
> connectCounts(f.out, param, GRanges("chrA", IRanges(1, 4)))
class: InteractionSet 
dim: 0 1 
metadata(1): param
assays(1): counts
rownames: NULL
rowData names(0):
colnames: NULL
colData names(1): totals
type: ReverseStrictGInteractions
regions: 1
> 
> extractPatch(f.out, param, GRanges("chrA", IRanges(1, 4)), width=10)
class: InteractionSet 
dim: 0 1 
metadata(3): param width flipped
assays(1): counts
rownames: NULL
rowData names(0):
colnames: NULL
colData names(0):
type: ReverseStrictGInteractions
regions: 1
> 
> unlink(f.out)
> 
> # Testing with an empty InteractionSet.
> 
> ghost <- InteractionSet(list(counts=matrix(0, nrow=0, ncol=1)), 
+     GInteractions(integer(0), integer(0), regions=GRanges("chrA", IRanges(1:5, 1:5)), mode="reverse"),
+     colData=DataFrame(totals=1e6))
> 
> getArea(ghost)
numeric(0)
> getArea(ghost, bp=TRUE)
numeric(0)
> 
> filterDirect(ghost)
$abundances
numeric(0)

$threshold
[1] 0.9999942

Warning message:
In .getInterThreshold(all.chrs, ave.ab[is.inter], empty = empty.ab) :
  insufficient inter-chromosomal pairs for reliable threshold estimation
> filterDirect(ghost, reference=ghost)
$abundances
numeric(0)

$threshold
[1] 0.9999942

$ref
$ref$abundances
numeric(0)

$ref$threshold
[1] 0.9999942


Warning message:
In .getInterThreshold(all.chrs, ave.ab[is.inter], empty = empty.ab) :
  insufficient inter-chromosomal pairs for reliable threshold estimation
> 
> filterTrended(ghost)
$abundances
numeric(0)

$threshold
logical(0)

$log.distance
numeric(0)

Warning message:
In .trended_filter(data, span = span, prior.count = prior.count,  :
  too many missing regions in the intra-chromosomal interaction space to fill in
> try(filterTrended(ghost, reference=ghost)) # This will fail, as interpolation is impossible.
Error in approx(x = ref$log.distance, y = ref$threshold, xout = actual.dist,  : 
  need at least two non-NA values to interpolate
In addition: Warning message:
In .trended_filter(reference, span = span, prior.count = prior.count,  :
  too many missing regions in the intra-chromosomal interaction space to fill in
> 
> filterPeaks(ghost, integer(0))
logical(0)
> 
> enrichedPairs(ghost)
class: InteractionSet 
dim: 0 1 
metadata(0):
assays(5): counts quadrant vertical horizontal surrounding
rownames: NULL
rowData names(4): N.quadrant N.vertical N.horizontal N.surrounding
colnames: NULL
colData names(1): totals
type: ReverseStrictGInteractions
regions: 5
> 
> try(compartmentalize(ghost)) # This will fail, as interpolation is impossible.
Error in approxfun(x = trended$log.distance, y = trended$threshold, rule = 2) : 
  need at least two non-NA values to interpolate
In addition: Warning message:
In .trended_filter(data, span = span, prior.count = prior.count,  :
  too many missing regions in the intra-chromosomal interaction space to fill in
> try(compartmentalize(ghost, dist.correct=FALSE)) # This will also fail, due to non-unique k-means.
Error in kmeans(mat, centers = centers, ...) : 
  more cluster centers than distinct data points.
> 
> correctedContact(ghost)
$truth
numeric(0)

$bias
[1] NA NA NA NA NA

$max
 [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[39] 0 0 0 0 0 0 0 0 0 0 0 0

> 
> ghost.ranges <- SummarizedExperiment(matrix(0, 0, 1), GRanges(), colData=DataFrame(totals=1e6))
> try(normalizeCNV(ghost, ghost.ranges)) # locfit isn't as robust as loessFit
Error in locfit(i.fc ~ cov.fun, maxk = maxk, ..., lfproc = locfit.robust) : 
  fewer than one row in the data
> ghost.ranges$totals <- NULL
> try(normalizeCNV(ghost, ghost.ranges)) # spits the dummy when totals are not the same.
Error in normalizeCNV(ghost, ghost.ranges) : 
  'totals' should be non-NULL for 'data' and 'margins'
> 
> matchMargins(ghost, ghost.ranges)
[1] anchor1 anchor2
<0 rows> (or 0-length row.names)
> 
> asDGEList(ghost)
An object of class "DGEList"
$counts
     Sample1

$samples
        group lib.size norm.factors
Sample1     1    1e+06            1

> 
> diClusters(ghost, data.frame(PValue=integer(0), logFC=numeric(0)), target=0.05, cluster.args=list(tol=1))
$indices
$indices[[1]]
integer(0)


$interactions
ReverseStrictGInteractions object with 0 interactions and 0 metadata columns:
   seqnames1   ranges1     seqnames2   ranges2
       <Rle> <IRanges>         <Rle> <IRanges>
  -------
  regions: 0 ranges and 0 metadata columns
  seqinfo: 1 sequence from an unspecified genome; no seqlengths

$FDR
[1] 0

> 
> annotatePairs(ghost, indices=integer(0), regions=GRanges())
$anchor1
character(0)

$anchor2
character(0)

> 
> proc.time()
   user  system elapsed 
  7.367   0.188   7.553 
