fetchSamples: Collect samples fulfilling the specified requirements

View source: R/utils.R

fetchSamplesR Documentation

Collect samples fulfilling the specified requirements

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

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:

  • which with inequality signs: ==,>,<

  • grep

Value

an object of data.table-class class filtered according to specified requirements

Examples

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")

pepr documentation built on Nov. 21, 2023, 5:06 p.m.