File: show-methods.R

package info (click to toggle)
r-bioc-dada2 1.34.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 3,016 kB
  • sloc: cpp: 3,096; makefile: 5
file content (95 lines) | stat: -rw-r--r-- 3,269 bytes parent folder | download | duplicates (3)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
############################################################################
#' method extensions to show for dada2 objects.
#'
#' See the general documentation of \code{\link[methods]{show}} method for
#' expected behavior. 
#'
#' @seealso \code{\link[methods]{show}}
#' 
#' @inheritParams methods::show
#' @return NULL.
#' @importFrom stats median
#' @rdname show-methods
#' @include allClasses.R
#' # examples
setMethod("show", "derep", function(object){
  cat("derep-class: R object describing dereplicated sequencing reads", fill=TRUE)
  if( length(object$uniques) > 0 ){
    cat("$uniques:", sum(object$uniques, na.rm = TRUE), "reads in",
        length(names(object$uniques)), "unique sequences\n")
    seqlens <- nchar(names(object$uniques))
    cat("  Sequence lengths: min=", min(seqlens), ", median=", median(seqlens),
        ", max=", max(seqlens), sep="", fill=TRUE)
  }
  if( length(object$quals) > 0 & inherits(object$quals, "matrix")){
    cat("$quals: Quality matrix dimension: ", dim(object$quals), fill = TRUE)
    quals <- as.vector(object$quals)
    cat("  Consensus quality scores: min=", min(quals, na.rm=TRUE), ", median=", median(quals, na.rm=TRUE),
        ", max=", max(quals, na.rm=TRUE), sep="", fill=TRUE)
  }
  if( length(object$map) > 0 ){
    cat("$map: Map from reads to unique sequences: ", object$map[1L:5L], "...", fill = TRUE)
  }
})

#' @inheritParams methods::show
#' @rdname show-methods
#' @include allClasses.R
setMethod("show", "dada", function(object){
  cat("dada-class: object describing DADA2 denoising results", fill=TRUE)
  if( length(object$denoised) > 0 && length(object$map) > 0 ) {
    cat(length(object$denoised), "sequence variants were inferred from", length(object$map), "input unique sequences.", fill=TRUE)
  }
  cat("Key parameters: OMEGA_A = ", object$opts$OMEGA_A,
      ", OMEGA_C = ", object$opts$OMEGA_C,
      ", BAND_SIZE = ", object$opts$BAND_SIZE, 
      sep="", fill=TRUE)
})

############################################################################
#' Deactivate renaming of derep-class objects.
#'
#' @inheritParams base::`names<-`
#' @return NULL.
#' @include allClasses.R
#'
setMethod("names<-", "derep", function(x, value){
  warning("derep-class objects cannot be renamed.")
  return(x)
})

############################################################################
#' Deactivate renaming of dada-class objects.
#'
#' @inheritParams base::`names<-`
#' @return NULL.
#' @include allClasses.R
#' 
setMethod("names<-", "dada", function(x, value){
  warning("dada-class objects cannot be renamed.")
  return(x)
})

############################################################################
#' Change concatenation of derep-class objects to list construction.
#'
#' @inheritParams base::c
#' @param x A derep-class object
#' @return list.
#' @include allClasses.R
#'
setMethod("c", signature("derep"), function(x,...,recursive=FALSE){
  list(x,...)
})

############################################################################
#' Change concatenation of dada-class objects to list construction.
#'
#' @inheritParams base::c
#' @param x A dada-class object
#' @return list.
#' @include allClasses.R
#'
setMethod("c", signature("dada"), function(x,...,recursive=FALSE){
  list(x,...)
})