melt_plate_xlsx: Read xlsx data in plate format and convert to long format

Description Usage Arguments Details Value Examples

Description

Read in plate format data from an xlsx file and return a melted data frame with the contents and well coordinates.

Usage

1
2
melt_plate_xlsx(file, rows, cols, sheet = 1, col_names = FALSE, ...,
  .id = "content")

Arguments

file

A valid file path for the xlsx file.

rows

A numeric vector of the rows to read

cols

A vector of columns to be read. Can be integers or characters, see examples

sheet

The name or index of the sheet.

col_names

Boolean. Should the first non-empty row be converted to column names.

...

Arguments passed to read_generic().

.id

The name of the well content column.

Details

A special case is when the first row of contents is empty. The suggested pattern then is to include an extra row with column names from the Excel Sheet and set col_names = TRUE. So for a a 8-row plate you would include a 9-row range, see examples. This is because of behavior in the underlying function openxlsx::read.xlsx() that skips empty rows at the start of a read-in region if the contents are blank.

Value

A melted data frame.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
# generic assay with layouts in 96 well format
meta_file <- "data/plate_layouts.xlxs"

# all equivilant
melt_plate_xlsx(meta_file, rows = 2:9, cols = 2:13, sheet = 1)
melt_plate_xlsx(meta_file, rows = 2:9, cols = LETTERS[2:13], sheet = 1)
melt_plate_xlsx(meta_file, rows = 2:9, cols = "B:M", sheet = 1)

# if the first row was empty
melt_plate_xlsx(meta_file, rows = 1:9, cols = "B:M", col_names = T, sheet = 1)

## End(Not run)

hemoshear/assayr2 documentation built on Nov. 8, 2019, 6:13 p.m.