export_results: Export experiment results to a dataframe or file.

View source: R/export_results.R

export_resultsR Documentation

Export experiment results to a dataframe or file.

Description

Binds experiment data together with analysis results and optionally writes this to file.

Usage

export_results(experiment, strategies = NULL, tracks = "all", file = NULL)

Arguments

experiment

An rtrack_experiment object from read_experiment.

strategies

An optional rtrack_strategies object generated by call_strategy. If present, the strategies corresponding to the tracks in the experiment (after subsetting using the tracks parameter) will be extracted and returned in the results.

tracks

Which tracks should be exported. Default, "all", exports the entire experiment object. A subset of tracks can be specified using either numeric indices or a vector of track IDs following usual R standards.

file

The file to which the results will be written. If NULL (the default), the data will be returned as a data.frame.

Details

If only the results matching a thresholded subset of strategies should be exported, then this can be achieved by performing strategy calling and thresholding separately and passing the strategies$tracks component of the resulting rtrack_strategies object to this function as the parameter tracks. This will restrict the output of export_results to only the tracks where an above-threshold strategy has been determined.

If the parameter file is supplied, the file extension will be used to determine which format to save the file in. The formats ".csv", ".csv2" (see write.table for details of the formats), ".tsv" ( tab-delimited text; can also be written as ".txt" or ".tab") and ".xlsx" are supported. If the file extension is not in this list, the data will be written as tab-delimited text with a warning. Note that the Excel ".xlsx" format is supported, but the older ".xls" is not.

Value

A data.frame containing the experimental groups and factors (as supplied in the original experiment description) together with the summary metrics. This is returned invisibly if file is specified.

See Also

call_strategy, threshold_strategies.

Examples

require(Rtrack)
experiment.description <- system.file("extdata", "Minimal_experiment.xlsx",
  package = "Rtrack")
experiment <- read_experiment(experiment.description, format = "excel",
  project.dir = system.file("extdata", "", package = "Rtrack"))
# The code below returns a data.frame.
# Use the parameter 'file' to write to a file instead.
export_results(experiment)


Rtrack documentation built on Aug. 10, 2023, 9:10 a.m.