build_screen: build screen object

Description Usage Arguments Details Value Log file Layout file Dropping columns Dependencies

View source: R/fun-build_screen.R

Description

Read screen log and layout, and collate all data into a single object. This is the first stage of the analysis. Restrictions on log/layout files are discussed here. The function tries to cope with some cases and also runs checks on data completion. There are many communications that the function will normally print; these can be silenced. The final object is returned invisibly as printing it all would be counterproductive.

Usage

1
2
3
4
5
6
7
8
9
build_screen(
  logfile,
  layout,
  datadir = "./data/",
  rem.col,
  zero.to.NA = FALSE,
  wells = "Index",
  verbose = TRUE
)

Arguments

logfile

path to screen log file; see Log file

layout

path to layout file that describes well types; see Layout file

datadir

path to directory where data files are stored

rem.col

columns to remove, given either as character vector or as vector of numeric indices; input 0 to remove last column;

zero.to.NA

logical flag whether to convert all 0 values to NAs

wells

name of column that stores well numbers; will be renamed to "wells"

verbose

logical flag whether to print all communications

Details

The function first checks the data files present in the data directory against the plates logged in the screen log. Data file names must begin with the full plate names as given in the screen log. Suffixes are allowed but must be separated by _. They will be discarded. Unexpected and missing plates are reported.

Once the plate list has been compiled, the layout file is loaded and all present data files that correspond to logged plates are read and wrapped into a single data frame.

The plate number and screen log data are used to obtain dates of the plates' preparation, plating, and imaging.

There is quite a lot of printed communication the function does, hence the verbose argument.

Value

an invisible data.frame

Log file

The screen log this must be a tab delimited file and contain columns: plateno, plated, imaged. Any number of other columns is acceptable. The plate number must be contained verbatim within the corresponding result file name. Any suffixes following an underscore will be dropped.

Layout file

The layout file must be a tab delimited file and contain columns: (numeric) well and well.type or well_type. Other columns may be necessary if there are multiple layouts, e.g. for different plating days or different plate types. Maintain a narrow data format.

The file should also specify a well's coordinates on a plate, either as position, e.g. "E02", or row and column. By default ScanR sorts and numbers wells by row, in contrast to the default filling of matrices in R. Thus, normalize sorts the data frame by column and row before running the median polish and if these columns are absent it throws an error.

Dropping columns

Columns are removed upon request. This option exists for two reasons. First, ScanR always adds an empty column at the end called "X". Second, the second column in every exported file, called "Description", contains the names of groups of wells. Since we only ever export data by well and not by group, this may cause problems if not all wells are scanned. Also we load layout and annotation separately, the column is redundant anyway.

Dependencies

Data files are loaded with read.delim. Dates are handled with lubridate. A number of internal functions are used.


olobiolo/siscreenr documentation built on Nov. 26, 2021, 3:08 p.m.