% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/IRFinder.R
\name{IRFinder}
\alias{IRFinder}
\alias{BAM2COV}
\title{Runs the OpenMP/C++-based NxtIRF/IRFinder algorithm}
\usage{
BAM2COV(
  bamfiles = "./Unsorted.bam",
  sample_names = "sample1",
  output_path = "./cov_folder",
  n_threads = 1,
  Use_OpenMP = TRUE,
  overwrite = FALSE,
  verbose = FALSE
)

IRFinder(
  bamfiles = "./Unsorted.bam",
  sample_names = "sample1",
  reference_path = "./Reference",
  output_path = "./IRFinder_Output",
  n_threads = 1,
  Use_OpenMP = TRUE,
  overwrite = FALSE,
  run_featureCounts = FALSE,
  verbose = FALSE
)
}
\arguments{
\item{bamfiles}{A vector containing file paths of 1 or more BAM files}

\item{sample_names}{The sample names of the given BAM files. Must
be a vector of the same length as \code{bamfiles}}

\item{output_path}{The output directory of this function}

\item{n_threads}{(default \code{1}) The number of threads to use. See details.}

\item{Use_OpenMP}{(default \code{TRUE}) Whether to use OpenMP to run IRFinder.
If set to \code{FALSE}, BiocParallel will be used if \code{n_threads} is set}

\item{overwrite}{(default \code{FALSE}) If IRFinder output files already exist,
will not attempt to re-run. If \code{run_featureCounts} is \code{TRUE}, will not
overwrite gene counts of previous run unless \code{overwrite} is \code{TRUE}.}

\item{verbose}{(default \code{FALSE}) Set to \code{TRUE} to allow IRFinder to output
progress bars and messages}

\item{reference_path}{The directory containing the NxtIRF reference}

\item{run_featureCounts}{(default \code{FALSE}) Whether this function will run
\link[Rsubread:featureCounts]{Rsubread::featureCounts} on the BAM files after running IRFinder.
If so, the output will be
saved to \verb{"main.FC.Rds} in the \code{output_path} directory as a list object.}
}
\value{
IRFinder output will be saved to \code{output_path}. Output files will be
named using the given sample names.
\itemize{
\item sample.txt.gz: The main IRFinder output file containing the quantitation
of IR and splice junctions, as well as QC information\cr\cr
\item sample.cov: Contains coverage information in compressed binary. See
\link{GetCoverage}
\item main.FC.Rds: A single file containing gene counts for the whole dataset
(only if \code{run_featureCounts == TRUE})
}
}
\description{
These function calls the IRFinder C++ routine on one or more BAM files.\cr\cr
The routine is an improved version over the original IRFinder, with
OpenMP-based multi-threading and the production of compact "COV" files to
record alignment coverage. A NxtIRF reference built using \link{BuildReference}
is required.\cr\cr
After IRFinder is run, users should call
\link{CollateData} to collate individual outputs into an experiment / dataset.
\cr\cr
BAM2COV creates COV files from BAM files without running the full IRFinder
algorithm.\cr\cr
See details for performance info.
}
\details{
Typical run-times for a 100-million paired-end alignment BAM file takes 10
minutes using a single core. Using 8 threads, the runtime is approximately
2 minutes. Approximately 10 Gb of RAM is used when OpenMP is used. If OpenMP
is not used (see below), this memory usage is multiplied across the number
of processor threads (i.e. 40 Gb if \code{n_threads = 4}).

OpenMP is natively available to Linux / Windows compilers, and OpenMP will
be used if \code{Use_OpenMP} is set to \code{TRUE}, using multiple threads to process
each BAM file. On Macs, if OpenMP is not available at compilation,
BiocParallel will be used, processing BAM files simultaneously,
with one BAM file per thread.
}
\section{Functions}{
\itemize{
\item \code{BAM2COV}: Converts BAM files to COV files without running
IRFinder algorithm

\item \code{IRFinder}: Runs IRFinder algorithm on BAM files. Requires a
NxtIRF/IRFinder reference generated by BuildReference()
}}

\examples{

# Run BAM2COV, which only produces COV files but does not run IRFinder:

bams <- NxtIRF_example_bams()

BAM2COV(bams$path, bams$sample,
  output_path = file.path(tempdir(), "IRFinder_output"),
  n_threads = 2, overwrite = TRUE
)

# Run IRFinder algorithm, which produces:
# - text output of intron coverage and spliced read counts
# - COV files which record read coverages

example_ref <- file.path(tempdir(), "Reference")

BuildReference(
    reference_path = example_ref,
    fasta = chrZ_genome(),
    gtf = chrZ_gtf()
)

bams <- NxtIRF_example_bams()

IRFinder(bams$path, bams$sample,
  reference_path = file.path(tempdir(), "Reference"),
  output_path = file.path(tempdir(), "IRFinder_output"),
  n_threads = 2
)
}
\seealso{
\link{BuildReference} \link{CollateData} \link{IsCOV}
}
