read-tbl: Read MIPTools tables

read-tblR Documentation

Read MIPTools tables

Description

The ⁠read_tbl_*()⁠ family of functions is designed to read data tables generated by the software program MIPTools. Data is read lazily using the vroom package. Data can be filtered, retaining all rows that satisfy the conditions. To be retained, the row in question must produce a value of TRUE for all conditions. Note that when a condition evaluates to NA, the row will be dropped.

Usage

read_tbl_reference(.tbl, ...)

read_tbl_alternate(.tbl, ...)

read_tbl_coverage(.tbl, ...)

read_tbl_genotype(.tbl, ...)

read_tbl_haplotype(.tbl, ..., .col_select = NULL)

read_tbl_ref_alt_cov(
  .tbl_ref,
  .tbl_alt,
  .tbl_cov,
  ...,
  chrom = deprecated(),
  gene = deprecated()
)

Arguments

.tbl

File path to the table.

...

<data-masking> Filtering expressions. Expressions must return a logical value. If multiple expressions are included, they are combined with the & operator. Only rows for which all conditions evaluate to TRUE are kept.

.col_select

Columns to include in the results. Columns can be selected using one or more selection expressions as in dplyr::select(). Use c() or list() to use more than one expression. See ?tidyselect::language for details on available selection options.

.tbl_ref

File path to the reference table.

.tbl_alt

File path to the alternate table.

.tbl_cov

File path to the coverage table.

chrom

[Deprecated] The chromosome(s) to filter to.

gene

[Deprecated] The gene(s) to filter to.

Value

A tibble() subclass. Each function defines a unique subclass to store the data. Data typically contains the sample, associated metadata, and the value of interest.

Data structure

Input data must contain six rows of metadata. The metadata can vary depending on what type of file is read, but typically contains information about the location of a mutation. The remaining rows represent the data for each sample sequenced.

Useful filter functions

The dplyr::filter() function is employed to subset the rows of the data by applying the expressions in ... to the column values to determine which rows should be retained.

There are many functions and operators that are useful when constructing the expressions used to filter the data:

  • ==, >, >=, etc.

  • &, |, !, xor()

  • is.na()

  • between(), near()

See Also

vroom::vroom() dplyr::filter()

Examples

# Get path to example file
ref_file <- miplicorn_example("reference_AA_table.csv")
alt_file <- miplicorn_example("alternate_AA_table.csv")
cov_file <- miplicorn_example("coverage_AA_table.csv")
ref_file

# Input sources -------------------------------------------------------------
# Read from a path
read_tbl_reference(ref_file)

# You can also use paths directly
# read_tbl_alternate("alternate_AA_table.csv")

# Read entire file ----------------------------------------------------------
read_tbl_coverage(cov_file)

# Data filtering ------------------------------------------------------------
# Filtering by one criterion
read_tbl_reference(ref_file, gene == "atp6")

# Filtering by multiple criteria within a single logical expression
read_tbl_alternate(alt_file, gene == "atp6" & targeted == "Yes")
read_tbl_coverage(cov_file, gene == "atp6" | targeted == "Yes")

# When multiple expressions are used, they are combined using &
read_tbl_reference(ref_file, gene == "atp6", targeted == "Yes")

# Read multiple files together ----------------------------------------------
read_tbl_ref_alt_cov(ref_file, alt_file, cov_file)

bailey-lab/miplicorn documentation built on March 19, 2023, 7:40 p.m.