sortByRead1: Sort GRanges object with read pairs R1 and R2 by start of R1

View source: R/alignment-utils.R

sortByRead1R Documentation

Sort GRanges object with read pairs R1 and R2 by start of R1

Description

In order to plot the read pairs as position versus read pair index, information on the mates needs to be kept intact and the visualization is more clear if the reads are sorted by the first read in the pair. This function turns the read tag in the 'id' field of the GRanges object to an ordered factor. The levels of the factor are determined by the start position of the first read (R1) in the pair.

Usage

sortByRead1(gr)

Arguments

gr

a GRanges object instantiated from a GAlignmentPairs

Value

a GRanges object

Examples

  library(svbams)
  library(TxDb.Hsapiens.UCSC.hg19.refGene)
  region <- GRanges("chr15", IRanges(63201003, 63209243))
  si <- seqinfo(TxDb.Hsapiens.UCSC.hg19.refGene)
  seqinfo(region) <- si["chr15", ]

  path <-system.file("extdata", package="svbams")
  bampath <- list.files(path, pattern="cgov44t_revised.bam$",
                        full.names=TRUE)

  iparams <- improperAlignmentParams(mapqFilter=30)
  pparams <- properAlignmentParams(mapqFilter=30)
  ## Not run: 
    irp <- getImproperAlignmentPairs(bampath,
                                     iparams, build="hg19")
    g.irp <- ga2gr(irp, is.improper=TRUE)
    prp <- getProperAlignmentPairs(bampath,
                                   pparams, build="hg19")
    g.prp <- ga2gr(prp, is.improper=FALSE)
    gr <- c(g.irp, g.prp)
    gr <- sortByRead1(gr)
    gr

## End(Not run)

cancer-genomics/trellis documentation built on Aug. 20, 2024, 5:48 p.m.