% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gsea_to_mtx.R
\name{gsea_to_mtx}
\alias{gsea_to_mtx}
\title{Reads a GSEA output file and creates a matrix from the positive and negative report files,
that serves as input to pathway_heatmap}
\usage{
gsea_to_mtx(dirlist, db = "GO", q = 0.1, preN = 25, postN = NULL,
  colname = "GseaPreranked")
}
\arguments{
\item{dirlist}{a list of GSEA directories of interest, containing the results for multiple gene sets}

\item{db}{the geneset database to include, e.g., GO or Path, as imbedded in the output GSEA directory names}

\item{q}{minimum FDR / q-value cutoff for including genesets in the output matrix}

\item{preN}{maximum number of rows to include from each input GSEA analysis (pairwise comparison)}

\item{postN}{maximum number of rows to include in the final merged matrix.}

\item{colname}{name of the column in the GSEA output containing the normalized scores ("GseaPreranked" for RNASeq pipeliner results)}
}
\value{
a list of three elements:
        1) numeric matrix, with rownames as genesets, column names as comparisons
        2) a vector of names for the columns containing the actual enrichment data
        3) a vector of names for the column names containing q-values
}
\description{
Reads in both the positive and negative GSEA enrichment reports from the appropriate directories,
  reads the scoring column (default="GseaPreranked") and creates a single matrix of
  positive and negative enrichment scores
}
\details{
The directory list should be generated with the list.dirs() function,
these directories will be further filtered to only those containing the db name (e.g., GO or Path).

Once the GSEA results have been read in, they will be filtered to only q (FDR) values
less than the minimum (q).
The set of resulting matrices for each comparison will be filtered to include only a maximum of preN values.
The matrices will then be combined across all comparisons, and the filtered again to a maximum number of rows (postN).
The current RNASeq pipeliner sets the normalized GSEA score to "GseaPreranked",
Use colname to set the appropriate column name for GSEA results derived from outside of pipeliner.
}
\examples{
alldirs = list.dirs(path=dir_gsea3, full.names=TRUE, recursive=FALSE)
dirlist = alldirs[grepl(paste0("KO_vs_WT.", i, ".GseaPreranked.[0-9]*$"), alldirs, perl=TRUE)]
nes <- gsea_to_mtx(dirlist, db="GO", q=0.1, preN=50, postN=50)
main=paste("Gene Set Enrichment:", i, "\\nPairwise comparisons of genotype within experiment")
fontsize_row=8
pdf("myoutput.pdf")
pathway_heatmap(nes, clustrow=1, clustcol=1, cluster_cols=FALSE,
                main=main, samples=NULL, annotlegend=FALSE,
                fontsize_row=fontsize_row, fontsize_col=12)
dev.off()

}
\author{
Susan Huse \email{susan.huse@nih.gov}
}
\keyword{GSEA}
\keyword{Pipeliner}
\keyword{RNASeq}
\keyword{geneset}
\keyword{heatmap}
