Skip to content

Commit 4009fe6

Browse files
added uBiome parser
1 parent a98efef commit 4009fe6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+221
-55
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: metacoder
22
Title: Tools for Parsing, Manipulating, and Graphing Taxonomic Abundance Data
3-
Version: 0.2.1.9011
3+
Version: 0.2.1.9012
44
Authors@R: c(person("Zachary", "Foster", email =
55
"[email protected]", role = c("aut", "cre")),
66
person("Niklaus", "Grunwald", email =
@@ -58,7 +58,7 @@ Suggests:
5858
BiocInstaller,
5959
zlibbioc
6060
VignetteBuilder: knitr
61-
RoxygenNote: 6.0.1
61+
RoxygenNote: 6.1.0
6262
Date: 2018-05-01
6363
Encoding: UTF-8
6464
biocViews:

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export(parse_phyloseq)
3636
export(parse_qiime_biom)
3737
export(parse_rdp)
3838
export(parse_silva_fasta)
39+
export(parse_ubiome)
3940
export(parse_unite_general)
4041
export(primersearch)
4142
export(primersearch_raw)

R/calculations.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ compare_groups <- function(obj, data, cols, groups,
610610
median_1 <- stats::median(abund_1, na.rm = TRUE)
611611
median_2 <- stats::median(abund_2, na.rm = TRUE)
612612
log_ratio <- log2(median_1 / median_2)
613-
if (is.nan(log_ratio)) {
613+
if (is.nan(log_ratio) | is.na(log_ratio)) {
614614
log_ratio <- 0
615615
}
616616
list(log2_median_ratio = log_ratio,

R/parsers.R

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,3 +732,58 @@ parse_phylo <- function(obj) {
732732
output$data <- c(output$data, list(tax_data = tax_data))
733733
output$replace_taxon_ids(convert_base(as.integer(output$taxon_ids())))
734734
}
735+
736+
737+
738+
739+
#' Converts the uBiome file format to taxmap
740+
#'
741+
#' Converts the uBiome file format to taxmap. NOTE: This is experimental and might not work if
742+
#' uBiome changes their format. Contact the maintainers if you encounter problems/
743+
#'
744+
#' The input file has a format like:
745+
#'
746+
#' \preformatted{
747+
#' tax_name,tax_rank,count,count_norm,taxon,parent
748+
#' root,root,29393,1011911,1,
749+
#' Bacteria,superkingdom,29047,1000000,2,131567
750+
#' Campylobacter,genus,23,791,194,72294
751+
#' Flavobacterium,genus,264,9088,237,49546
752+
#' }
753+
#'
754+
#' @param file (\code{character} of length 1) The file path to the input file.
755+
#' Either "file", or "table" must be used, but only one.
756+
#' @param table (\code{character} of length 1) An already parsed data.frame or
757+
#' tibble. Either "file", or "table" must be used, but only one.
758+
#'
759+
#' @return \code{\link{taxmap}}
760+
#'
761+
#' @family parsers
762+
#'
763+
#' @export
764+
parse_ubiome <- function(file = NULL, table = NULL) {
765+
766+
# Check that `file` and `text` and `table` are not used together
767+
are_missing <- c(file = is.null(file),
768+
text = is.null(table))
769+
if (sum(are_missing) != 1) {
770+
stop(paste0('Either "file" or "table" must be supplied, but not both.'))
771+
}
772+
773+
# Read raw data
774+
if (is.null(file)) {
775+
raw_data <- table
776+
} else {
777+
raw_data <- readr::read_csv(file)
778+
}
779+
780+
# Make taxmap object
781+
output <- parse_edge_list(input = raw_data,
782+
taxon_id = "taxon",
783+
supertaxon_id = "parent",
784+
taxon_name = "tax_name",
785+
taxon_rank = "tax_rank")
786+
787+
return(output)
788+
}
789+

man/ambiguous_patterns.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/calc_group_mean.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/calc_group_median.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/calc_group_rsd.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/calc_group_stat.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/calc_n_samples.Rd

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)