From ceec784515ea5fc80329db8e27593f6ed8a97a2e Mon Sep 17 00:00:00 2001 From: "Zachary S.L Foster" Date: Tue, 1 May 2018 15:05:01 -0700 Subject: [PATCH] fixed a few examples --- R/heat_tree.R | 2 +- R/parsers.R | 5 +++-- R/primersearch.R | 7 +++---- man/heat_tree.Rd | 2 +- man/primersearch.Rd | 7 +++---- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/R/heat_tree.R b/R/heat_tree.R index 5ed46e4..4fe56c8 100644 --- a/R/heat_tree.R +++ b/R/heat_tree.R @@ -363,7 +363,7 @@ heat_tree.Taxmap <- function(.input, ...) { #' # You can plot up to 4 quantative variables use node/edge size/color, but it #' # is usually best to use 2 or 3. The plot below uses node size for number of #' # OTUs and color for number of reads and edge size for number of samples -#' x$data$taxon_counts <- calc_n_samples(x, dataset = "taxon_counts", append = TRUE) +#' x$data$n_samples <- calc_n_samples(x, dataset = "taxon_counts") #' heat_tree(x, node_label = taxon_names, node_size = n_obs, node_color = total, #' edge_color = n_samples) #' diff --git a/R/parsers.R b/R/parsers.R index 76997a2..b564bc4 100644 --- a/R/parsers.R +++ b/R/parsers.R @@ -573,16 +573,17 @@ parse_silva_fasta <- function(file = NULL, input = NULL, include_seqs = TRUE) { raw_headers <- names(raw_data) # Make classifications easier to parse - name_chars <- "A-Za-z0-9._+ \\-" + name_chars <- "A-Za-z0-9._+ ='\"\\-" parts <- stringr::str_match(raw_headers, paste0("^(.+;)([", name_chars, "]+)(\\(?.*\\)?)$")) parts <- as.data.frame(parts[, -1], stringsAsFactors = FALSE) colnames(parts) <- c("tax", "binom", "common") parts$binom <- sub(parts$binom, pattern = "sp\\. ", replacement = "sp\\._") parts$binom <- sub(parts$binom, pattern = "uncultured ", replacement = "uncultured_") - parts$binom <- gsub(pattern = " ", replacement = ";", parts$binom) + # parts$binom <- gsub(pattern = " ", replacement = ";", parts$binom) parts$binom <- sub(pattern = ";$", replacement = " ", parts$binom) headers <- apply(parts, MARGIN = 1, paste0, collapse = "") + headers <- gsub(headers, pattern = "\\[|\\]", replacement = "") # Create taxmap object output <- taxa::extract_tax_data(tax_data = headers, diff --git a/R/primersearch.R b/R/primersearch.R index 89410cd..c48520c 100644 --- a/R/primersearch.R +++ b/R/primersearch.R @@ -210,10 +210,9 @@ parse_primersearch <- function(file_path) { #' #' # Visualize which taxa were amplified #' # This work because only amplicons are returned by `primersearch` -#' n_amplified <- obj$obs_apply("pcr", -#' function(x) length(unique(x)), -#' value = "input", -#' simplify = TRUE) +#' n_amplified <- unlist(obj$obs_apply("pcr", +#' function(x) length(unique(x)), +#' value = "input")) #' prop_amped <- n_amplified / obj$n_obs() #' heat_tree(obj, #' node_label = taxon_names, diff --git a/man/heat_tree.Rd b/man/heat_tree.Rd index 710c523..784c814 100644 --- a/man/heat_tree.Rd +++ b/man/heat_tree.Rd @@ -412,7 +412,7 @@ heat_tree(x, node_label = taxon_names, node_size = total, node_color = total) # You can plot up to 4 quantative variables use node/edge size/color, but it # is usually best to use 2 or 3. The plot below uses node size for number of # OTUs and color for number of reads and edge size for number of samples -x$data$taxon_counts <- calc_n_samples(x, dataset = "taxon_counts", append = TRUE) +x$data$n_samples <- calc_n_samples(x, dataset = "taxon_counts") heat_tree(x, node_label = taxon_names, node_size = n_obs, node_color = total, edge_color = n_samples) diff --git a/man/primersearch.Rd b/man/primersearch.Rd index 4b7cd17..1a47c9c 100644 --- a/man/primersearch.Rd +++ b/man/primersearch.Rd @@ -156,10 +156,9 @@ obj$data$pcr$taxon_id <- obj$data$tax_data$taxon_id[pcr_result$input] # Visualize which taxa were amplified # This work because only amplicons are returned by `primersearch` -n_amplified <- obj$obs_apply("pcr", - function(x) length(unique(x)), - value = "input", - simplify = TRUE) +n_amplified <- unlist(obj$obs_apply("pcr", + function(x) length(unique(x)), + value = "input")) prop_amped <- n_amplified / obj$n_obs() heat_tree(obj, node_label = taxon_names,