R/jd_annotate.R

Defines functions jd_annotate_path jd_annotate

Documented in jd_annotate

#' Extract taxa names. jd_annotate_path() is specifically for phyloseq object containing pseudo-pathway names
#'
#' @param ps A phyloseq object from where the taxa names will be extracted
#' @param df A dataframe, whose rownames are taxa codes
#' @return data frame containing taxonomy names
#' @export
jd_annotate = function(ps, df) {
  toget = df %>% rownames
  taxname = phyloseq::tax_table(ps)[toget,] %>% data.frame
  ordname = taxname$order
  famname = taxname$family
  genname = taxname$genus
  spname = taxname$species
  txname = taxname$taxon
  data = data.frame(order = ordname, family = famname, genus = genname, species = spname, taxon = txname)
  return(data)
}

#' @export
jd_annotate_path = function(ps, df) {
  toget = df %>% rownames
  taxname = phyloseq::tax_table(ps)[toget,] %>% data.frame
  pathname = taxname$pathway
  data = data.frame(pathway = pathname)
  return(data)
}
jdwiyanto/mbiome documentation built on April 18, 2021, 3:31 a.m.