read_midas_data: Read midas snp merge data

Description Usage Arguments Value Examples

View source: R/midas_data.r

Description

Reads the output of midas_merge.py

Usage

1
read_midas_data(midas_dir, map = NULL, genes = NULL, cds_only = TRUE)

Arguments

midas_dir

Directory where the output from midas_merge.py is located. It must include files: 'snps_info.txt', 'snps_depth.txt' and 'snps_freq.txt'.

map

A data table associating samples in the MIDAS otput to groups. It must have an 'sample' and a 'Group' column.

genes

The list of genes that are to be tested. Must correspond to entries in the 'genes_id' column of the 'snps_info.txt' file. If NULL, all genes will be tested.

cds_only

If TRUE, it will remove all sites that do not have a gene_id. If a gene list is passed its effect is redundant.

Value

A list with three data tables: info, freq and depth, corresponding to the three files from MIDAS

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(HMVAR)
library(tidyverse)

# Get file paths
midas_dir <- system.file("toy_example/merged.snps/", package = "HMVAR")
map <- read_tsv(system.file("toy_example/map.txt", package = "HMVAR"),
                col_types = cols(.default = col_character())) %>%
  select(sample = ID, Group)

# Read data
midas_data <- read_midas_data(midas_dir = midas_dir, map = map, cds_only = TRUE)
midas_data

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