sam2ranges: SAM to genomic ranges

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/sam2ranges.R

Description

Import alignment positions in a SAM file to a GenomicRanges object.

Usage

1
sam2ranges(sam, minq = 10, restricted = NULL)

Arguments

sam

String containing the path to a SAM file.

minq

A numeric scalar specifying the minimum mapping quality score for an alignment.

restricted

A character vector containing reference sequences to restrict to.

Details

We use SAM files as Nanopore CIGAR strings are too long to be handled with the BAM format, and Rsamtools is yet to support CRAM files.

If minq is set, all reads with a lower mapping quality score are considered to be unmapped. These are preserved in the output (for consistency with the original FASTQ file) but are assigned reference locations of "*".

If restricted is not NULL, only alignments to reference sequences in restricted will be considered as valid. All other alignments will have their reference locations set to "*" to indicate that they are to be ignored.

Value

A GRanges is returned containing one entry per alignment record of interest. Each entry is named with the read name, and multiple entries may be present for a read if it aligns to multiple locations (due to multi-mapping or chimerism).

Author(s)

Florian Bieberich, with modifications from Aaron Lun

See Also

cigarWidthAlongReferenceSpace for how the width of each alignment is computed.

Examples

1
2
3
4
5
6
7
8
library(Rsamtools)
fl <- system.file("extdata", "ex1.bam", package="Rsamtools", mustWork=TRUE)
out <- asSam(fl, tempfile(fileext=""))
sam2ranges(out)

sam2ranges(out, restricted="seq1")

sam2ranges(out, minq=80)

florian0512/SarlaccSeq documentation built on May 28, 2019, 8:39 p.m.