Skip to contents

Parses files.

Usage

parse_file(fpath, pname, schemas_all, delim = "\t", ...)

Arguments

fpath

(character(1))
File path.

pname

(character(1))
Parser name (e.g. "breakends" - see docs).

schemas_all

(tibble())
Tibble with name, version and schema list-col.

delim

(character(1))
File delimiter.

...

Passed on to readr::read_delim.

Examples

path <- system.file("extdata/tool1", package = "nemo")
x <- Tool$new("tool1", pkg = "nemo", path)
schemas_all <- x$config$get_schemas_raw()
f <- function(ver, tbl) file.path(path, ver, paste0("sampleA.tool1.", tbl, ".tsv"))
# table1: three versions with different column sets
(d1_v123 <- parse_file(f("v1.2.3", "table1"), "table1", schemas_all))
#> # A tibble: 3 × 5
#>   SampleID Chromosome Start   End metricX
#>   <chr>    <chr>      <int> <int>   <dbl>
#> 1 sampleA  chr1          10    50     0.1
#> 2 sampleA  chr2         100   500     0.2
#> 3 sampleA  chr3        1000  5000     0.3
(d1_v456 <- parse_file(f("v4.5.6", "table1"), "table1", schemas_all))
#> # A tibble: 3 × 4
#>   SampleID Chromosome Start   End
#>   <chr>    <chr>      <int> <int>
#> 1 sampleA  chr1          10    50
#> 2 sampleA  chr2         100   500
#> 3 sampleA  chr3        1000  5000
(d1_lat  <- parse_file(f("latest", "table1"), "table1", schemas_all))
#> # A tibble: 3 × 6
#>   SampleID Chromosome Start   End metricY metricZ
#>   <chr>    <chr>      <int> <int>   <dbl>   <dbl>
#> 1 sampleA  chr1          10    50     0.4     0.7
#> 2 sampleA  chr2         100   500     0.5     0.8
#> 3 sampleA  chr3        1000  5000     0.6     0.9
# table2: two versions (v1.0.0 drops metricB)
(d2_v1  <- parse_file(f("v1.0.0", "table2"), "table2", schemas_all))
#> # A tibble: 3 × 2
#>   SampleID metricA
#>   <chr>    <chr>  
#> 1 sampleA  a      
#> 2 sampleA  b      
#> 3 sampleA  c      
(d2_lat <- parse_file(f("latest", "table2"), "table2", schemas_all))
#> # A tibble: 3 × 3
#>   SampleID metricA metricB
#>   <chr>    <chr>     <dbl>
#> 1 sampleA  a         12.3 
#> 2 sampleA  b          4.56
#> 3 sampleA  c          7.89