list2df: Apply a function to items in list and combine into data frame

Description Usage Arguments Value Author(s) Examples

Description

list2df is a helper function that takes a named list and applies a function to each element, and combines the resulting data frames into a single data frame. The output data frame will have an additional column named sample indicating which element the data came from.

Usage

1
  list2df(x, fun)

Arguments

x

a named list of objects.

fun

a function that takes in the elements of x and outputs a data frame.

Value

A data frame made by applying fun to each element of the list x. An additional column named sample will indicate which element the data came from.

Author(s)

Vince Buffalo <vsbuffalo@ucdavis.edu>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
  ## Get some sequence files
  sq.files = list.files(system.file('extdata', package='qrqc'),
    pattern="test.*fastq", full.names=TRUE)
  names(sq.files) <- gsub("(.*)\\.fastq", "\1", basename(sq.files))
  sq <- lapply(sq.files, readSeqFile)


  ## Take the FASTQSummary objects, extract quality data from each of
  ## the, and combine.
  d <- list2df(sq, getQual)

  ## Look at difference in average quality
  aggregate(d$mean, list(sample=d$sample), mean)

  ## Look at difference in variance - this is where we really see a
  ## change.
  aggregate(d$mean, list(sample=d$sample), var)

qrqc documentation built on Nov. 8, 2020, 7:03 p.m.