Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output TreeSE #24

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ License: Artistic-2.0 | file LICENSE
Encoding: UTF-8
Depends:
R(>= 4.4.0),
SummarizedExperiment,
TreeSummarizedExperiment,
MultiAssayExperiment
Imports:
dplyr,
Expand All @@ -29,8 +29,7 @@ Suggests:
testthat,
knitr,
rmarkdown,
BiocStyle,
TreeSummarizedExperiment
BiocStyle
URL: https://github.com/microbiome/HoloFoodR
BugReports: https://github.com/microbiome/HoloFoodR/issues
VignetteBuilder: knitr
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export(getData)
export(getMetaboLights)
export(getResult)
import(MultiAssayExperiment)
import(SummarizedExperiment)
import(TreeSummarizedExperiment)
importFrom(S4Vectors,SimpleList)
importFrom(dplyr,bind_rows)
importFrom(dplyr,full_join)
Expand Down
6 changes: 3 additions & 3 deletions R/HoloFoodR.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#' @name HoloFoodR
#' @docType package
#' @seealso
#' \link[SummarizedExperiment:SummarizedExperiment-class]{SummarizedExperiment}
#' \link[MultiAssayExperiment:MultiAssayExperiment-class]{MultiAssaySummarizedExperiment}
#' \link[TreeSummarizedExperiment:TreeSummarizedExperiment-class]{TreeSummarizedExperiment}
#' \link[MultiAssayExperiment:MultiAssayExperiment-class]{MultiAssayExperiment}
NULL

#' @import SummarizedExperiment
#' @import TreeSummarizedExperiment
#' @import MultiAssayExperiment
NULL
24 changes: 12 additions & 12 deletions R/getResult.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#' database. Compared to \code{getData}, this function is more convenient for
#' fetching the samples data because it converts the data to
#' \code{MultiAssayExperiment} where different omics are stored as
#' \code{SummarizedExperiment} objects which are optimized for downstream
#' \code{TreeSummarizedExperiment} objects which are optimized for downstream
#' analytics. Columns of returned \code{MultiAssayExperiment} are individual
#' animals. These columns are linked with individual samples that are stored in
#' \code{SummarizedExperiment} objects.
#' \code{TreeSummarizedExperiment} objects.
#'
#' The HoloFood database lacks non-targeted metabolomic data but fetched from
#' MetaboLights resource. The function \code{getResult} facilitates the
Expand Down Expand Up @@ -46,7 +46,7 @@
#' use.cache (Default: \code{FALSE})
#'
#' \item \strong{assay.type} \code{Character scalar} specifying the name of
#' assay in resulting \code{SummarizedExperiment} object.
#' assay in resulting \code{TreeSummarizedExperiment} object.
#' (Default: \code{"counts"})
#'
#' }
Expand All @@ -64,7 +64,7 @@
#'
#' @seealso
#' \code{\link[HoloFoodR:getData]{getData}}
#' \code{\link[SummarizedExperiment:SummarizedExperiment-class]{SummarizedExperiment}}
#' \code{\link[TreeSummarizedExperiment:TreeSummarizedExperiment-class]{TreeSummarizedExperiment}}
#' \code{\link[MultiAssayExperiment:MultiAssayExperiment-class]{MultiAssayExperiment}}
#' \code{\link[MGnifyR:getResult]{MGnifyR:getResult}}
#'
Expand Down Expand Up @@ -198,7 +198,7 @@
rownames(temp) <- accessions
temp <- DataFrame(temp, check.names = FALSE)
# Create empty SE
se <- SummarizedExperiment(colData = temp)
se <- TreeSummarizedExperiment(colData = temp)

Check warning on line 201 in R/getResult.R

View check run for this annotation

Codecov / codecov/patch

R/getResult.R#L201

Added line #L201 was not covered by tests
return(se)
})
names(ses) <- type_names
Expand Down Expand Up @@ -266,8 +266,8 @@
names(assays) <- assay.type
feat_meta <- DataFrame(feat_meta, check.names = FALSE)
sample_meta <- DataFrame(sample_meta, check.names = FALSE)
# Create SummarizedExperiment
se <- SummarizedExperiment(
# Create TreeSummarizedExperiment
se <- TreeSummarizedExperiment(

Check warning on line 270 in R/getResult.R

View check run for this annotation

Codecov / codecov/patch

R/getResult.R#L270

Added line #L270 was not covered by tests
assays = assays, rowData = feat_meta, colData = sample_meta)

# The data still has sample names from MetaboLights and not from HoloFood
Expand Down Expand Up @@ -508,8 +508,8 @@

# This function cretaes a MAE object from list of tables.
.construct_omics_data_from_markers <- function(res, metadata){
# Convert each table to SummarizedExperiment
res <- lapply(res, .convert_type_to_SummarizedExperiment, metadata)
# Convert each table to TreeSummarizedExperiment
res <- lapply(res, .convert_type_to_TreeSummarizedExperiment, metadata)

Check warning on line 512 in R/getResult.R

View check run for this annotation

Codecov / codecov/patch

R/getResult.R#L512

Added line #L512 was not covered by tests
# Create MultiAssayExperiment
res <- ExperimentList(res)
res <- MultiAssayExperiment(res)
Expand All @@ -520,7 +520,7 @@
# to SE.
#' @importFrom stats reshape
#' @importFrom S4Vectors SimpleList
.convert_type_to_SummarizedExperiment <- function(
.convert_type_to_TreeSummarizedExperiment <- function(
type, metadata, assay.type = "counts", ...){
# Check assay.type
temp <- .check_input(assay.type, list("character scalar"))
Expand Down Expand Up @@ -581,10 +581,10 @@
# Convert to DF
col_data <- DataFrame(col_data, check.names = FALSE)

# Create SummarizedExperiment
# Create TreeSummarizedExperiment
assays <- SimpleList(assay)
names(assays) <- assay.type
se <- SummarizedExperiment(
se <- TreeSummarizedExperiment(

Check warning on line 587 in R/getResult.R

View check run for this annotation

Codecov / codecov/patch

R/getResult.R#L587

Added line #L587 was not covered by tests
assays = assays, rowData = row_data,
colData = col_data
)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ With this tool, users can efficiently search and retrieve data from the EBI
HoloFood resource.

The retrieved data is available in `MultiAssayExperiment` /
`SummarizedExperiment` format similarly to the data acquired with the
`TreeSummarizedExperiment` format similarly to the data acquired with the
`MGnifyR` package from the MGnify database. This compatibility ensures users
can seamlessly combine and analyze datasets from both sources, leading to
valuable insights into intricate biological systems.
Expand Down
4 changes: 2 additions & 2 deletions man/HoloFoodR.Rd

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

8 changes: 4 additions & 4 deletions man/getResult.Rd

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

4 changes: 2 additions & 2 deletions tests/testthat/test-getResult.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test_that("getResult", {
res <- getResult(samples)
# The data must be MAE that have SEs inside
expect_s4_class(res, "MultiAssayExperiment")
expect_s4_class(res[[1]], "SummarizedExperiment")
expect_s4_class(res[[1]], "TreeSummarizedExperiment")

# This function fetches corresponding values from MAE (getResult) and list of
# data.frames (getData)
Expand Down Expand Up @@ -95,7 +95,7 @@ test_that("getResult", {
res <- getResult(samples)
# The data must be MAE that have SEs inside
expect_s4_class(res, "MultiAssayExperiment")
expect_s4_class(res[[1]], "SummarizedExperiment")
expect_s4_class(res[[1]], "TreeSummarizedExperiment")

ref <- getMetaboLights(
"https://www.ebi.ac.uk/metabolights/ws/studies/MTBLS4381")
Expand Down
6 changes: 2 additions & 4 deletions vignettes/HoloFoodR.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ mae
```

`MAE` object stores individual omics as
`r BiocStyle::Biocpkg("SummarizedExperiment")` (`SE`) objects.
`r BiocStyle::Biocpkg("TreeSummarizedExperiment")` (`TreeSE`) objects.

```{r show_mae}
mae[[1]]
```

In `SE`, each column represents a sample and rows represent features.
In `TreeSE`, each column represents a sample and rows represent features.

### Incorporate with MGnify data

Expand Down Expand Up @@ -175,8 +175,6 @@ mae_metagenomic <- MGnifyR::getResult(mg, analysis_ids)
```

```{r get_metagenomic_data2, include = FALSE}
library(TreeSummarizedExperiment)

path <- system.file("extdata", "mae_metagenomic.rds", package = "HoloFoodR")
mae_metagenomic <- readRDS(path)
```
Expand Down
Loading