filter_host_bowtie | R Documentation |
After a sample is aligned to a target library with
align_target_bowtie()
, we may use filter_host_bowtie()
to
remove unwelcome host contamination using filter reference libraries. This
function takes as input the name of the .bam file produced via
align_target_bowtie()
, and produces a sorted .bam or .csv.gz file with
any reads that match the filter libraries removed. This resulting .bam file
may be used downstream for further analysis. This function uses Rbowtie2 For
the Rsubread equivalent of this function, see filter_host
.
filter_host_bowtie(
reads_bam,
lib_dir,
libs,
make_bam = FALSE,
output = paste(tools::file_path_sans_ext(reads_bam), "filtered", sep = "."),
bowtie2_options = NULL,
YS = 1e+05,
threads = 1,
overwrite = FALSE,
quiet = TRUE
)
reads_bam |
The name of a merged, sorted .bam file that has previously
been aligned to a reference library. Likely, the output from running an
instance of |
lib_dir |
Path to the directory that contains the filter Bowtie2 index files. |
libs |
The basename of the filter libraries (without .bt2 or .bt2l extension). |
make_bam |
Logical, whether to also output a bam file with host reads
filtered out. A .csv.gz file will be created instead if |
output |
The desired name of the output .bam or .csv.gz file. Extension is
automatically defined by whether |
bowtie2_options |
Optional: Additional parameters that can be passed to the filter_host_bowtie() function. To see all the available parameters use Rbowtie2::bowtie2_usage(). See Details for default parameters. NOTE: Users should pass all their parameters as one string and if optional parameters are given then the user is responsible for entering all the parameters to be used by Bowtie2. The only parameters that should NOT be specified here is the threads. |
YS |
yieldSize, an integer. The number of alignments to be read in from the bam file at once for chunked functions. Default is 100000. |
threads |
The amount of threads available for the function. Default is 1 thread. |
overwrite |
Whether existing files should be overwritten. Default is FALSE. |
quiet |
Turns off most messages. Default is |
A compressed .csv can be created to produce a smaller output file that is
created more efficiently and is still compatible with metascope_id()
.
The default parameters are the same that PathoScope 2.0 uses. "–very-sensitive-local -k 100 –score-min L,20,1.0"
The name of a filtered, sorted .bam file written to the user's
current working directory. Or, if make_bam = FALSE
, a .csv.gz file
containing a data frame of only requisite information to run
metascope_id()
.
#### Filter reads from bam file that align to any of the filter libraries
## Assuming a bam file has already been created with align_target_bowtie()
# Create temporary filter library
filter_ref_temp <- tempfile()
dir.create(filter_ref_temp)
## Download reference genome
MetaScope::download_refseq("Orthoebolavirus zairense",
reference = FALSE,
representative = FALSE,
compress = TRUE,
out_dir = filter_ref_temp,
caching = TRUE)
## Create temp directory to store the indices
index_temp <- tempfile()
dir.create(index_temp)
## Create filter index
MetaScope::mk_bowtie_index(
ref_dir = filter_ref_temp,
lib_dir = index_temp,
lib_name = "filter",
overwrite = TRUE
)
## Create temporary folder to hold final output file
output_temp <- tempfile()
dir.create(output_temp)
## Get path to example bam
bamPath <- system.file("extdata", "bowtie_target.bam",
package = "MetaScope")
target_copied <- file.path(output_temp, "bowtie_target.bam")
file.copy(bamPath, target_copied)
## Align and filter reads
filter_out <-
filter_host_bowtie(
reads_bam = target_copied,
lib_dir = index_temp,
libs = "filter",
threads = 1
)
## Remove temporary directories
unlink(filter_ref_temp, recursive = TRUE)
unlink(index_temp, recursive = TRUE)
unlink(output_temp, recursive = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.