This function creates a Project-class object, and executes the user provided function with the created object as a first argument.

If the custom data processing function returns an object of class other than Annotated-class, the output will be packaged in a List-class with a metadata slot populated with the Project-class.

BiocProject(
  file,
  amendments = NULL,
  autoLoad = TRUE,
  func = NULL,
  funcArgs = NULL
)

Arguments

file

a character vector with a path to the PEP config file

amendments

a character vector with a name of the amendments to be activated

autoLoad

a logical indicating whether the data should be loaded automatically. See Details for more information.

func

a anonymous function that reads and/or processes the data, it must take the Project-class as an argument. See Details for more information

funcArgs

a named list with arguments you want to pass to the func. The PEP will be passed automatically, but if provided regardless, the constructor will disregard it. You can also pass the arguments in a funcArgs section within the bioconductor section in the config file.

Value

an object of Annotated-class that is returned by the user provided function with the Project-class object inserted into the first element of the list in its medatada slot

Details

This BiocProject function provides some degree of flexibility in your custom data processing function usage and implementation. Consider the possibilities listed below:

  • use a function loaded into the R environment and specified in the config slot in Project-class (specifically: config(project)$bioconductor$readFunName).

  • use a function not loaded into the R environment and specified in the config slot in Project (specifically: config(project)$bioconductor$readFunPath).

  • use a function from other R package not loaded into the R environment and specified in the config slot in Project (specifically: config(project)$bioconductor$readFunName), like: pkgName::functionName

  • use a function implemented in the BiocProject call (passed to the func argument - anonymous function). This option is given the top priority and overrides other arguments if provided.

The custom data processing function must take the Project-class as an argument since this object will be passed to the function by default. However, if the function requires additional arguments, ones can be provided with the funcArgs argument in the BiocProject function call. Besides, the func argument with the anonymous function may serve similar possibility.

If the autoLoad is set to FALSE the data will not be loaded and empty Project-class object will be returned.

Note

The bioconductor section can be read from the project config file or pipeline interface. The former is given the priority

Further reading

Browse the BiocProject package vignettes for more detailed explanation with examples.

See also

Examples

projectConfig = system.file("extdata", "example_peps-master", "example_BiocProject", "project_config.yaml", package="BiocProject") bp=BiocProject(projectConfig)
#> Loading config file: /tmp/Rtmpp7Kvae/temp_libpath658d0e8e5/BiocProject/extdata/example_peps-master/example_BiocProject/project_config.yaml
#> Function 'readBedFiles' read from file '/tmp/Rtmpp7Kvae/temp_libpath658d0e8e5/BiocProject/extdata/example_peps-master/example_BiocProject/readBedFiles.R'
bp
#> GRangesList object of length 2: #> $laminB1Lads #> GRanges object with 1302 ranges and 0 metadata columns: #> seqnames ranges strand #> <Rle> <IRanges> <Rle> #> [1] chr1 11401198-11694590 * #> [2] chr1 14877629-15246452 * #> [3] chr1 18229570-19207602 * #> [4] chr1 29618442-31162049 * #> [5] chr1 33943885-35623392 * #> ... ... ... ... #> [1298] chrX 154066672-154251301 * #> [1299] chrY 2880166-7112793 * #> [1300] chrY 15047033-15333970 * #> [1301] chrY 15603977-16627892 * #> [1302] chrY 16966225-21013116 * #> ------- #> seqinfo: 24 sequences from an unspecified genome; no seqlengths #> #> $vistaEnhancers #> GRanges object with 1339 ranges and 0 metadata columns: #> seqnames ranges strand #> <Rle> <IRanges> <Rle> #> [1] chr1 3190581-3191428 * #> [2] chr1 8130439-8131887 * #> [3] chr1 10593123-10594209 * #> [4] chr1 10732070-10733118 * #> [5] chr1 10757664-10758631 * #> ... ... ... ... #> [1335] chrX 139380916-139382199 * #> [1336] chrX 139593502-139594774 * #> [1337] chrX 139674499-139675403 * #> [1338] chrX 147829016-147830159 * #> [1339] chrX 150407692-150409052 * #> ------- #> seqinfo: 24 sequences from an unspecified genome; no seqlengths #>
metadata(bp)
#> $PEP #> PEP project object. Class: Project #> file: #> /tmp/Rtmpp7Kvae/temp_libpath658d0e8e5/BiocProject/extdata/example_peps-master/example_BiocProject/project_config.yaml #> samples: 2 #>