pull_lev: Shorten long taxa names

Description Usage Arguments Value Examples

View source: R/pull_lev.R

Description

pull_lev is designed to work with Taxa names that contain multiple taxonomy levels. The function splits Taxa names using str_split, then grabs the string in position l or higher. If nothing exists at or past position l, the function will add "Unclassified" to the last position. The function skips over any Taxa named "Other".

Usage

1
pull_lev(Taxa, l, sep = "/")

Arguments

Taxa

Taxa names with taxonomic rank separated by some character

l

Numeric. Position / taxonomic rank. Best if it is the highest rank in Taxa names

sep

Character to split

Value

A character string

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data(bpd_fam); data(bpd_clin)
set <- tidy_micro(otu_tabs = bpd_fam, clinical = bpd_clin, tab_names = "Family",
prev_cutoff = 5, ra_cutoff = 1, exclude_taxa = "Bacteria",
count_summary = FALSE, filter_summary = FALSE) %>%
filter(day == 7)

## Taxa names
pull_lev(unique(set$Taxa), 4)

## Most useful to clean up plots ##

# Hard to read!
(ch <- cor_heatmap(set, table = "Family", weight, gestational_age))

# Much better
ch$data$Taxa <- pull_lev(ch$data$Taxa,4)
ch

CharlieCarpenter/tidyMicro documentation built on April 25, 2021, 4:09 p.m.