Description Usage Arguments Details Author(s) Examples
Filter unknown, mitochondrial, and "random" chromosomes from a SAM file
1 | sam_filter(fileIn, fileOut, verbose = FALSE, deleteTemps = TRUE)
|
fileIn |
String - |
fileOut |
String - |
verbose |
Logical - |
deleteTemps |
Logical |
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:
Emma Myers
1 2 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.