Case Study: Cheese
cheese.Rmd
library(MolPad)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
Load Data
In the process of producing cheese, regular washing with a brine solution is an aging practice that can homogenize the microbial communities on the cheese’ surface and facilitate intermicrobial interactions. In the following parts, we will analyze a longitudinal data set of three washed-rind cheese communities collected during cheese ripening.
data("cheese")
Preprocess
Data and Annotations
Here we select a ‘type’ column with phylum
to describe
the characteristic of cheese data. Also, the columns phylum
and class
are taken as tags for elemental composition.
cheesedata <- cheese |>
select(ID, A_1:C_5, phylum) |>
rename(type=phylum) |>
pre_process()
pathchee <- gAnnotation(annotations,"phylum","class")
After pre-processing, here is what the two datasets that we will put into the dashboard look like:
cheesedata[112:115,]
#> # A tibble: 4 × 11
#> ID A_1 A_2 A_3 A_4 A_5 C_1 C_3 C_4 C_5 type
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 112 0.943 -0.471 -0.471 -0.471 -0.471 2.36 -0.471 -0.471 -0.471 Other
#> 2 113 0.786 -0.124 0.126 -0.623 -0.637 2.33 -0.667 -0.593 -0.593 Other
#> 3 114 1.22 -1.09 -0.430 -0.829 -0.170 1.43 -1.30 0.455 0.715 Other
#> 4 115 2.67 -0.333 -0.333 -0.333 -0.333 -0.333 -0.333 -0.333 -0.333 Other
pathchee[112:115,]
#> # A tibble: 4 × 9
#> ID GO_ID KEGG_ID domain Pathway taxonomic.scope order family genus
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 145 - ko:K00004 Bacte… Pseudo… Unknown NA NA NA
#> 2 147 - ko:K00004 Bacte… Actino… Actinomycetes NA NA NA
#> 3 148 - ko:K00004 Bacte… Bacill… Bacilli Baci… Bacil… Lysi…
#> 4 149 - ko:K00004,ko:K0… Bacte… Actino… Actinomycetes NA NA NA
Cluster Input
Then we generate clusters from the long dataset above.
cluschee <- gClusters(cheesedata,ncluster = 10,elbow.max=15)
network input
After that, we got the network result from the clusters. We pick top 3 predictors for each feature, and save the network output for future use.
networkchee <- gNetwork(cluschee,ntop = 3)
View more details of the results with the following function:
gNetwork_view(networkchee)
Run Dashboard
Declare the annotations, and then run the dashboard.
gDashboard(cheesedata,
cluschee,
pathchee,
networkchee,
id_colname = c("GO_ID","KEGG_ID"),
id_type = c("GO","KEGG"))