R/get_microbiome_data.R

Defines functions get_microbiome_data

Documented in get_microbiome_data

#' @title Download test microbiome data
#' @description Test microbiome data in phyloseq format.
#' @details You can download few example datasets in phyloseq format from Duvallet et al 2017 https://www.nature.com/articles/s41467-017-01973-8.pdf?origin=ppub. The source file for these data is the microbiomedatarepo https://github.com/microsud/microbiomedatarepo.
#' @param disease Disease of interest as shown in list_microbiome_data()
#' @param study Name of the study as shown in list_microbiome_data()
#' @return \code{\link{phyloseq-class}} object.
#' @import microbiome
#' @import phyloseq
#' @export
#' @examples
#' \dontrun{
#' # Example data
#' library(microbiome)
#' library(microbiomeUtilities)
#' list_microbiome_data()
#' ps1 <- get_microbiome_data(disease = "CDI", "Schubert2014_CDI")
#' print_ps(ps1)
#' }
#' @keywords utilities
get_microbiome_data <- function(disease, study) {
  if (grepl(disease, study) == FALSE) {
    stop("Disease-Study combination does not exists, check list_microbiome()")
  }

  fileloc <-
    paste0(
      "https://github.com/microsud/microbiomedatarepo/blob/master/datasets/microbiomeDB/",
      disease,
      "/",
      study,
      ".rds?raw=true"
    )

  psX <- readRDS(url(fileloc))

  return(psX)
}
microsud/microbiomeutilities documentation built on Nov. 29, 2022, 12:18 a.m.