-
Notifications
You must be signed in to change notification settings - Fork 1
/
AggrHiCExperiment-methods.R
68 lines (51 loc) · 2.14 KB
/
AggrHiCExperiment-methods.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#' @name AggrHiCExperiment
#'
#' @param x,object A \code{AggrHiCExperiment} object.
#' @param name The name/index of slices to extract.
#'
#' @include AggrHiCExperiment-class.R
#' @include HiCExperiment-methods.R
NULL
#' @export
#' @rdname AggrHiCExperiment
setMethod("slices", signature(x = "AggrHiCExperiment", name = "missing"), function(x) x@slices)
#' @export
#' @rdname AggrHiCExperiment
setMethod("slices", signature(x = "AggrHiCExperiment", name = "character"), function(x, name) {
if (!name %in% names(slices(x))) {
stop(paste0(name, ' not in slices.'))
}
return(x@slices[[name]])
})
#' @export
#' @rdname AggrHiCExperiment
setMethod("slices", signature(x = "AggrHiCExperiment", name = "numeric"), function(x, name) {
if (name > length(slices(x))) {
stop(paste0('Only ', length(slices(x)), ' slices in x.'))
}
return(x@slices[[name]])
})
#' @export
#' @rdname AggrHiCExperiment
setMethod("show", signature("AggrHiCExperiment"), function(object) {
ntargets <- length(topologicalFeatures(object, 'targets'))
cat(paste0('`AggrHiCExperiment` object over ', ntargets, ' targets'), '\n')
cat('-------\n')
cat(paste0('fileName: \"', fileName(object), '\"'), '\n')
cat(paste0('focus: ', ntargets, ' targets'), '\n')
## Resolutions
S4Vectors::coolcat("resolutions(%d): %s\n", resolutions(object))
cat(paste0('active resolution: ', resolution(object)), '\n')
## Interactions
cat(paste0('interactions: ', length(interactions(object))), '\n')
## Scores
cat(paste0('scores(', length(scores(object)), '): ', paste(names(scores(object)), collapse = " ")), '\n')
## Slices
cat(paste0('slices(', length(slices(object)), '): ', paste(names(slices(object)), collapse = " ")), '\n')
## topologicalFeatures
cat(paste0('topologicalFeatures: ', paste(paste0(names(topologicalFeatures(object)), "(", lengths(topologicalFeatures(object)), ")"), collapse = " ")), '\n')
## Pairs
cat(paste0('pairsFile: ', ifelse(is.null(pairsFile(object)), "N/A", pairsFile(object))), '\n')
## Metadata
S4Vectors::coolcat("metadata(%d): %s\n", names(S4Vectors::metadata(object)))
})