Writes a CSV with one row per image, ready to fill in (in Excel, Numbers or R), which analyze_plates() then merges into every output table.

make_metadata(
  dir,
  file = file.path(dir, "plate_metadata.csv"),
  treatment = NA_character_,
  patterns = NULL,
  extra = list(),
  overwrite = FALSE
)

Arguments

dir

Folder with plate images.

file

Output CSV path (default plate_metadata.csv in dir).

treatment

Default treatment for all plates (e.g. "bacteria"), or NA to leave empty.

patterns

Optional named character vector of regular expressions: names are treatment labels, values are matched against file names.

extra

Named list of additional constant columns, e.g. list(bacterium = "isolate_7", zymo_strain = "IPO323", day = 7).

overwrite

Overwrite an existing file.

Value

The metadata data frame (invisibly), also written to file.

Details

Columns:

file

Image file name (do not edit).

plate_id

Identifier used in all outputs (file name by default).

treatment

"control" (Zymoseptoria alone, no bacterium) or the name of the confrontation, e.g. "bacteria". This column decides the layout: "control" plates are analysed without a central bacterium.

bacterium, zymo_strain, medium, day, replicate, photo_date, notes

Free design variables; add or remove any columns you like.

treatment can be pre-filled from the file names with patterns, e.g. patterns = c(control = "ctrl|control", bacteria = "bact|conf").

Examples

d <- tempfile(); dir.create(d)
for (f in c("ctrl_01.png", "ctrl_02.png", "bact_01.png")) {
  png::writePNG(array(0.5, c(10, 10, 3)), file.path(d, f))
}
meta <- make_metadata(d, patterns = c(control = "ctrl", bacteria = "bact"),
                      extra = list(bacterium = "isolate_7", day = 7))
#> ✔ Wrote 3 plates to /var/folders/f1/f8pqw4_n4y90tlykbbhy3ztm0000gn/T//RtmpzynSAP/file17fe7dd82e08/plate_metadata.csv.
meta
#>          file plate_id treatment bacterium zymo_strain medium day replicate
#> 1 bact_01.png  bact_01  bacteria isolate_7        <NA>   <NA>   7        NA
#> 2 ctrl_01.png  ctrl_01   control isolate_7        <NA>   <NA>   7        NA
#> 3 ctrl_02.png  ctrl_02   control isolate_7        <NA>   <NA>   7        NA
#>   photo_date notes
#> 1       <NA>  <NA>
#> 2       <NA>  <NA>
#> 3       <NA>  <NA>