% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/scanMeripBAM.R
\name{scanMeripBAM}
\alias{scanMeripBAM}
\title{Organize the BAM Files Information of a MeRIP-seq Data Set.}
\usage{
scanMeripBAM(
  bam_ip = NULL,
  bam_input = NULL,
  bam_treated_ip = NULL,
  bam_treated_input = NULL,
  paired_end = FALSE,
  library_type = c("unstranded", "1st_strand", "2nd_strand"),
  index_bam = TRUE,
  bam_files = NULL,
  design_ip = NULL,
  design_treatment = NULL,
  mapq = 30L,
  isSecondaryAlignment = FALSE,
  isNotPassingQualityControls = FALSE,
  isDuplicate = FALSE,
  isPaired = NA,
  isProperPair = NA,
  hasUnmappedMate = NA,
  ...
)
}
\arguments{
\item{bam_ip}{a \code{character} vector for the BAM file directories of the (control) IP samples.}

\item{bam_input}{a \code{character} vector for the BAM file directories of the (control) input samples.}

\item{bam_treated_ip}{a \code{character} vector for the BAM file directories of the treated IP samples.}

\item{bam_treated_input}{a \code{character} vector for the BAM file directories of the treated input samples.

If the bam files do not contain treatment group, user should only fill the arguments of \code{BAM_ip} and \code{BAM_input}.}

\item{paired_end}{a \code{logical} of whether the data comes from the Paired-End Library, \code{TRUE} if the data is Paired-End sequencing; default \code{= FALSE}.}

\item{library_type}{a \code{character} specifying the protocal type of the RNA-seq library, can be one in \code{c("unstranded", "1st_strand", "2nd_strand")}; default \code{= "unstranded"}.

\describe{
\item{\strong{unstranded}}{The randomly primed RNA-seq library type, i.e. both the strands generated during the first and the second strand sythesis are sequenced; example: Standard Illumina.}
\item{\strong{1st_strand}}{The first strand-specific RNA-seq library, only the strand generated during the first strand sythesis is sequenced; examples: dUTP, NSR, NNSR.}
\item{\strong{2nd_strand}}{The second strand-specific RNA-seq library, only the strand generated during the second strand sythesis is sequenced; examples: Ligation, Standard SOLiD.}
}}

\item{index_bam}{a \code{logical} value indicating whether to sort and index BAM files automatically if the bam indexes are not found; default \code{= TRUE}.

The BAM index files will be named by adding ".bai" after the names of the corresponding BAM files.}

\item{bam_files}{optional, a \code{character} vector for all the BAM file directories, if it is provided, the first 4 arguments above will be ignored.}

\item{design_ip}{optional, a \code{logical} vector indicating the information of IP/input, \code{TRUE} represents IP samples.}

\item{design_treatment}{optional, a \code{logical} vector indicating the design of treatment/control, \code{TRUE} represents treated samples.}

\item{mapq}{a non-negative integer specifying the minimum reads mapping quality. BAM records with mapping qualities less than \code{mapq} are discarded; default \code{= 30L}.}

\item{isPaired, isProperPair, hasUnmappedMate, isSecondaryAlignment, isNotPassingQualityControls, isDuplicate, ...}{arguments specifying the filters on SAM FLAG scores, inherited from \code{\link{ScanBamParam}}.}
}
\value{
a \code{MeripBamFileList} object.
}
\description{
\code{scanMeripBAM} check and organize the BAM files in MeRIP-seq data before peak calling using \code{\link{exomePeakCalling}}.
The library types of the RNA-seq and the filters such as SAM FLAG score are specified in this function.
}
\details{
\code{scanMeripBAM} takes the input of the BAM file directories for the MeRIP-seq datasets.
It first checks the completeness of the BAM files and the BAM indexes. Then, the design information of IP/input and treated/control are returned as a \code{MeripBamFileList} object.
If the BAM file indexes are missing, the BAM files will be automatically indexed with the package \code{Rsamtools}.
}
\examples{

### Define BAM File Directories

f1 = system.file("extdata", "IP1.bam", package="exomePeak2")
f2 = system.file("extdata", "IP2.bam", package="exomePeak2")
f3 = system.file("extdata", "IP3.bam", package="exomePeak2")
f4 = system.file("extdata", "IP4.bam", package="exomePeak2")
IP_BAM = c(f1,f2,f3,f4)
f1 = system.file("extdata", "Input1.bam", package="exomePeak2")
f2 = system.file("extdata", "Input2.bam", package="exomePeak2")
f3 = system.file("extdata", "Input3.bam", package="exomePeak2")
INPUT_BAM = c(f1,f2,f3)

f1 = system.file("extdata", "treated_IP1.bam", package="exomePeak2")
TREATED_IP_BAM = c(f1)
f1 = system.file("extdata", "treated_Input1.bam", package="exomePeak2")
TREATED_INPUT_BAM = c(f1)

### For MeRIP-Seq Experiment Without the Treatment Group

MeRIP_Seq_Alignment <- scanMeripBAM(
  bam_ip = IP_BAM,
  bam_input = INPUT_BAM,
  paired_end = FALSE
)

### For MeRIP-Seq Experiment With the Treatment Group

MeRIP_Seq_Alignment <- scanMeripBAM(
bam_ip = IP_BAM,
bam_input = INPUT_BAM,
bam_treated_ip = TREATED_IP_BAM,
bam_treated_input = TREATED_INPUT_BAM,
paired_end = FALSE
)

}
\seealso{
\code{\link{exomePeakCalling}}
}
