Reads a tool's schema.yaml from inst/config/tools/<tool>/ in the
package, exposing the raw/tidy schemas and column maps Tool uses for file
discovery and renaming. Fan-out outputs get their own schema rows, with
parent set to the file table. Schema format: see new-tool article.
Public fields
tool(
character(1))
Tool name.pkg(
character(1))
Package name tool belongs to (for config lookup).
Methods
Method new()
Create a new Config object.
Usage
Config$new(tool, pkg)Arguments
tool(
character(1))
Tool name.pkg(
character(1))
Package name tool belongs to (for config lookup).
Returns
(R6::R6Class())
R6 object.
Method get_globs()
Return all output file globs. Derived tables (no file of
their own, hence no glob) contribute no rows.
Method get_tables()
Return the parsed tables list.
Returns
(list())
Named list of table definitions from schema.yaml.
Method get_output_shape()
Return how strictly an output's tidy columns are checked.
"exact" (default): exactly the columns of one schema version, in
order. "subset": any subset of them, in any order (for outputs whose
columns depend on the data, e.g. wide pivots of the metrics present).
Method get_outputs()
Return every output table the tool writes: the declared
outputs of a fan-out table, or the table itself otherwise.
Method get_schemas_raw()
Return raw schemas for all tables, plus outputs that carry raw column names.
Method get_schema_raw()
Get raw schema for a specific table and optional version.
Method get_schema_tidy()
Get tidy schema for a specific table and optional version.
Examples
tool <- "tool1"
pkg <- "nemo"
conf <- Config$new(tool, pkg)
(patterns <- conf$get_patterns())
#> # A tibble: 6 × 2
#> name pattern
#> <chr> <chr>
#> 1 table1 "\\.tool1\\.table1\\.tsv$"
#> 2 table2 "\\.tool1\\.table2\\.tsv$"
#> 3 table3 "\\.tool1\\.table3\\.tsv$"
#> 4 table4 "\\.tool1\\.table4\\.tsv$"
#> 5 table6 "\\.tool1\\.table6\\.csv$"
#> 6 table7 "\\.tool1\\.table7\\.tsv$"
(globs <- conf$get_globs())
#> # A tibble: 6 × 2
#> name glob
#> <chr> <chr>
#> 1 table1 *.tool1.table1.tsv
#> 2 table2 *.tool1.table2.tsv
#> 3 table3 *.tool1.table3.tsv
#> 4 table4 *.tool1.table4.tsv
#> 5 table6 *.tool1.table6.csv
#> 6 table7 *.tool1.table7.tsv
(ftypes <- conf$get_ftypes())
#> # A tibble: 6 × 2
#> name ftype
#> <chr> <chr>
#> 1 table1 tsv
#> 2 table2 tsv
#> 3 table3 tsv-keyvalue
#> 4 table4 tsv-nohead
#> 5 table6 csv
#> 6 table7 tsv
(pat1 <- conf$get_pattern("table1"))
#> [1] "\\.tool1\\.table1\\.tsv$"
(ftype1 <- conf$get_ftype("table1"))
#> [1] "tsv"
(descr1 <- conf$get_description("table1"))
#> [1] "Table1 for tool1 (tsv: header present, tab-delimited)."
(descr <- conf$get_descriptions())
#> # A tibble: 6 × 2
#> name description
#> <chr> <chr>
#> 1 table1 Table1 for tool1 (tsv: header present, tab-delimited).
#> 2 table2 Table2 for tool1 (tsv: header present, tab-delimited).
#> 3 table3 Table3 for tool1 (tsv-keyvalue: no header, 2 cols, col1=key col2=value…
#> 4 table4 Table4 for tool1 (tsv-nohead: no header, positional cols X1..XN).
#> 5 table6 Table6 for tool1 (csv: header present, comma-delimited).
#> 6 table7 Table7 for tool1 (tsv: one wide row, split into two outputs).
(rs <- conf$get_schemas_raw())
#> # A tibble: 13 × 5
#> name tbl_description version schema parent
#> <chr> <chr> <chr> <list> <chr>
#> 1 table1 Table1 for tool1 (tsv: header present, tab-de… v1.2.3 <tibble> NA
#> 2 table1 Table1 for tool1 (tsv: header present, tab-de… v4.5.6 <tibble> NA
#> 3 table1 Table1 for tool1 (tsv: header present, tab-de… latest <tibble> NA
#> 4 table2 Table2 for tool1 (tsv: header present, tab-de… v1.0.0 <tibble> NA
#> 5 table2 Table2 for tool1 (tsv: header present, tab-de… latest <tibble> NA
#> 6 table3 Table3 for tool1 (tsv-keyvalue: no header, 2 … v1.0.0 <tibble> NA
#> 7 table3 Table3 for tool1 (tsv-keyvalue: no header, 2 … latest <tibble> NA
#> 8 table4 Table4 for tool1 (tsv-nohead: no header, posi… v1.0.0 <tibble> NA
#> 9 table4 Table4 for tool1 (tsv-nohead: no header, posi… latest <tibble> NA
#> 10 table6 Table6 for tool1 (csv: header present, comma-… v1.0.0 <tibble> NA
#> 11 table6 Table6 for tool1 (csv: header present, comma-… latest <tibble> NA
#> 12 table7 Table7 for tool1 (tsv: one wide row, split in… v1.0.0 <tibble> NA
#> 13 table7 Table7 for tool1 (tsv: one wide row, split in… latest <tibble> NA
(ts <- conf$get_schemas_tidy())
#> # A tibble: 17 × 5
#> name tbl_description version schema parent
#> <chr> <chr> <chr> <list> <chr>
#> 1 table1 Table1 for tool1 (tsv: header present, ta… v1.2.3 <tibble> NA
#> 2 table1 Table1 for tool1 (tsv: header present, ta… v4.5.6 <tibble> NA
#> 3 table1 Table1 for tool1 (tsv: header present, ta… latest <tibble> NA
#> 4 table2 Table2 for tool1 (tsv: header present, ta… v1.0.0 <tibble> NA
#> 5 table2 Table2 for tool1 (tsv: header present, ta… latest <tibble> NA
#> 6 table3 Table3 for tool1 (tsv-keyvalue: no header… v1.0.0 <tibble> NA
#> 7 table3 Table3 for tool1 (tsv-keyvalue: no header… latest <tibble> NA
#> 8 table4 Table4 for tool1 (tsv-nohead: no header, … v1.0.0 <tibble> NA
#> 9 table4 Table4 for tool1 (tsv-nohead: no header, … latest <tibble> NA
#> 10 table6 Table6 for tool1 (csv: header present, co… v1.0.0 <tibble> NA
#> 11 table6 Table6 for tool1 (csv: header present, co… latest <tibble> NA
#> 12 table7 Table7 for tool1 (tsv: one wide row, spli… v1.0.0 <tibble> NA
#> 13 table7 Table7 for tool1 (tsv: one wide row, spli… latest <tibble> NA
#> 14 table7main Table7 read counts, one row per sample. v1.0.0 <tibble> table7
#> 15 table7main Table7 read counts, one row per sample. latest <tibble> table7
#> 16 table7dp Table7 fraction of bases at each depth th… v1.0.0 <tibble> table7
#> 17 table7dp Table7 fraction of bases at each depth th… latest <tibble> table7
(s1 <- conf$get_schema_raw("table1"))
#> # A tibble: 15 × 3
#> version field type
#> <chr> <chr> <chr>
#> 1 v1.2.3 SampleID c
#> 2 v1.2.3 Chromosome c
#> 3 v1.2.3 Start i
#> 4 v1.2.3 End i
#> 5 v1.2.3 metricX d
#> 6 v4.5.6 SampleID c
#> 7 v4.5.6 Chromosome c
#> 8 v4.5.6 Start i
#> 9 v4.5.6 End i
#> 10 latest SampleID c
#> 11 latest Chromosome c
#> 12 latest Start i
#> 13 latest End i
#> 14 latest metricY d
#> 15 latest metricZ d
conf$get_schema_raw("table1", version = "v1.2.3")
#> # A tibble: 5 × 3
#> version field type
#> <chr> <chr> <chr>
#> 1 v1.2.3 SampleID c
#> 2 v1.2.3 Chromosome c
#> 3 v1.2.3 Start i
#> 4 v1.2.3 End i
#> 5 v1.2.3 metricX d
conf$get_schema_tidy("table1")
#> # A tibble: 15 × 3
#> version field type
#> <chr> <chr> <chr>
#> 1 v1.2.3 sample_id c
#> 2 v1.2.3 chromosome c
#> 3 v1.2.3 start i
#> 4 v1.2.3 end i
#> 5 v1.2.3 metric_x d
#> 6 v4.5.6 sample_id c
#> 7 v4.5.6 chromosome c
#> 8 v4.5.6 start i
#> 9 v4.5.6 end i
#> 10 latest sample_id c
#> 11 latest chromosome c
#> 12 latest start i
#> 13 latest end i
#> 14 latest metric_y d
#> 15 latest metric_z d
(cm <- conf$get_col_map("table6"))
#> # A tibble: 4 × 4
#> raw tidy type description
#> <chr> <chr> <chr> <chr>
#> 1 GeneId gene_id c Ensembl gene ID
#> 2 GeneName gene_name c gene name
#> 3 AdjTPM tpm_adj d adjusted TPM
#> 4 RawTPM tpm_raw d raw TPM
# table7 fans out into two outputs
(outs <- conf$get_outputs())
#> # A tibble: 7 × 3
#> name table description
#> <chr> <chr> <chr>
#> 1 table1 table1 Table1 for tool1 (tsv: header present, tab-delimited).
#> 2 table2 table2 Table2 for tool1 (tsv: header present, tab-delimited).
#> 3 table3 table3 Table3 for tool1 (tsv-keyvalue: no header, 2 cols, col1=key…
#> 4 table4 table4 Table4 for tool1 (tsv-nohead: no header, positional cols X1…
#> 5 table6 table6 Table6 for tool1 (csv: header present, comma-delimited).
#> 6 table7main table7 Table7 read counts, one row per sample.
#> 7 table7dp table7 Table7 fraction of bases at each depth threshold, long-form.
conf$get_table_outputs("table7")
#> [1] "table7main" "table7dp"
conf$get_schema_tidy("table7dp")
#> # A tibble: 6 × 3
#> version field type
#> <chr> <chr> <chr>
#> 1 v1.0.0 sample_id c
#> 2 v1.0.0 dp d
#> 3 v1.0.0 pct d
#> 4 latest sample_id c
#> 5 latest dp d
#> 6 latest pct d
