bamファイルがpaired end かsingle end なのかを調べる

Rsamtools を使った判定法

> packageVersion("Rsamtools")
[1] ‘1.20.5’
library(Rsamtools)

# ファイルのPATHを指定
fl <- system.file("extdata", "ex1.bam", package="Rsamtools")

> quickBamFlagSummary(fl)
                                group |    nb of |    nb of | mean / max
                                   of |  records |   unique | records per
                              records | in group |   QNAMEs | unique QNAME
All records........................ A |     3307 |     1699 | 1.95 / 2
  o template has single segment.... S |        0 |        0 |   NA / NA
  o template has multiple segments. M |     3307 |     1699 | 1.95 / 2
      - first segment.............. F |     1654 |     1654 |    1 / 1
      - last segment............... L |     1653 |     1653 |    1 / 1
      - other segment.............. O |        0 |        0 |   NA / NA

Note that (S, M) is a partitioning of A, and (F, L, O) is a partitioning of M.
Indentation reflects this.

Details for group M:
  o record is mapped.............. M1 |     3271 |     1699 | 1.93 / 2
      - primary alignment......... M2 |     3271 |     1699 | 1.93 / 2
      - secondary alignment....... M3 |        0 |        0 |   NA / NA
  o record is unmapped............ M4 |       36 |       36 |    1 / 1

Details for group F:
  o record is mapped.............. F1 |     1641 |     1641 |    1 / 1
      - primary alignment......... F2 |     1641 |     1641 |    1 / 1
      - secondary alignment....... F3 |        0 |        0 |   NA / NA
  o record is unmapped............ F4 |       13 |       13 |    1 / 1

Details for group L:
  o record is mapped.............. L1 |     1630 |     1630 |    1 / 1
      - primary alignment......... L2 |     1630 |     1630 |    1 / 1
      - secondary alignment....... L3 |        0 |        0 |   NA / NA
  o record is unmapped............ L4 |       23 |       23 |    1 / 1

single segmentだけ:シングルエンド multiple segmentだけ:ペアエンド

とりあえず知りたい

testPairedEndBam(fl)
[1] TRUE