Skip to content

Commit

Permalink
Add cheese datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
abichat committed Mar 1, 2024
1 parent 7bf6287 commit f0f557f
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ Config/testthat/edition: 3
Encoding: UTF-8
LazyData: false
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
41 changes: 40 additions & 1 deletion R/data.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Pediatric cancer gene expression
#' Gene Expression of Pediatric Cancer
#'
#' Gene expression of 108 CCLE cell lines from 5 different pediatric cancers.
#'
Expand All @@ -21,3 +21,42 @@
#' data("pedcan_expression", package = "scimo")
#' pedcan_expression
"pedcan_expression"


#' Abundance of Fungal Communities in Cheese
#'
#' Fungal community abundance of 74 ASVs sampled from the surface of three
#' different French cheeses.
#'
#' @usage data("cheese_abundance", package = "scimo")
#'
#' @format For `cheese_abundance`, a [tibble][tibble::tibble-package]
#' with columns:
#' \describe{
#' \item{sample}{Sample ID.}
#' \item{cheese}{Appellation of the cheese. One of `Saint-Nectaire`,
#' `Livarot` or `Epoisses`.}
#' \item{rind_type}{One of `Natural` or `Washed`.}
#' \item{other columns}{Count of the ASV.}
#' }
#'
#' @source This dataset came from \url{https://doi.org/10.24072/pcjournal.321}.
#'
#' @examples
#' data("cheese_abundance", package = "scimo")
#' cheese_abundance
"cheese_abundance"

#' @rdname cheese_abundance
#' @format For `cheese_taxonomy`, a [tibble][tibble::tibble-package]
#' with columns:
#' \describe{
#' \item{asv}{ASV ID.}
#' \item{lineage}{Character corresponding to a standard concatenation of
#' taxonomic clades.}
#' \item{other columns}{Clade to which the ASV belongs.}
#' }
#' @examples
#' data("cheese_taxonomy", package = "scimo")
#' cheese_taxonomy
"cheese_taxonomy"
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ reference:
- title: Datasets
contents:
- '`pedcan_expression`'
- '`cheese_abundance`'
- title: Helpers
contents:
- '`cv`'
Expand Down
43 changes: 43 additions & 0 deletions data-raw/cheese_abundance.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## code to prepare `cheese_abundance` dataset goes here
library(tidyverse)
library(phyloseq)
library(glue)

phylo_cheese <- read_rds("data-raw/data/phyloseq_cheese.rds")

cheese_taxonomy <-
phylo_cheese %>%
tax_table() %>%
as.data.frame() %>%
as_tibble(rownames = "sequence") %>%
mutate(lineage = glue("k__{Kingdom}|p__{Phylum}|c__{Class}|o__{Order}|f__{Family}|g__{Genus}|s__{Species}"),
lineage = str_replace_all(lineage, " ", "_")) %>%
arrange(lineage) %>%
rowid_to_column(var = "asv") %>%
mutate(asv = if_else(asv >= 10,
paste0("asv_", asv),
paste0("asv_0", asv))) %>%
select(asv, lineage, everything())

cheese_abundance <-
cheese_taxonomy %>%
select(asv, sequence) %>%
left_join(otu_table(phylo_cheese)@.Data %>%
as_tibble(rownames = "sequence"), by = "sequence") %>%
select(-sequence) %>%
pivot_longer(-asv, names_to = "sample", values_to = "count") %>%
pivot_wider(names_from = asv, values_from = count) %>%
mutate(sample = str_remove_all(sample, "_ITS2_CURATED"),
sample = str_replace_all(sample, "echantillon", "sample")) %>%
mutate(cheese = str_remove_all(sample, "sample"),
cheese = str_remove_all(cheese, "-[1-3]"),
cheese = case_when(cheese == 1 ~ "Saint-Nectaire",
cheese == 2 ~ "Livarot",
cheese == 3 ~ "Epoisses"),
rind_type = if_else(cheese == "Saint-Nectaire", "Natural", "Washed"),
.after = sample)

cheese_taxonomy <- select(cheese_taxonomy, -sequence)

# usethis::use_data(cheese_abundance, overwrite = TRUE)
# usethis::use_data(cheese_taxonomy, overwrite = TRUE)
Binary file added data-raw/data/phyloseq_cheese.rds
Binary file not shown.
Binary file added data/cheese_abundance.rda
Binary file not shown.
Binary file added data/cheese_taxonomy.rda
Binary file not shown.
2 changes: 2 additions & 0 deletions dev/dev_history.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ library(testthat)

# use_pkgdown()

# use_data_raw("cheese_abundance")

####

devtools::load_all()
Expand Down
46 changes: 46 additions & 0 deletions man/cheese_abundance.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/pedcan_expression.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f0f557f

Please sign in to comment.