## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
options(rmarkdown.html_vignette.check_title = FALSE)

## ----setup--------------------------------------------------------------------
library(pathdb)

## ----data---------------------------------------------------------------------
head(hypoxia_reads)

## ----search_species, eval = FALSE---------------------------------------------
# srch_results <- search_species(
#   query = "Human",
#   name_type = "all"
# )
# 
# srch_results

## ----print_srch, echo = FALSE-------------------------------------------------
pathdb:::human_srch

## ----primary_srch, eval=FALSE-------------------------------------------------
# search_species(
#   query = "Human",
#   name_type = "primary"
# )

## ----primary_print, echo = FALSE----------------------------------------------
pathdb:::human_primary

## ----academic_srch, eval=FALSE------------------------------------------------
# search_species(
#   query = "Homo sapiens",
#   name_type = "academic"
# )

## ----academic_print, echo = FALSE---------------------------------------------
pathdb:::human_academic

## ----id_srch, eval=FALSE------------------------------------------------------
# search_species(
#   query = 96,
#   name_type = "id"
# )

## ----id_print, echo = FALSE---------------------------------------------------
pathdb:::human_id

## ----list_tables, eval=FALSE--------------------------------------------------
# table_names <- list_tables(species_id = 96)
# 
# table_names

## ----table_print, echo = FALSE------------------------------------------------
pathdb:::human_tables

## ----get_table, eval=FALSE----------------------------------------------------
# gene_info <- get_table(
#   species_id = 96,
#   table = "geneInfo"
# )
# 
# head(gene_info[, 1:5])

## ----print_genes, echo=FALSE--------------------------------------------------
head(pathdb:::human_genes[, 1:5])

## ----gene_info, eval=FALSE----------------------------------------------------
# gene_info <- get_genes(
#   species_id = 96,
#   genes = rownames(hypoxia_reads)
# )
# 
# head(gene_info[, 1:5])

## ----print_info, echo=FALSE---------------------------------------------------
head(pathdb:::hypoxia_genes[, 1:5])

## ----get_categories, eval = FALSE---------------------------------------------
# categories <- path_categories(species_id = 96)
# 
# head(categories, n = 10)

## ----print_categories, echo=FALSE---------------------------------------------
head(pathdb:::categories)

## ----rows_categories, eval=FALSE----------------------------------------------
# nrow(categories)

## ----print_nrow, echo=FALSE---------------------------------------------------
nrow(pathdb:::categories)

## ----gene_paths, eval=FALSE---------------------------------------------------
# path_info <- get_pathways(
#   species_id = 96,
#   genes = rownames(hypoxia_reads),
#   category = c("GOBP")
# )
# 
# head(path_info)

## ----print_paths, echo=FALSE--------------------------------------------------
head(pathdb:::hypoxia_paths)

## ----conv_vector, eval=FALSE--------------------------------------------------
# head(rownames(hypoxia_reads))
# 
# # Providing just a vector
# conv_table <- convert_id(
#   genes = rownames(hypoxia_reads),
#   species_id = 96
# )
# 
# head(conv_table)

## ----print_conv_vector, echo=FALSE--------------------------------------------
head(pathdb:::conversion_vector)

## ----conv_data, eval=FALSE----------------------------------------------------
# # Providing a vector AND data
# hypoxia_conv <- convert_id(
#   genes = rownames(hypoxia_reads),
#   data = hypoxia_reads,
#   species_id = 96
# )
# 
# knitr::kable(head(hypoxia_conv))

## ----print_conv_data, echo=FALSE----------------------------------------------
hypoxia_conv <- pathdb:::conversion_data
knitr::kable(head(hypoxia_conv))

## ----process_example----------------------------------------------------------
nrow(hypoxia_conv)

processed_data <- process_data(
  data = hypoxia_conv,
  missing_value = "geneMedian",
  min_cpm = 0.5,
  n_min_samples = 1
)

nrow(processed_data)

knitr::kable(head(processed_data[, 1:3]))

