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")an object of data.table-class class
a string specifying a column in the samples
an anonymous function, see Details for more information
a string (either include or exclude) that specifies whether the function should select the row or exclude it.
an object of data.table-class class filtered according to specified requirements
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:
projectConfig = system.file("extdata", "example_peps-master",
"example_amendments1", "project_config.yaml", package="pepr")
p = Project(projectConfig)
#> Loading config file: /home/runner/work/_temp/Library/pepr/extdata/example_peps-master/example_amendments1/project_config.yaml
#> amendments: newLib,newLib2
s = sampleTable(p)
fetchSamples(s,attr = "sample_name", func=function(x){ which(x=="pig_0h") },action="include")
#> sample_name protocol organism time file_path
#> 1: pig_0h RRBS pig 0 /data/lab/project/pig_0h.fastq
fetchSamples(s,attr = "sample_name", func=function(x){ which(x=="pig_0h") },action="exclude")
#> Empty data.table (0 rows and 5 cols): sample_name,protocol,organism,time,file_path
fetchSamples(s,attr = "sample_name", func=function(x){ grep("pig_",x) },action="include")
#> sample_name protocol organism time file_path
#> 1: pig_0h RRBS pig 0 /data/lab/project/pig_0h.fastq
#> 2: pig_1h RRBS pig 1 /data/lab/project/pig_1h.fastq