plotDistrTargets2: Plot distributions of signals from limma RGList, MAList,...

Description Usage Arguments Value Implementation Examples

Description

Plots distributions for each combination of FUNS, channels and sampleColors. By default, samples are ordered according to the sampleColors (if provided). Colors should be provided as factors with a preset order of levels; the order of colors is determined by the order of levels

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
plotDistrTargets2(
  expLog2,
  targets,
  colorsFrom = "color_",
  rename = TRUE,
  namesFrom = NULL,
  FUNS = c(geom_density, geom_boxplot),
  probeTypeVec = NULL,
  probeTypeValue = 0,
  numProbes = NULL,
  orderByColors = TRUE,
  scale_x_limits = NULL,
  filePath = NULL,
  width = 16/9 * 7,
  height = 7,
  ...
)

Arguments

expLog2

Expression matrix (preferably in log2 scale) with genes in rows and samples in columns

targets

Table with columns names with a prefix colorsFrom='color_'

colorsFrom

Character, non-empty prefix of names of columns with colors, default 'color_'

rename

Logical, default TRUE: rename colors using associated variables or variable namesFrom (default) FALSE: use existing names from 'color_' variables, or, if missing, use values from associated variables

namesFrom

Either NULL for using variables that share suffixes with colors or a variable from targets that is used for setting names to colors, e.g. HybName

FUNS

Vector, geom_functions from ggplot2, default c(geom_density, geom_boxplot), alternatives c(geom_violin, geom_histogram, ggridges::geom_density_ridges)

probeTypeVec

Vector of probe types

probeTypeValue

Value from probeTypeVec to use for plotting

numProbes

Number of randomly select probes

orderByColors

Logical for ordering samples by colors (coded as a factor with levels in order); default TRUE

scale_x_limits

NULL for auto-scale; use c(0,16) or less for log2(intensities)

filePath

NULL or character; if given, output a PDF; default NULL

width

PDF width, default 16/9*7=12.44

height

PDF height, default 7

...

Passed to ggplot2::FUN, e.g.: bins, binwidth, show.legend

Value

Invisibly a list of ggplot2 objects, one per a combination of FUNS and colors; PDF if filePath is given

Implementation

See https://www.tidyverse.org/blog/2020/02/glue-strings-and-tidy-eval/ for bracing variables. Evaluation of expression: https://adv-r.hadley.nz/evaluation.html. For bquote(a +. (b)): http://adv-r.had.co.nz/Expressions.html. Errors: - dplyr::rename(!!purrr::set_names(oldColNames, newColNames)) - colnames(expLog2) <- newColNames TODO: - titlePfx <- paste("Distribution of", as.character(rlang::fn_fmls()$'expLog2'), "on", numProbes, "probes", titleSfx)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
## Not run: 
expLog2 <- log2(dataRG$R)[1:100,]
## rename=TRUE (default)
## namesFrom=NULL,     orderByColors=TRUE
plotDistrTargets2(expLog2, targets, colorsFrom="color_", namesFrom=NULL, FUNS = c(geom_density, geom_boxplot),
    probeTypeVec = probeTypeVec, probeTypeValue = 0, numProbes = NULL, 
    scale_x_limits = NULL, filePath = file.path(resultDir, "_debug3_plotDistrTargets2-NULL.pdf"))
## namesFrom=HybName
plotDistrTargets2(expLog2, targets, colorsFrom="color_", namesFrom=HybName, FUNS = c(geom_density, geom_boxplot),
    probeTypeVec = probeTypeVec, probeTypeValue = 0, numProbes = NULL, 
    scale_x_limits = NULL, filePath = file.path(resultDir, "_debug3_plotDistrTargets2-HybName.pdf"))
## namesFrom=Birth3WHO
plotDistrTargets2(expLog2, targets, colorsFrom="color_", namesFrom=Birth3WHO, FUNS = c(geom_density, geom_boxplot),
    probeTypeVec = probeTypeVec, probeTypeValue = 0, numProbes = NULL, 
    scale_x_limits = NULL, filePath = file.path(resultDir, "_debug3_plotDistrTargets2-Birth3WHO.pdf"))
## namesFrom=HybName,  orderByColors=FALSE
plotDistrTargets2(expLog2, targets, colorsFrom="color_", namesFrom=HybName, FUNS = c(geom_density, geom_boxplot),
    probeTypeVec = probeTypeVec, probeTypeValue = 0, numProbes = NULL, orderByColors = FALSE,
    scale_x_limits = NULL, filePath = file.path(resultDir, "_debug3_plotDistrTargets2-HybName-noReorder.pdf"))
## rename=FALSE () (implies namesFrom=NULL)
## orderByColors=TRUE
plotDistrTargets2(expLog2, targets, colorsFrom="color_", rename=FALSE, namesFrom=NULL, FUNS = c(geom_density, geom_boxplot),
    probeTypeVec = probeTypeVec, probeTypeValue = 0, numProbes = NULL, 
    scale_x_limits = NULL, filePath = file.path(resultDir, "_debug3_plotDistrTargets2-noRename.pdf"))
## orderByColors=FALSE
plotDistrTargets2(expLog2, targets, colorsFrom="color_", rename=FALSE, namesFrom=NULL, FUNS = c(geom_density, geom_boxplot),
    probeTypeVec = probeTypeVec, probeTypeValue = 0, numProbes = NULL, orderByColors = FALSE,
    scale_x_limits = NULL, filePath = file.path(resultDir, "_debug3_plotDistrTargets2-noRename-noReorder.pdf"))
## warning: rename=FALSE $ namesFrom!=NULL
plotDistrTargets2(expLog2, targets, colorsFrom="color_", rename=FALSE, namesFrom=Birth2, FUNS = c(geom_density, geom_boxplot),
    probeTypeVec = probeTypeVec, probeTypeValue = 0, numProbes = NULL, orderByColors = FALSE,
    scale_x_limits = NULL, filePath = file.path(resultDir, "_debug3_plotDistrTargets2-warning.pdf"))
## w/o targets
getColPats2(NULL, unique=TRUE)
plotDistrTargets2(expLog2, NULL, colorsFrom="color_", rename=TRUE, namesFrom=NULL, FUNS = c(geom_density, geom_boxplot),
    probeTypeVec = probeTypeVec, probeTypeValue = 0, numProbes = NULL, orderByColors = FALSE,
    scale_x_limits = NULL, filePath = file.path(resultDir, "_debug3_plotDistrTargets2-noTargets.pdf"))
## non-unique column names
exxx <- expLog2
colnames(exxx) <- names(getColPats2(targets, namesFrom=Birth3WHO, pullVar=Birth3WHO))
plotDistrTargets2(exxx, NULL, colorsFrom="color_", rename=TRUE, namesFrom=NULL, FUNS = c(geom_density, geom_boxplot),
    probeTypeVec = probeTypeVec, probeTypeValue = 0, numProbes = NULL, orderByColors = FALSE,
    scale_x_limits = NULL, filePath = file.path(resultDir, "_debug3_plotDistrTargets2-euqalSampleNames-noTargets-.pdf"))
plotDistrTargets2(exxx, targets, colorsFrom="color_", rename=TRUE, namesFrom=NULL, FUNS = c(geom_density, geom_boxplot),
    probeTypeVec = probeTypeVec, probeTypeValue = 0, numProbes = NULL, orderByColors = FALSE,
    scale_x_limits = NULL, filePath = file.path(resultDir, "_debug3_plotDistrTargets2-euqalSampleNames.pdf"))

## End(Not run)

peterjuv/FunGenPipe documentation built on June 18, 2021, 3:38 a.m.