assert_chr: Check that input contains a CHR column with values that look...

Description Usage Arguments Value Examples

Description

Check that input contains a CHR column with values that look like (human) contigs

Usage

1
assert_chr(data, on_error = on_error_options)

Arguments

data

a dataframe that has a column CHR which will be validated

on_error

if data does _not_ validate, whether to show the reasons and whether to throw: all: show all the problems and throw an exception none: don't show anything, but throw an exception summary: show a summary and throw an exception tell: just return TRUE if OK and FALSE if invalid

Value

TRUE if data is valid and FALSE if invalid (only when "on_error" == "tell")

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
assert_chr(data.frame(CHR=c("1","2"))) # TRUE

assert_chr(data.frame(contig="1"),on_error="tell") # FALSE: column name needs to be "CHR"

assert_chr(data.frame(CHR=c("chr1","chr2"))) # TRUE

# contigs should either all have "chr" or all not have it
assert_chr(data.frame(CHR=c("1", "chr2")), on_error="tell") # FALSE 

# value needs to be 1-22, X,Y or with "chr" prefix.
assert_chr(data.frame(CHR="hello"),on_error="tell") # FALSE  

richardslab/MRutils documentation built on Dec. 22, 2021, 4 p.m.