The MidarExperiment
object is the main data
container used in the MiDAR workflow. It holds all the
experimental and processed data and metadata, as well as details of the
applied processing steps and the current status of the data.
Most MiDAR
functions take an MidarExperiment object as
input. Functions that process or update the data return a modified
MidarExperiment
object as output, allowing it to be used in
subsequent functions. You can create and process multiple
MidarExperiment
objects independently within the same
script.
Creating a MidarExperiment object
First the {midar} package is loaded and then we create a new
MidarExperiment
object.
library(midar)
myexp <- MidarExperiment()
At any time we can obtain a summary on the status of the
myexp
object using the print()
function.
print(myexp)
#> Warning: Unknown or uninitialised column: `feature_id`.
Using MidarExperiment objects
Most MiDAR
functions take an MidarExperiment object as
input. Functions that process or update the data return a modified
MidarExperiment
object as output, allowing it to be used in
subsequent functions.
myexp <- MidarExperiment()
myexp <- data_load_example(myexp, 1)
myexp <- normalize_by_istd(myexp)
myexp <- save_dataset_csv(myexp,
"mydata.csv",
variable = "norm_intensity",
filter_data = FALSE)
You can also use MidarExperiment
objects in an R pipe
chain. This allows you to chain multiple functions together, making your
code more streamlined and easier to read while clearly indicating the
flow of your processing workflow.
myexp <- myexp |>
MidarExperiment() |>
data_load_example(1) |>
normalize_by_istd() |>
save_dataset_csv(myexp,
"mydata.csv",
variable = "norm_intensity",
filter_data = FALSE)
Multiple MidarExperiment
objects can be created and
processed independently within the same script.
myexp_panel_1 <- data_load_example(myexp, 1)
myexp_panel_2 <- data_load_example(myexp, 1)
Accessing data and metadata
Use specific functions to access data and metadata stored in the
MidarExperiment
object, rather than directly accessing the
object slots. TODO
myexp <- MidarExperiment()
myexp <- data_load_example(myexp, 1)
print(midar::get_analyticaldata(myexp))
Saving and Reading MidarExperiment objects
myexp <- MidarExperiment()
myexp <- data_load_example(myexp, 1)
saveRDS(myexp, file = "myexp-midar.rds", compress = TRUE)
my_saved_exp <- readRDS(file = "myexp-midar.rds")
print(my_saved_exp)