Title: | Reading Portable Encapsulated Projects |
---|---|
Description: | A PEP, or Portable Encapsulated Project, is a dataset that subscribes to the PEP structure for organizing metadata. It is written using a simple YAML + CSV format, it is your one-stop solution to metadata management across data analysis environments. This package reads this standardized project configuration structure into R. Described in Sheffield et al. (2021) <doi:10.1093/gigascience/giab077>. |
Authors: | Nathan Sheffield [aut, cph, cre], Michal Stolarczyk [aut] |
Maintainer: | Nathan Sheffield <[email protected]> |
License: | BSD_2_clause + file LICENSE |
Version: | 0.5.0 |
Built: | 2024-11-18 05:55:21 UTC |
Source: | https://github.com/pepkit/pepr |
"Project"
This method switches between the amendments
within the "Project"
object
activateAmendments(.Object, amendments) ## S4 method for signature 'Project,character' activateAmendments(.Object, amendments)
activateAmendments(.Object, amendments) ## S4 method for signature 'Project,character' activateAmendments(.Object, amendments)
.Object |
an object of class |
amendments |
character with the amendment name |
To check what are the amendments names
call listAmendments(p)
, where p
is the object
of "Project"
class
an object of class "Project"
with activated amendments
activateAmendments(.Object = Project, amendments = character)
: activate amendments in a "Project"
object
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package = "pepr") p = Project(file = projectConfig) availAmendments = listAmendments(p) activateAmendments(p, availAmendments[1])
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package = "pepr") p = Project(file = projectConfig) availAmendments = listAmendments(p) activateAmendments(p, availAmendments[1])
This function checks for the section/nested sections in the config YAML file.
Returns TRUE
if it exist(s) or FALSE
otherwise.
checkSection(object, sectionNames) ## S4 method for signature 'Config' checkSection(object, sectionNames)
checkSection(object, sectionNames) ## S4 method for signature 'Config' checkSection(object, sectionNames)
object |
object of |
sectionNames |
the name of the section or names of the nested sections to look for |
Element indices can be used instead of the actual names, see Examples
.
a logical indicating whether the section exists
checkSection(Config)
: checks for existence of a section in "Config"
objects
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package="pepr") p=Project(projectConfig) checkSection(config(p),sectionNames = c("amendments","newLib")) checkSection(config(p),sectionNames = c("amendments",1))
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package="pepr") p=Project(projectConfig) checkSection(config(p),sectionNames = c("amendments","newLib")) checkSection(config(p),sectionNames = c("amendments",1))
"Project"
This method can be used to view the config slot of
the "Project"
class
config(object) ## S4 method for signature 'Project' config(object)
config(object) ## S4 method for signature 'Project' config(object)
object |
an object of |
project config
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package="pepr") p=Project(projectConfig) config(p)
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package="pepr") p=Project(projectConfig) config(p)
Config objects are used with the "Project"
object
Config(file, amendments = NULL)
Config(file, amendments = NULL)
file |
a character with project configuration yaml file |
amendments |
a character with the amendments names to be activated |
an object of "Config"
class
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package="pepr") c=Config(projectConfig)
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package="pepr") c=Config(projectConfig)
This funciton collects the samples from a data.table-class
object that
fulfill the requirements of an attribute attr
specified with
the fun
argument
fetchSamples(samples, attr = NULL, func = NULL, action = "include")
fetchSamples(samples, attr = NULL, func = NULL, action = "include")
samples |
an object of |
attr |
a string specifying a column in the |
func |
an anonymous function, see Details for more information |
action |
a string (either |
The anonymous function provided in the func
argument has to return an integer that indicate the rows that the action
should be performed on.
Core expressions which are most useful to implement the anonymous function are:
an object of data.table-class
class filtered according to specified requirements
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package="pepr") p = Project(projectConfig) s = sampleTable(p) fetchSamples(s,attr = "sample_name", func=function(x){ which(x=="pig_0h") },action="include") fetchSamples(s,attr = "sample_name", func=function(x){ which(x=="pig_0h") },action="exclude") fetchSamples(s,attr = "sample_name", func=function(x){ grep("pig_",x) },action="include")
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package="pepr") p = Project(projectConfig) s = sampleTable(p) fetchSamples(s,attr = "sample_name", func=function(x){ which(x=="pig_0h") },action="include") fetchSamples(s,attr = "sample_name", func=function(x){ which(x=="pig_0h") },action="exclude") fetchSamples(s,attr = "sample_name", func=function(x){ grep("pig_",x) },action="include")
This method extracts the samples
getSample(.Object, sampleName) ## S4 method for signature 'Project,character' getSample(.Object, sampleName)
getSample(.Object, sampleName) ## S4 method for signature 'Project,character' getSample(.Object, sampleName)
.Object |
An object of Project class |
sampleName |
character the name of the sample |
data.table one row data table with the sample associated metadata
getSample(.Object = Project, sampleName = character)
: extracts the sample from the "Project"
object
projectConfig = system.file( "extdata", "example_peps-master", "example_basic", "project_config.yaml", package = "pepr" ) p = Project(projectConfig) sampleName = "frog_1" getSample(p, sampleName)
projectConfig = system.file( "extdata", "example_peps-master", "example_basic", "project_config.yaml", package = "pepr" ) p = Project(projectConfig) sampleName = "frog_1" getSample(p, sampleName)
This method extracts the subsamples
getSubsample(.Object, sampleName, subsampleName) ## S4 method for signature 'Project,character,character' getSubsample(.Object, sampleName, subsampleName)
getSubsample(.Object, sampleName, subsampleName) ## S4 method for signature 'Project,character,character' getSubsample(.Object, sampleName, subsampleName)
.Object |
An object of Project class |
sampleName |
character the name of the sample |
subsampleName |
character the name of the subsample |
data.table one row data table with the subsample associated metadata
getSubsample(
.Object = Project,
sampleName = character,
subsampleName = character
)
: extracts the subsamples from the "Project"
object
projectConfig = system.file( "extdata", "example_peps-master", "example_subtable1", "project_config.yaml", package = "pepr" ) p = Project(projectConfig) sampleName = "frog_1" subsampleName = "sub_a" getSubsample(p, sampleName, subsampleName)
projectConfig = system.file( "extdata", "example_peps-master", "example_subtable1", "project_config.yaml", package = "pepr" ) p = Project(projectConfig) sampleName = "frog_1" subsampleName = "sub_a" getSubsample(p, sampleName, subsampleName)
Lists available amendments within a "Project"
object.
listAmendments(.Object) ## S4 method for signature 'Project' listAmendments(.Object)
listAmendments(.Object) ## S4 method for signature 'Project' listAmendments(.Object)
.Object |
an object of |
The amendments can be activated by passing their names to the activateAmendments
method
names of the available amendments
listAmendments(Project)
: list amendments in a "Project"
object
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package = "pepr") p = Project(file = projectConfig) availAmendemtns = listAmendments(p)
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package = "pepr") p = Project(file = projectConfig) availAmendemtns = listAmendments(p)
Make selected sections absolute using config path
makeSectionsAbsolute(object, sections, cfgPath) ## S4 method for signature 'Config,character,character' makeSectionsAbsolute(object, sections, cfgPath)
makeSectionsAbsolute(object, sections, cfgPath) ## S4 method for signature 'Config,character,character' makeSectionsAbsolute(object, sections, cfgPath)
object |
|
sections |
character set of sections to make absolute |
cfgPath |
character absolute path to the config YAML file |
Config with selected sections made absolute
makeSectionsAbsolute(
object = Config,
sections = character,
cfgPath = character
)
: Make selected sections absolute using config path from "Project"
Package documentation
Michal Stolarczyk, Nathan Sheffield
GitHub: https://github.com/pepkit/pepr, Documentation: https://code.databio.org/pepr/
This is a helper that creates the project with empty samples and config slots
Project( file = NULL, amendments = NULL, sampleTableIndex = NULL, subSampleTableIndex = NULL )
Project( file = NULL, amendments = NULL, sampleTableIndex = NULL, subSampleTableIndex = NULL )
file |
a string specifying a path to a project configuration YAML file |
amendments |
a string with the amendments names to be activated |
sampleTableIndex |
a string indicating the sample attribute that is used to index the sample table |
subSampleTableIndex |
a string indicating the sample attribute that is used to index the sample table |
an object of "Project"
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package="pepr") p=Project(projectConfig)
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package="pepr") p=Project(projectConfig)
Provides an in-memory representation and functions to access project configuration and sample annotation values for a PEP.
Can be created with the constructor: "Project"
file
character vector path to config file on disk.
samples
a data table object holding the sample metadata
config
a list object holding contents of the config file
sampleNameAttr
a string indicating the sample attribute that is used to index the sample table
subSampleNameAttr
a string indicating the sample attribute that is used to index the sample table
"Project"
This method can be used to view the samples slot
of the "Project"
class
sampleTable(object) ## S4 method for signature 'Project' sampleTable(object)
sampleTable(object) ## S4 method for signature 'Project' sampleTable(object)
object |
an object of |
a data.table with the with metadata about samples
sampleTable(Project)
: extract sample table from a "Project"
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package="pepr") p=Project(projectConfig) sampleTable(p)
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package="pepr") p=Project(projectConfig) sampleTable(p)
"Config"
object elementsYou can subset Config by identifier or by position using the
`[`
, `[[`
or `$`
operator.
The string will be expanded if it's a path.
## S4 method for signature 'Config' x[i] ## S4 method for signature 'Config' x[[i]] ## S4 method for signature 'Config' x$name
## S4 method for signature 'Config' x[i] ## S4 method for signature 'Config' x[[i]] ## S4 method for signature 'Config' x$name
x |
a |
i |
position of the identifier or the name of the identifier itself. |
name |
name of the element to access. |
An element held in "Config"
object
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package="pepr") c=Config(projectConfig) c[[2]] c[2] c[["sample_table"]] c$sample_table
projectConfig = system.file("extdata", "example_peps-master", "example_amendments1", "project_config.yaml", package="pepr") c=Config(projectConfig) c[[2]] c[2] c[["sample_table"]] c$sample_table