% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/MakeSE.R
\name{MakeSE}
\alias{MakeSE}
\title{Constructs a NxtSE object from the collated data}
\usage{
MakeSE(collate_path, colData, RemoveOverlapping = TRUE, realize = FALSE)
}
\arguments{
\item{collate_path}{(Required) The output path of \link{CollateData} pointing
to the collated data}

\item{colData}{(Optional) A data frame containing the sample annotation
information. The first column must contain the sample names.
Omit \code{colData} to generate a NxtSE object of the whole dataset without
any assigned annotations.
Alternatively, if the names of only a subset of samples are given, then
\code{MakeSE()} will construct the NxtSE object based only on the samples given.
The colData can be set later using \code{colData()}}

\item{RemoveOverlapping}{(default = \code{TRUE}) Whether to filter out overlapping
novel IR events belonging to minor isoforms. See details.}

\item{realize}{(default = \code{FALSE}) Whether to load all assay data into
memory. See details}
}
\value{
A \linkS4class{NxtSE} object containing the compiled data in
DelayedArrays pointing to the assay data contained in the given
\code{collate_path}
}
\description{
Creates a \linkS4class{NxtSE} object from the data
from IRFinder output collated using \link{CollateData}. This object is used
for downstream differential analysis of IR and alternative splicing events
using \link{ASE-methods} as well as visualisation using \link{Plot_Coverage}
}
\details{
\code{MakeSE} retrieves the generic SummarizedExperiment structure saved by
\link{CollateData}, and initialises a \linkS4class{NxtSE} object. It references
the required on-disk assay data using DelayedArrays, thereby utilising
'on-disk' memory to conserve memory usage.

For extremely large datasets, loading the entire data into memory may consume
too much memory. In such cases, make a subset of the \linkS4class{NxtSE}
object (e.g. subset by samples) before loading the data into memory (RAM)
using \link{realize_NxtSE}

It should be noted that downstream applications of NxtIRF, including
\link{ASE-methods}, \link{Plot_Coverage}, are much faster if the \linkS4class{NxtSE}
is realized. It is recommended to realize the \linkS4class{NxtSE} object
before extensive usage.

If COV files assigned via \link{CollateData} have been moved relative to the
\code{collate_path}, the created \linkS4class{NxtSE} object will not have any
linked COV files and \link{Plot_Coverage} cannot be used. To reassign these
files, a vector of file paths corresponding to all the COV files of the data
set can be assigned using \code{covfile(se) <- vector_of_cov_files}. See
example below for details.

If \code{RemoveOverlapping = TRUE}, \code{MakeSE} will try to
identify which introns belong to major isoforms, then remove introns of
minor introns that overlaps those of major isoforms. Non-overlapping
introns are then reassessed iteratively, until all introns are included
or excluded in this way. This is important to ensure that overlapping
novel IR events are not 'double-counted'.
}
\examples{

# The following code can be used to reproduce the NxtSE object
# that can be fetched with NxtIRF_example_NxtSE()

BuildReference(
    reference_path = file.path(tempdir(), "Reference"),
    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")
)

expr <- Find_IRFinder_Output(file.path(tempdir(), "IRFinder_output"))
CollateData(expr,
  reference_path = file.path(tempdir(), "Reference"),
  output_path = file.path(tempdir(), "NxtIRF_output")
)

se <- MakeSE(collate_path = file.path(tempdir(), "NxtIRF_output"))

# "Realize" NxtSE object to load all H5 assays into memory:

se <- realize_NxtSE(se)

# If COV files have been removed since the last call to CollateData()
# reassign them to the NxtSE object, for example:

covfile_path <- system.file("extdata", package = "NxtIRFcore")
covfile_df <- Find_Samples(covfile_path, ".cov")

covfile(se) <- covfile_df$path

# Check that the produced object is identical to the example NxtSE

example_se <- NxtIRF_example_NxtSE()
identical(se, example_se) # should return TRUE
}
