% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/findSimilarLibraries.R
\docType{methods}
\name{findSimilarLibraries,StrandStateMatrix,StrandReadMatrix,ChrTable-method}
\alias{findSimilarLibraries,StrandStateMatrix,StrandReadMatrix,ChrTable-method}
\alias{findSimilarLibraries}
\alias{findSimilarLibraries,findSimilarLibraries-StrandStateMatrix-StrandReadMatrix-ChrTable-method}
\title{findSimilarLibraries -- function to identify libraries that hare similar WC patterns on chromosomes}
\usage{

  \S4method{findSimilarLibraries}{StrandStateMatrix,StrandReadMatrix,ChrTable}(strandStateMatrix,
  strandReadMatrix, chrGrange, chrNum, cluster = 1, clusterParam = NULL,
  verbose = TRUE)
}
\arguments{
\item{strandStateMatrix}{A strandStateMatrix object for all libraries across split fragments, derived from preprocessStrandTable}

\item{strandReadMatrix}{The number of reads present for each strandStateMatrix element. An object of type strandReadMatrix from strandSeqFreqTable}

\item{chrGrange}{File of type ChrTable (a GRanges object with a meta column titled 'name' determining contig name) to split chromosomes based on locations.
name meta should match the rownames of strandStateMatrix and strandReadMatrix}

\item{chrNum}{The chromosome number to analyse}

\item{cluster}{Number of times to recluster and take the consensus of. If NULL, clustering is 
run only once}

\item{clusterParam}{optional \code{BiocParallelParam} specifying cluster to use for parallel execution.
When \code{NULL}, execution will be serial.}

\item{verbose}{prints messages to the terminal (default is TRUE)}
}
\value{
a list of type LinkageGroupList with two elements; libraries that are mostly Watson, and those that are mostly Crick
}
\description{
findSimilarLibraries -- function to identify libraries that hare similar WC patterns on chromosomes
}
\examples{
#Get a list of BAM files containing libraries for cells from the same organism, aligned to the same genome
#In this case these are the example BAM files provided with the package (hence the call to system.file);
data("exampleDividedChr")
data("exampleWCMatrix")
data("exampleReadCounts")

library(BiocParallel)

example.dir <- file.path(system.file(package='contiBAIT'), 'extdata')

chrGrange <- exampleDividedChr[which(exampleDividedChr$name \%in\% rownames(exampleWCMatrix))]

exampleLibList <- lapply(seq_len(length(unique(seqnames(chrGrange)))), function(x) findSimilarLibraries(exampleWCMatrix, exampleReadCounts, chrGrange, x, cluster=1, clusterParam=MulticoreParam()))
exampleLibList <- exampleLibList[!sapply(exampleLibList, is.null)]
exampleLibList <- LibraryGroupList(exampleLibList)

show(exampleLibList)
}
