bamtagregex: Change sam/bam tag values

Description Usage Arguments Details Examples

View source: R/bamtagregex.r

Description

Change tag value in sam/bam file using regular expression.

Usage

1
bamtagregex(input, output, tag, pattern, replace, remake = FALSE)

Arguments

input

an input sam/bam file

output

an output sam/bam file

tag

a tag to modify

pattern

a regex pattern

replace

a string to replace matched pattern

remake

optional remake the output if it already exists

Details

This code is a thin wrapper over the Python script bamtagregex.py found in the package's inst folder.

The bamtagregex.py uses the amazing pysam package to manipulate the sam/bam files. The Python's pysam package is powered by the htslib library. the same library that powers samtools. In R, there is a similar package to pysam, the Rsamtools found in bioconductor. But this library reads the whole file at once (instead of using memory efficient iterators), which makes working with a large bam files less than ideal.

Examples

1
2
3
4
5
## Not run: 
# Replace the end of 10x barcode from "-1" to "-baz"
bamtagregex("foo.bam", "bar.bam", "CB", "-1", "-baz")

## End(Not run)

bioDS/phyloRNA documentation built on Feb. 21, 2022, 3:28 p.m.