match_freq_and_depth: Match freq and depth

Description Usage Arguments Value Examples

View source: R/midas_data.r

Description

Takes two data.frames or tibbles representing site x sample allele frequencies (freq) and sequence coverage (depth), and used gather to convert them into a tibble with one line per site per sample. It combines both sources of info into one table, it filters out positions below a sequencing depth threshold, and if another data table with metadata (info) about the sites is passed, it also joins that information into the sites that passed the threshold.

Usage

1
2
3
4
5
6
7
8
match_freq_and_depth(
  freq,
  depth,
  info = NULL,
  map = NULL,
  depth_thres = 1,
  verbose = TRUE
)

Arguments

freq

A site by sample data frame or tibble. Must contain a column named "site_id".

depth

A site by sample data frame or tibble. Must containa a column named "site_id".

info

A site by variable data frame or tibble. Must contain a column named "site_id".

map

A sample by variable data frame or tibble. Must conatin a colum named "sample".

depth_thres

Minimum sequence coverage (depth) for a site to be kept in the final output.

verbose

logical indicating whether progress messages should be printed.

Value

A data frame or tibble with columns site_id, freq, depth, and one column per column in info and map.

Examples

1
2
3
4
5
6
7
freq <- tibble::tibble(site_id = paste('snv' , 1:4, sep = ""),
                       sample1 = c(1,1,0,1), sample2 = c(1,1,1,1),
                       sample3=c(0,0,0,1))
depth <- tibble::tibble(site_id = paste('snv' , 1:4, sep = ""),
                        sample1 = c(1,0,1,1), sample2 = c(4,1,1,0),
                        sample3=c(0,0,0,1))
match_freq_and_depth(freq, depth, depth_thres = 1)

surh/HMVAR documentation built on Aug. 18, 2021, 1:21 a.m.