File: methods-FastqFileList.R

package info (click to toggle)
r-bioc-edaseq 2.24.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 408 kB
  • sloc: sh: 13; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 1,256 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
setMethod(
          f = "plotQuality",
          signature = "FastqFileList", 
          definition = function(x, ..., col=rainbow(length(x)))
          {
            quals <- lapply(x, function(x) {
              fq <- quality(readFastq(x))
              wd <- unique(width(fq))
              if (1L != length(wd)) {
              minwd <- min(wd)
              message(paste("reducing width to trailing ", minwd,
                      "\n  path: ", path(x)))
              fq <- narrow(fq, start=1, end=minwd)
              }
              colMeans(as(fq, "matrix"))
            })
            wd <- max(sapply(quals, length))
            min <- min(sapply(quals, min))
            max <- max(sapply(quals, max))
            plot(quals[[1]], xlim=c(1, wd), ylim=c(min, max), type="b",
                 ..., xlab="Cycle", ylab="Quality", col=col[1])
            for (i in 1 + seq_along(quals[-1]))
              lines(quals[[i]], type="l", col=col[i])
            invisible()
          })


setMethod(
          f = "barplot",
          signature = signature(height="FastqFileList"),
          definition = function(height,...) {
            x <- lapply(height,function(x) length(readFastq(x)))
            barplot(unlist(x),...)
          }
          )