sam_filter: Filter SAM file

Description Usage Arguments Details Author(s) Examples

View source: R/sam_filter.R

Description

Filter unknown, mitochondrial, and "random" chromosomes from a SAM file

Usage

1
sam_filter(fileIn, fileOut, verbose = FALSE, deleteTemps = TRUE)

Arguments

fileIn

String -

fileOut

String -

verbose

Logical -

deleteTemps

Logical

Details

Remove mitochondrial, unmapped, and "random" chromosome reads from one SAM file, and save under a specified filename (ideally ending in '.filtered.sam') In the command line, all three steps can be accomplished for one file with one line: sed '/chrM/d;/random/d;/chrUn/d' fileIn.sam > fileOut.sam In order to do this in R, this function calls the system2() function, which issues commands to the command line. However, bash interprets the above line of code as three commands one call to sed per input (inputs are separated by semicolons). Therefore, system2() is called three times. The first call filters out lines with 'chrM' and writes the results to a temporary file. The second call filters out lines with 'chrUn' from that temporary file, and writes the results to another temporary file. The final call to system2() takes that file, filters out lines with 'random', and writes the results to the output file. Temporary files are deleted by default (see "deleteTemps" parameter). This function operates on SAM files generated by mapping with STAR. Not BAM, because Erin found that "random" chromosome reads weren't getting removed from bams along with the mitochondrial and unknown ones. Might be worth trying to figure that out, and make this handle BAMs as well. Time:

Author(s)

Emma Myers

Examples

1
2
Example at the command line:
system2('/opt/UCSC/wigToBigWig', args=c('samplename.gencov.bedgraph', '/path/to/genomeSizeFile.txt', samplename.bigwig))

e-myers/rnaseq documentation built on May 20, 2019, 9:14 p.m.