Export annotation Tables from ARCs
This guide demonstrates how to use ARCtrl to export annotation tables from an ARC into individual json files.
Use-case
Section titled Use-caseSome users want to quickly export studies, assays or individual annotation tables into easily shareable and reusable json files. This might help to establish SOPs from a lab-typical ARC.
Example script
Section titled Example scriptTo follow this example you can download the public ARC Facultative-CAM-in-Talinum
and store it parallel to the script.
Preparation
Section titled PreparationFirst, load the required libraries and load the local ARC into an ArcInvestigation
object for easy access.
#r "nuget: ARCtrl"#r "nuget: ARCtrl.QueryModel"
open ARCtrlopen ARCtrl.QueryModelopen ARCtrl.Jsonopen System.IO
// Path to a local ARC
let arcPath = @"Facultative-CAM-in-Talinum"
// Load local ARC from scaffold
let arc = ARC.load arcPath
// Store the ArcInvestigation object for easier accesslet investigation = arc.ISA.Value
Export a study
Section titled Export a studyWe can simply create a function exportStudyToJson
, which takes an ArcInvestigation
object and a selected study identifier as inputs and writes the json (of type ARCtrl json) to a file named by the study identifier with the extension “.arctrl.json”.
In this example, we select “TalinumSamples-STRI” from the available studies.
let exportStudyToJson (a: ArcInvestigation) (studyIdentifier : string) = a.GetStudy studyIdentifier |> ArcStudy.toJsonString 2 |> fun c -> File.WriteAllText(studyIdentifier + ".arctrl.json", c)
// Print all study identifiers
investigation.StudyIdentifiers |> Seq.iter (printfn "%s")
// TalinumGenomeDraft // TalinumSamples-STRI // val it: unit = ()
exportStudyToJson investigation "TalinumSamples-STRI"
Export an assay
Section titled Export an assayIn the same manner, we can create a function exportAssayToJson
, which takes an ArcInvestigation
object and a selected assay identifier as inputs and writes the json (of type ARCtrl json) to a file named by the assay identifier with the extension “.arctrl.json”.
In this example, we select “RNASeq” from the available assays.
let exportAssayToJson (a: ArcInvestigation) (assayIdentifier : string) = a.GetAssay assayIdentifier |> ArcAssay.toJsonString 2 |> fun c -> File.WriteAllText(assayIdentifier + ".arctrl.json", c)
// Print all assay identifiers
investigation.AssayIdentifiers |> Seq.iter (printfn "%s")
// MassHunter_targets // RNASeq // GCqTOF_targets // val it: unit = ()
exportAssayToJson investigation "RNASeq"
Export a single table
Section titled Export a single tableInstead of exporting a full study or assay, including all annotation tables and the respective metadata sheet, respectively, you can also export a single annotation table.
let exportArcTableToJson (a: ArcInvestigation) (tableName : string) = let at = investigation.ArcTables at.GetTable tableName |> ArcTable.toJsonString 2 |> fun c -> File.WriteAllText(tableName + ".arctrl.json", c)
// Print all Table Names
investigation.ArcTables.TableNames |> Seq.iter (printfn "%s")
// val it: string list = // ["TalinumGenomeDraft"; "plant_material"; "mh-quant-results"; // "mh-quant-report"; "rna_extraction"; "illumina"; "metabolite_extraction"; // "gas_chromatography"; "mass_spec"]
exportArcTableToJson investigation "rna_extraction"
Download example
Section titled Download exampleYou can download the example script to adapt it to your needs.