get_fragment_size: Gets fragment lengths from a bam file

Description Usage Arguments Details Value See Also Examples

View source: R/get_fragment_size.R

Description

A function to extract fragment lengths from a bam file. Optionally, given a mutation data frame, it can categorize read lengths in mutated vs non-mutated reads.

Usage

1
2
3
4
get_fragment_size(bam, mutations = NULL, targets = NULL, tag = "",
  isProperPair = NA, mapqFilter = 30, min_size = 1, max_size = 400,
  ignore_trimmed = TRUE, different_strands = TRUE,
  simple_cigar = FALSE)

Arguments

bam

path to bam file.

mutations

An optional data frame with mutations. Must have the columns CHROM, POS, REF, ALT.

targets

a data frame with the target regions to restrict the reads in the bam. Must have three columns: chr, start and end

tag

the RG tag if the bam has more than one sample.

isProperPair

a logical whether to return only proper pairs (true), only improper pairs (false), or it does not matter (NA).

mapqFilter

mapping quality threshold for considering reads.

min_size

Integer with the lowest fragment length.

max_size

Integer with the highest fragment length.

ignore_trimmed

logical, whether to remove reads that have been hard trimmed.

different_strands

logical, whether to keep only reads whose mates map to different strand.

simple_cigar

logical, whether to include only reads with simple cigar.

Details

Extracts the fragment size of reads in the input bam that satisfy the following conditions:

When the input mutations is given, the output will label the reads that support the variant alleles of the mutation in a separate column.

Value

A data frame with the columns:

See Also

summarize_fragment_size bin_fragment_size analyze_fragmentation get_mutations_fragment_size

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
data("mutations", package = "ctDNAtools")
data("targets", package = "ctDNAtools")
bamT1 <- system.file("extdata", "T1.bam", package = "ctDNAtools")

## basic usage
fs <- get_fragment_size(bam = bamT1)

## More options
fs1 <- get_fragment_size(
  bam = bamT1, isProperPair = TRUE, min_size = 70,
  max_size = 200, ignore_trimmed = FALSE, different_strands = FALSE,
  simple_cigar = TRUE
)

## with mutations input
fs2 <- get_fragment_size(bam = bamT1, mutations = mutations)

## using targets
fs3 <- get_fragment_size(bam = bamT1, targets = targets)

ctDNAtools documentation built on March 26, 2020, 7:39 p.m.