fetchSamples: Collect samples fulfilling the specified requirements

Description Usage Arguments Details Examples

View source: R/utils.R

Description

This funciton collects the samples from a data.table-class object that fulfill the requirements of an attribute attr specified with the fun argument

Usage

1
fetchSamples(samples, attr = NULL, func = NULL, action = "include")

Arguments

samples

an object of data.table-class class

attr

a string specifying a column in the samples

func

an anonymous function, see Details for more information

action

a string (either include or exclude) that specifies whether the function should select the row or exclude it.

Details

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:

Examples

1
2
3
4
5
6
7
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")

Example output

Registered S3 method overwritten by 'pryr':
  method      from
  print.bytes Rcpp
Loading config file: /usr/lib/R/site-library/pepr/extdata/example_peps-master/example_amendments1/project_config.yaml
  amendments: newLib,newLib2
   sample_name protocol organism time                      file_path
1:      pig_0h     RRBS      pig    0 /data/lab/project/pig_0h.fastq
Empty data.table (0 rows and 5 cols): sample_name,protocol,organism,time,file_path
   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

pepr documentation built on Jan. 13, 2021, 3:50 p.m.