Function defined for (re)plotting ngs avg profiles (histograms) plots for specification of colors, facets, linetypes, and other pretty parameters.

ngsAvgProf(dir, linetype = FALSE, facets = NULL, applyNorm = FALSE,
  cols = NULL, dat = NULL)



location of unzipped directory of ngs.plot.r output


boolean describing whether to specify linetype based on column names in regcovMat, e.g. names specified in config. If set to "TRUE", then scale_linetype_manual should be added to output of function to specify linetypes (similarly, colours should be specified - see examples)


data.frame with columns "Var2" and "facets", where Var2 is the column names in regcovMat, e.g. names specified in config, and "facets" is a factor specifying how to group the marks (Var2)


for cases where analysis is input normalized, this takes the regcovMat matrix and subtracts the minima of each column from each column, respectively, allowing for easier visual comparison


Named vector of desired columns for output. Must match column names contained in regcovMat matrix in avgprof.RData. This can be indices or character vector of names.


A list containing regcovMat and confiMat from the avgprof.RData object contained in the ngs folder output. This can be used to select only certain columns for plotting or other manipulations.


Returns a ggplot2 object that can be additionally modified with functions such as scale_colour_manual and more (see examples).


## Specify directories
ngsatac <- paste0(dir$ngs, list.files(dir$ngs, pattern = "atac"), "/")
ngsmods <- paste0(dir$ngs, list.files(dir$ngs, pattern = "mods"), "/")

## Load example of each - mods & atac - for colnames (samples)
## and specify colouring, linetypes, and facets
load(paste0(ngsatac[1], "avgprof.RData"))
atacColour <- c(rep(colourCode["N"], 3), rep(colourCode["TE"], 3), rep(colourCode["MP"], 3))
names(atacColour) <- colnames(regcovMat)

load(paste0(ngsmods[1], "avgprof.RData"))
modsColour <- c(rep(colourCode["N"], 3), rep(colourCode["TE"], 3), rep(colourCode["MP"], 3),
                rep("black", 3))
names(modsColour) <- colnames(regcovMat)
modsLinetype <- rep(c("dashed", "solid", "dotted"), 4)
names(modsLinetype) <- colnames(regcovMat)
modsType <- data.frame(Var2 = colnames(regcovMat),
                       facets = rep(factor(c("N", "TE", "MP", "Tbet"), levels = c("MP", "N", "TE", "Tbet")),
                         each = 3))

## Plotting - add colour to atac
ngsAvgProf(ngsatac[1]) + ggtitle(basename(ngsatac[1])) +
  scale_colour_manual(values = atacColour)

## Plotting - add colour, linetype, and facetting to mods plot
ngsAvgProf(ngsmods[1], linetype = TRUE, facets = modsType, applyNorm = TRUE) +
  ggtitle(basename(ngsmods[1])) +
  scale_colour_manual(values = modsColour) +
  scale_linetype_manual(values = modsLinetype)