Skip to contents

Get the number of positive/negative reads of all windows from read information obtained from scanBam function

Usage

getStrandFromReadInfo(
  readInfo,
  winWidth = 1000L,
  winStep = 100L,
  readProp = 0.5,
  subset = NULL
)

Arguments

readInfo

a list contains read information returned by scanBam function when read a bam file.

winWidth

the length of the sliding window, 1000 by default.

winStep

the step length to sliding the window, 100 by default.

readProp

A read is considered to be included in a window if at least readProp of it is in the window. Specified as a proportion. 0.5 by default.

subset

an integer vector specifying the subset of reads to consider

Value

a DataFrame object containing the number of positive/negative reads and coverage of each window sliding .

Examples

library(Rsamtools)
file <- system.file('extdata','s2.sorted.bam',package = 'strandCheckR')
readInfo <- scanBam(file, param =
ScanBamParam(what = c("pos","cigar","strand")))
getStrandFromReadInfo(readInfo[[1]],1000,100,0.5)
#> DataFrame with 1913 rows and 10 columns
#>       Type   Seq     Start   End NbPos NbNeg CovPos CovNeg MaxCoverage  File
#>      <Rle> <Rle> <integer> <Rle> <Rle> <Rle>  <Rle>  <Rle>       <Rle> <Rle>
#> 1                    70297     0     0     1      0     19           1      
#> 2                    70298     0     0     1      0     19           1      
#> 3                    70299     0     0     1      0     19           1      
#> 4                    70300     0     0     1      0     19           1      
#> 5                    70301     0     0     1      0     19           1      
#> ...    ...   ...       ...   ...   ...   ...    ...    ...         ...   ...
#> 1909                 73986     0    46    34   2241   1668          13      
#> 1910                 73987     0    46    34   2241   1668          13      
#> 1911                 73988     0    41    32   2046   1568          13      
#> 1912                 73989     0    48    31   2500   1681          25      
#> 1913                 73990     0    52    35   2581   1728          25