% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gsvaRanks_serialization.R
\name{saveHDF5GSVAranks}
\alias{saveHDF5GSVAranks}
\alias{loadHDF5GSVAranks}
\title{Save/load GSVA rank values to disk using HDF5 format}
\usage{
saveHDF5GSVAranks(x, dir, ...)

loadHDF5GSVAranks(dir, ...)
}
\arguments{
\item{x}{A \code{\linkS4class{gsvaRanksParam}} object to save to disk.}

\item{dir}{The path to the directory where to save or load the GSVA ranks
data.}

\item{...}{Additional arguments to be passed to the underlying HDF5
saving/loading functions
\code{\link[HDF5Array:saveHDF5SummarizedExperiment]{saveHDF5SummarizedExperiment}}
and \code{\link[HDF5Array:saveHDF5SummarizedExperiment]{loadHDF5SummarizedExperiment}},
respectively.}
}
\value{
For \code{saveHDF5GSVAranks}, the path to the directory where the data
has been saved is returned invisibly. For \code{loadHDF5GSVAranks}, a
\code{gsvaRanksParam} object is returned containing the loaded GSVA rank values
and their corresponding metadata.
}
\description{
The functions \code{saveHDF5GSVAranks} and \code{loadHDF5GSVAranks} can
be used to save and load the GSVA rank values to/from disk, respectively.
The \code{saveHDF5GSVAranks} function takes a \code{gsvaRanksParam} object and saves
the rank values along with the relevant metadata to a specified directory.
The \code{loadHDF5GSVAranks} function reads the saved data from the specified
directory and reconstructs the \code{gsvaRanksParam} object with the rank values
and their corresponding metadata.
}
\examples{

p <- 10 ## number of genes
n <- 30 ## number of samples
nGrp1 <- 15 ## number of samples in group 1
nGrp2 <- n - nGrp1 ## number of samples in group 2

## consider three disjoint gene sets
geneSets <- list(gset1=paste0("g", 1:3),
                 gset2=paste0("g", 4:6),
                 gset3=paste0("g", 7:10))

## sample data from a normal distribution with mean 0 and st.dev. 1
y <- matrix(rnorm(n*p), nrow=p, ncol=n,
            dimnames=list(paste("g", 1:p, sep="") , paste("s", 1:n, sep="")))

## build GSVA parameter object
gsvapar <- gsvaParam(y, geneSets)

## calculate GSVA ranks
gsvarankspar <- gsvaRanks(gsvapar)

## calculate GSVA scores
es <- gsvaScores(gsvarankspar)

## save the GSVA ranks to disk
dir <- tempfile()
saveHDF5GSVAranks(gsvarankspar, dir)

## load the GSVA ranks from disk
loaded_gsvarankspar <- loadHDF5GSVAranks(dir)

## check that the loaded ranks provide the
## same scores as the original ranks
loaded_es <- gsvaScores(loaded_gsvarankspar)
identical(es, loaded_es)

}
