linModelSelect: Test multiple starting levels for linear regression model,...

View source: R/linModelSelect.R

linModelSelectR Documentation

Test multiple starting levels for linear regression model, select best and plot

Description

The aim of this function is to select the data suiting set of levels of the main input data to construct a linear regression model. In real world measurements one may be confronted to the case of very low level analytes below the detection limit (LOD) and resulting read-outs fluctuate around around a common baseline (instead of NA). With such data it may be preferable to omit the read-outs for the lowest concentrations/levels of analytes if they are spread around a base-line value. This function allows trying to omit all starting levels designed in startLev, then the resulting p-values for the linear regression slopes will be checked and the best p-value chosen. The input may also be a MArrayLM-type object from package limma or from moderTestXgrp or moderTest2grp. In the graphical representation all points assocoated to levels omitted are shown in light green. For the graphical display additional information can be used : If the dat is list or MArrayLM-type object, the list-elements $raw (according to argument lisNa will be used to display points initially given as NA ad imputed lateron in grey. Logarithmic (ie log-linear) data can be treated by settting argument logExpect=TRUE. Then the levels will be taken as exponent of 2 for the regression, while the original values will be displayed in the figure.

Usage

linModelSelect(
  rowNa,
  dat,
  expect,
  logExpect = FALSE,
  startLev = NULL,
  lisNa = c(raw = "raw", annot = "annot", datImp = "datImp"),
  plotGraph = TRUE,
  tit = NULL,
  pch = c(1, 3),
  cexLeg = 0.95,
  cexSub = 0.85,
  xLab = NULL,
  yLab = NULL,
  cexXAxis = 0.85,
  cexYAxis = 0.9,
  xLabLas = 1,
  cexLab = 1.1,
  silent = FALSE,
  debug = FALSE,
  callFrom = NULL
)

Arguments

rowNa

(character, length=1) rowname for line to be extracted from dat

dat

(matrix, list or MArrayLM-object from limma) main input of which columns should get re-ordered, may be output from moderTestXgrp or moderTest2grp.

expect

(numeric of character) the expected levels; if character, constant unit-characters will be stripped away to extact the numeric content

logExpect

(logical) toggle to TRUE if the main data are logarithmic but expect is linear

startLev

(integer) specify all starting levels to test for omitting here (multiple start sites for modelling linear regression may be specified to finally pick the best model)

lisNa

(character) in case dat is list or MArrayLM-type object, the list-elements with these names will be used as $raw (for indicating initial NA-values, $datImp (the main quantitation data to use) and $annot for displaying the corresponding value from the "Accession"-column.

plotGraph

(logical) display figure

tit

(character) optional custom title

pch

(integer) symbols to use n optional plot; 1st for regular values, 2nd for values not used in regression

cexLeg

(numeric) size of text in legend

cexSub

(numeric) text-size for line (as subtitle) giving regression details of best linear model)

xLab

(character) custom x-axis label

yLab

(character) custom y-axis label

cexXAxis

(character) cex-type for size of text for x-axis labels

cexYAxis

(character) cex-type for size of text for y-axis labels

xLabLas

(integer) las-type orientation of x-axis labels (set to 2 for vertical axix-labels)

cexLab

(numeric) cex-type for size of text in x & y axis labels (will be passed to cex.lab in plot())

silent

(logical) suppress messages

debug

(logical) additional messages for debugging

callFrom

(character) allow easier tracking of messages produced

Value

This function returns a list with $coef (coefficients), $name (as/from input rowNa), $startLev the best starting level)

See Also

moderTestXgrp for single comparisons, order

Examples

## Construct data
li1 <- rep(c(4,3,3:6),each=3) + round(runif(18)/5,2)
names(li1) <- paste0(rep(letters[1:5], each=3), rep(1:3,6))
li2 <- rep(c(6,3:7), each=3) + round(runif(18)/5, 2)
dat2 <- rbind(P1=li1, P2=li2)
exp2 <- rep(c(11:16), each=3)

## Check & plot for linear model 
linModelSelect("P2", dat2, expect=exp2)

## Log-Linear data
## Suppose dat2 is result of measures in log2, but exp4 is not
exp4 <- rep(c(3,10,30,100,300,1000), each=3)
linModelSelect("P2", dat2, expect=exp4, logE=FALSE)    # bad
linModelSelect("P2", dat2, expect=exp4, logE=TRUE)


wrMisc documentation built on Sept. 11, 2024, 6:10 p.m.