filter_unmapped_reads: Filter unmapped reads

View source: R/align_target.R

filter_unmapped_readsR Documentation

Filter unmapped reads

Description

This function will remove all unmapped reads or lines in a .bam file (warning: overwrites the original file!). This function is needed because combining multiple .bam files from different microbial libraries may lead to some reads that mapped to one library and have unmapped entries from another library. This will remove any unmapped entries and leave all reference mapped lines in the .bam file.

Usage

filter_unmapped_reads(bamfile)

Arguments

bamfile

Location for the .bam file to filter & remove all unmapped reads

Details

It is not intended for direct use.

Value

This function will overwrite the existing .bam file with a new .bam file in the same location that has only mapped lines. The function itself returns the output .bam file name.

Examples


# refPath <- system.file("extdata","target.fasta", package = "MetaScope")
# file.copy(from = refPath, to = file.path(".", "target.fasta"))
# mk_subread_index('target.fasta')
# readPath <- system.file("extdata", "reads.fastq", package = "MetaScope")
# Rsubread::align(index = "target", readfile1 = readPath, output_file = "example.bam")
# filtered <- filter_unmapped_reads("example.bam")


compbiomed/MetaScope documentation built on Aug. 9, 2022, 10:41 a.m.