link_ethoscope_metadata: Link ethoscope metadata to the matching result files

View source: R/link-ethoscope-metadata.R

link_ethoscope_metadata_remoteR Documentation

Link ethoscope metadata to the matching result files

Description

These functions augment metadata so it can be subsequently loaded (with load_ethoscope).

Usage

link_ethoscope_metadata_remote(
  x,
  remote_dir,
  result_dir,
  index_file = "index.txt",
  overwrite_local = FALSE,
  verbose = TRUE
)

link_ethoscope_metadata(x, result_dir = NULL, index_file = NULL)

Arguments

x

object such as a data.frame, or the name of a file (see detail)

remote_dir

the url of the result directory on the data server

result_dir

the directory where all data are saved

index_file

the name of an index_file, in result_dir (useful for loading remote data).

overwrite_local

whether to download all files. The default, FALSE, is to only fetch files if they are newer on the remote.

verbose

whether to print progress (a logical)

Details

These function will augment metadata from two different types of inputs (x):

  1. A data.frame (recomended) In this case, the function will try to match requested data with data available on result_dir. The provided data.table has typically one row per requested individual and the columns (not necessarily in this order):

    • machine_name – the name of the machine in which the individual was (e.g. "ETHOSCOPE_001")

    • date – the start date of the experiment formatted as "YYYY-MM-DD"

    • region_id – the ROI in which the animal was. When not provided, all regions are queried.

    • time – the start time of the experiment formatted as "HH:MM:SS". When not provided, and multiple experiment for the same machine exist, only the last one is loaded.

    • ??? – any number of arbitrary columns* to associate conditions/treatments/genotypes/... to the previous columns.

  2. The name of a CSV file that contains a table as described in 1.

  3. A vector of .db files to be read.

Value

a data.table::data.table with the same rows as x, and extra columns for further data loading

References

See Also

  • load_ethoscope – to load the actual data

  • list_result_files – to list available file

Examples

# Metadata with no region_id -> all regions will be loaded with the same metadata
dir <- paste0(scopr_example_dir(), "/ethoscope_results/")
data(no_region_id_metadata)
metadata <- link_ethoscope_metadata(no_region_id_metadata, dir)
print(metadata)

# Metadata with region_id ->  only stated regions will be loaded with specific metadata
data(region_id_metadata)
metadata <- link_ethoscope_metadata(region_id_metadata, dir)
print(metadata)

## Not run: 
# If your files are stored on a remote server,
# this will download to a local directory only the needed files
REMOTE <- "ftp://a/remote/server/"
LOCAL_DIR <- "/where/I/store/the/data/"
metadata <- link_ethoscope_metadata_remote(region_id_metadata,
                                           REMOTE,
                                           LOCAL_DIR)


## End(Not run)

scopr documentation built on Aug. 15, 2022, 5:05 p.m.