Skip to content
Snippets Groups Projects
Commit a6af9c99 authored by GUILMINEAU Camille's avatar GUILMINEAU Camille
Browse files

several corrections in documentation

parent b39645e6
No related branches found
No related tags found
No related merge requests found
......@@ -4,8 +4,8 @@ Title: Pathways Longitudinal and Differential Analysis in Metabolomics
Version: 0.1
Date: 2024-01-16
Depends: R (>= 4.0.0), knitr
Imports: lme4, blme, tibble, FactoMineR, factoextra
Suggests: ASICS, KEGGREST
Imports: lme4, blme, tibble, FactoMineR, factoextra, tidyr, stats
Suggests: KEGGREST
Authors@R: c(person("Camille", "Guilmineau", role = c("aut", "cre"),
email = "camille.guilmineau@inrae.fr"),
person("Remi", "Servien", role = "aut",
......
......@@ -9,12 +9,11 @@ S3method(summary,pathwayRes)
export(adjust_pval)
export(extract)
export(from_ASICS_to_PHOENICS)
export(head)
export(overlap_coefficient)
export(pathway_search)
export(test_pathway)
importFrom(FactoMineR,PCA)
importFrom(KEGGREST,keggGet)
importFrom(KEGGREST,keggList)
importFrom(blme,blmer)
importFrom(factoextra,fviz_eig)
importFrom(factoextra,fviz_pca_ind)
......
......@@ -17,32 +17,32 @@
#' \code{pathways = NULL} and \code{pathwayA} and \code{pathwayB} are pathway
#' names and ignored otherwise.
#'
#' @return A value between 0 and 1
#'
#' @importFrom KEGGREST keggList keggGet
#' @return A value between 0 and 1 calculated with the formula:
#' \deqn{\text{OC}(A,B) = \frac{\vert A \cap B \vert}{\min(\vert A \vert,
#' \vert B \vert)}}
#' An overlap coefficient of 1 means that one pathway is included in the other.
#' An overlap coefficient of 0 means that there is no overlap between the
#' pathways.
#'
#' @examples
#' data("MTBLS422")
#' pathwayA <- "Galactose metabolism"
#' pathwayB <- "Vitamin digestion and absorption"
#' oc_1 <- overlap_coefficient(pathwayA, pathwayB, pathways)
#' oc_1
#' overlap_coefficient(pathwayA, pathwayB, pathways)
#'
#' pathwayA <- "Galactose metabolism"
#' pathwayB <- "Vitamin digestion and absorption"
#' oc_2 <- overlap_coefficient(pathwayA, pathwayB, organism = "mmu")
#' oc_2
#' if (requireNamespace("KEGGREST", quietly = TRUE)) {
#' pathwayA <- "Galactose metabolism"
#' pathwayB <- "Vitamin digestion and absorption"
#' overlap_coefficient(pathwayA, pathwayB, organism = "mmu")
#' }
#'
#' pathwayA <- "mmu00052"
#' pathwayB <- "mmu00562"
#' oc_3 <- overlap_coefficient(pathwayA, pathwayB, pathways)
#' oc_3
#' overlap_coefficient(pathwayA, pathwayB, pathways)
#'
#' pathwayA <- c("C00029", "C00116", "C00137", "C00794", "C00984", "C01697")
#' pathwayB <- c("C00191", "C00092", "C00137")
#' oc_4 <- overlap_coefficient(pathwayA, pathwayB)
#' oc_4
#'
#' overlap_coefficient(pathwayA, pathwayB)
#'
#' @references
#' Wieder C., Lai R.P.J., Ebbels T.M.D. (2022). Single sample pathway analysis
......@@ -94,10 +94,10 @@ overlap_coefficient <- function(pathwayA, pathwayB, pathways = NULL, organism =
}
code <- substr(pathwayA, start = 1, stop = nchar(pathwayA) - 5)
kegg_org <- keggList("organism")
kegg_org <- KEGGREST::keggList("organism")
if (!code %in% kegg_org) {
pathlist <- keggList("pathway", organism)
pathlist <- KEGGREST::keggList("pathway", organism)
pathlist <- as.data.frame(pathlist)
pathlist$pathway_code <- rownames(pathlist)
......@@ -110,7 +110,7 @@ overlap_coefficient <- function(pathwayA, pathwayB, pathways = NULL, organism =
pathwayB <- pathlist[pathlist$pathlist == pathwayB, "pathway_code"]
}
pathinfo <- keggGet(c(pathwayA, pathwayB))
pathinfo <- KEGGREST::keggGet(c(pathwayA, pathwayB))
A <- pathinfo[[1]]$COMPOUND
B <- pathinfo[[2]]$COMPOUND
}
......
......@@ -5,23 +5,33 @@
#' Methods for the class pathwayRes
#'
#' @name pathwayRes
#' @param object object of class \code{pathwayRes}
#' @param object,x object of class \code{pathwayRes}
#' @param ... not used
NULL
#' @rdname pathwayRes
#' @aliases summary.pathwayRes
#' @examples
#' data("MTBLS422")
#' quantif <- from_ASICS_to_PHOENICS(quantif)
#' out_test <- test_pathway(quantif, design, pathways,
#' fixed = c("Age", "Treatment"), random = "Mouse",
#' npc = 2, model = "blmer")
#' summary(out_test)
#' @exportS3Method
summary.pathwayRes <- function(object) {
summary.pathwayRes <- function(object, ...) {
cat("Number of pathways: ", length(object), "\n")
cat("Tested effects: ", object[[1]]$test_pathway$Fixed_effect)
}
#' @rdname pathwayRes
#' @aliases print.pathwayRes
#' @examples
#' print(out_test)
#' @exportS3Method
print.pathwayRes <- function(object) {
print.pathwayRes <- function(x, ...) {
cat("A list of pathways which contains for each pathway: \n")
path_res <- object[[1]]
path_res <- x[[1]]
cat("$", names(path_res)[1], ": ", "Pathway name \n", sep = "")
cat("$", names(path_res)[2], ": ", "Pathway code \n", sep = "")
cat("$", names(path_res)[3], ": ", "Metabolites in the pathway \n", sep = "")
......@@ -41,28 +51,23 @@ print.pathwayRes <- function(object) {
#' \code{"none"} (no color)
#' @importFrom factoextra fviz_pca_ind fviz_eig fviz_pca_var
#' @examples
#' data("MTBLS422")
#' quantif <- from_ASICS_to_PHOENICS(quantif)
#' out_test <- test_pathway(quantif, design, pathways,
#' fixed = c("Age", "Treatment"), random = "Mouse",
#' npc = 2, model = "blmer")
#' \dontrun{
#' plot(out_test)
#' plot(out_test, "mmu00030", plot = "var")
#' plot(out_test, "mmu00030", plot = "ind", habillage = "Age")
#' plot(out_test, "mmu00052", plot = "var")
#' plot(out_test, "mmu00052", plot = "ind", habillage = "Age")
#' }
#' @exportS3Method
plot.pathwayRes <- function(object, pathway_id = NULL,
plot.pathwayRes <- function(x, ..., pathway_id = NULL,
plot = c("eig", "var", "ind"), habillage = "none") {
plot <- match.arg(plot)
if (is.null(pathway_id)) {
message("`pathway_id` not specified... defaulting to the first pathway")
pathway_id <- names(object)[1]
pathway_id <- names(x)[1]
}
object_sub <- extract.pathwayRes(object, pathway_id)
object_sub <- extract.pathwayRes(x, pathway_id)
lapply(object_sub, function (path_res) {
if (plot == "var") {
p <- factoextra::fviz_pca_var(path_res$PCA, title = path_res$pathway_name,
......@@ -83,7 +88,15 @@ plot.pathwayRes <- function(object, pathway_id = NULL,
}
#' @rdname pathwayRes
#' @aliases head
#' @aliases head.pathwayRes
#' @examples
#' head(out_test)
#' @export
head <- function(object) {
UseMethod("head")
}
#' @exportS3Method
head.pathwayRes <- function(object){
cat("Pathways: \n")
......@@ -94,6 +107,8 @@ head.pathwayRes <- function(object){
#' @aliases extract
#' @aliases extract.pathwayRes
#' @param pathway_id a character string or vector of pathway codes or names
#' @examples
#' extract(out_test, "mmu00562")
#' @export
extract <- function(object, pathway_id) {
UseMethod("extract")
......@@ -116,11 +131,6 @@ extract.pathwayRes <- function(object, pathway_id) {
#' @param n number of comparisons for multiple testing correction
#' @importFrom stats p.adjust p.adjust.methods
#' @examples
#' data("MTBLS422")
#' quantif <- from_ASICS_to_PHOENICS(quantif)
#' out_test <- test_pathway(quantif, design, pathways,
#' fixed = c("Age", "Treatment"), random = "Mouse",
#' npc = 2, model = "blmer")
#' adj_pval <- adjust_pval(out_test)
#' @export
adjust_pval <- function(object, method = p.adjust.methods, n = length(object)) {
......
......@@ -10,9 +10,9 @@
#' @param design data.frame or matrix with samples in rows (sample identifiers
#' must be row names) and the different effects to be included in the model
#' in columns. Column names must be provided and are used as arguments for
#' `fixed` and `random`
#' \code{fixed} and \code{random}
#' @param pathways data.frame or matrix with metabolites in rows (all
#' metabolites in columns of `quantif` must have a row in this input) and the
#' metabolites in columns of \code{quantif} must have a row in this input) and the
#' following information in columns: \itemize{
#' \item{\code{metabolite_code}}{ metabolite code}
#' \item{\code{metabolite_name}}{ metabolite name}
......@@ -23,9 +23,9 @@
#' @param model a character string indicating if the model has to be fitted
#' using \link[lme4]{lmer} or \link[blme]{blmer}. Default to \code{"lmer"}
#' @param fixed character vector of fixed effects to be included in the model.
#' They must correspond to column names of `design`
#' They must correspond to column names of \code{design}
#' @param random character vector of random effects to be included in the model.
#' They must correspond to column names of `design`
#' They must correspond to column names of \code{design}
#' @param organism organism code in KEGG database. Required if
#' \code{pathways = "auto"} and ignored otherwise
#' @param min_size minimal number of metabolites in a pathway. Required if
......@@ -47,7 +47,6 @@
#' @importFrom lme4 lmer
#' @importFrom blme blmer
#' @importFrom tibble column_to_rownames rownames_to_column
#' @importFrom KEGGREST keggList
#' @importFrom stats as.formula anova
#' @importFrom tidyr separate
#'
......@@ -60,10 +59,12 @@
#' out_test
#'
#' \dontrun{
#' out_test2 <- test_pathway(quantif, design, pathways = "auto",
#' fixed = c("Age", "Treatment"), random = "Mouse",
#' npc = 2, model = "blmer", organism = "mmu")
#' out_test2
#' if (requireNamespace("KEGGREST", quietly = TRUE)) {
#' out_test2 <- test_pathway(quantif, design, pathways = "auto",
#' fixed = c("Age", "Treatment"), random = "Mouse",
#' npc = 2, model = "blmer", organism = "mmu")
#' out_test2
#' }
#' }
#'
#' @seealso
......@@ -73,8 +74,8 @@
#' @details
#' If \code{pathways = "auto"}, information on pathways in which metabolites are
#' present is automatically obtained by the function \link{pathway_search} using
#' \link{KEGGREST} that queries KEGG database. Results are specific to a given
#' organism (passed in \code{organism}). Pathways containing less than
#' \code{KEGGREST} that queries KEGG database. Results are specific to a given
#' organism (passed in \code{organism}). Pathways containing less than
#' \code{min_size} metabolites are filtered out.
#'
#' @author Camille Guilmineau <camille.guilmineau@inrae.fr>\cr
......@@ -137,7 +138,7 @@ test_pathway <- function(quantif, design, pathways = "auto", fixed, random,
stop("Package 'KEGGREST' not available. Automatic pathway searching",
" cannot be performed.")
}
kegg_org <- keggList("organism")
kegg_org <- KEGGREST::keggList("organism")
kegg_org <- as.data.frame(kegg_org)
kegg_org <- unique(kegg_org$organism)
......
......@@ -73,8 +73,7 @@ metabolite compositions are given in the argument `pathways`.
```{r overlap_coefficient}
pathwayA <- "Galactose metabolism"
pathwayB <- "Vitamin digestion and absorption"
oc_1 <- overlap_coefficient(pathwayA, pathwayB, pathways)
oc_1
overlap_coefficient(pathwayA, pathwayB, pathways)
```
If `pathways` argument is not given, the argument `organism` is required to
......@@ -82,8 +81,7 @@ search for pathway composition in KEGG database.
```{r overlap_coefficient2}
pathwayA <- "Galactose metabolism"
pathwayB <- "Vitamin digestion and absorption"
oc_2 <- overlap_coefficient(pathwayA, pathwayB, organism = "mmu")
oc_2
overlap_coefficient(pathwayA, pathwayB, organism = "mmu")
```
The arguments `pathwayA` and `pathwayB` can be pathway codes and their
......@@ -91,8 +89,7 @@ metabolite compositions are given in the argument `pathways`.
```{r overlap_coefficient3}
pathwayA <- "mmu00052"
pathwayB <- "mmu00562"
oc_3 <- overlap_coefficient(pathwayA, pathwayB, pathways)
oc_3
overlap_coefficient(pathwayA, pathwayB, pathways)
```
The arguments `pathwayA` and `pathwayB` can be vectors of metabolites. In that
......@@ -100,6 +97,5 @@ case, the the argument `pathways` is not required.
```{r overlap_coefficient4}
pathwayA <- c("C00029", "C00116", "C00137", "C00794", "C00984", "C01697")
pathwayB <- c("C00191", "C00092", "C00137")
oc_4 <- overlap_coefficient(pathwayA, pathwayB)
oc_4
overlap_coefficient(pathwayA, pathwayB)
```
pkg_name <- "phoenix"
pkg_name <- "phoenics"
citHeader(paste("To cite the R package ", pkg_name, " in publications use:"))
if(!exists("meta") || is.null(meta)) meta <- packageDescription(pkg_name)
......@@ -9,10 +9,10 @@ vers <- paste("R package version", meta$Version)
url <- paste0("https://CRAN.R-project.org/package=", pkg_name)
bibentry(bibtype = "Manual",
title = "phoenix: ",
title = "phoenics: ",
author = c(person("Camille", "Guilmineau",
email = "camille.guilmineau@inrae.fr",
role = ("aut", "cre")),
role = c("aut", "cre")),
person("Remi", "Servien", email = "remi.servien@inrae.fr",
role = "aut", comment = c(ORCID = "0000-0003-1270-1843")),
person("Nathalie", "Vialaneix",
......@@ -20,8 +20,8 @@ bibentry(bibtype = "Manual",
comment = c(ORCID = "0000-0003-1156-0639"))),
year = year,
url = url,
note = paste(vers, "---", "For new features, see the 'NEWS'),
note = paste(vers, "---", "For new features, see the 'NEWS'"),
textVersion = paste0(
"Guilmineau, C., Servien, R., Vialaneix, N. (", year,
"). phoenix: . ", vers, ".")
"). phoenics: . ", vers, ".")
)
......@@ -28,7 +28,12 @@ codes.}
names and ignored otherwise.}
}
\value{
A value between 0 and 1
A value between 0 and 1 calculated with the formula:
\deqn{\text{OC}(A,B) = \frac{\vert A \cap B \vert}{\min(\vert A \vert,
\vert B \vert)}}
An overlap coefficient of 1 means that one pathway is included in the other.
An overlap coefficient of 0 means that there is no overlap between the
pathways.
}
\description{
Calculate overlap coefficient between pathways
......@@ -37,24 +42,21 @@ Calculate overlap coefficient between pathways
data("MTBLS422")
pathwayA <- "Galactose metabolism"
pathwayB <- "Vitamin digestion and absorption"
oc_1 <- overlap_coefficient(pathwayA, pathwayB, pathways)
oc_1
overlap_coefficient(pathwayA, pathwayB, pathways)
pathwayA <- "Galactose metabolism"
pathwayB <- "Vitamin digestion and absorption"
oc_2 <- overlap_coefficient(pathwayA, pathwayB, organism = "mmu")
oc_2
if (requireNamespace("KEGGREST", quietly = TRUE)) {
pathwayA <- "Galactose metabolism"
pathwayB <- "Vitamin digestion and absorption"
overlap_coefficient(pathwayA, pathwayB, organism = "mmu")
}
pathwayA <- "mmu00052"
pathwayB <- "mmu00562"
oc_3 <- overlap_coefficient(pathwayA, pathwayB, pathways)
oc_3
overlap_coefficient(pathwayA, pathwayB, pathways)
pathwayA <- c("C00029", "C00116", "C00137", "C00794", "C00984", "C01697")
pathwayB <- c("C00191", "C00092", "C00137")
oc_4 <- overlap_coefficient(pathwayA, pathwayB)
oc_4
overlap_coefficient(pathwayA, pathwayB)
}
\references{
......
......@@ -5,6 +5,7 @@
\alias{summary.pathwayRes}
\alias{print.pathwayRes}
\alias{plot.pathwayRes}
\alias{head}
\alias{head.pathwayRes}
\alias{extract}
\alias{extract.pathwayRes}
......@@ -12,25 +13,28 @@
\alias{adjust_pval.pathwayRes}
\title{Class pathwayRes}
\usage{
\method{summary}{pathwayRes}(object)
\method{summary}{pathwayRes}(object, ...)
\method{print}{pathwayRes}(object)
\method{print}{pathwayRes}(x, ...)
\method{plot}{pathwayRes}(
object,
x,
...,
pathway_id = NULL,
plot = c("eig", "var", "ind"),
habillage = "none"
)
\method{head}{pathwayRes}(object)
head(object)
extract(object, pathway_id)
adjust_pval(object, method = p.adjust.methods, n = length(object))
}
\arguments{
\item{object}{object of class \code{pathwayRes}}
\item{object, x}{object of class \code{pathwayRes}}
\item{...}{not used}
\item{pathway_id}{a character string or vector of pathway codes or names}
......@@ -59,15 +63,14 @@ quantif <- from_ASICS_to_PHOENICS(quantif)
out_test <- test_pathway(quantif, design, pathways,
fixed = c("Age", "Treatment"), random = "Mouse",
npc = 2, model = "blmer")
summary(out_test)
print(out_test)
\dontrun{
plot(out_test)
plot(out_test, "mmu00030", plot = "var")
plot(out_test, "mmu00030", plot = "ind", habillage = "Age")
plot(out_test, "mmu00052", plot = "var")
plot(out_test, "mmu00052", plot = "ind", habillage = "Age")
}
data("MTBLS422")
quantif <- from_ASICS_to_PHOENICS(quantif)
out_test <- test_pathway(quantif, design, pathways,
fixed = c("Age", "Treatment"), random = "Mouse",
npc = 2, model = "blmer")
head(out_test)
extract(out_test, "mmu00562")
adj_pval <- adjust_pval(out_test)
}
......@@ -24,10 +24,10 @@ columns (metabolite codes must be column names)}
\item{design}{data.frame or matrix with samples in rows (sample identifiers
must be row names) and the different effects to be included in the model
in columns. Column names must be provided and are used as arguments for
`fixed` and `random`}
\code{fixed} and \code{random}}
\item{pathways}{data.frame or matrix with metabolites in rows (all
metabolites in columns of `quantif` must have a row in this input) and the
metabolites in columns of \code{quantif} must have a row in this input) and the
following information in columns: \itemize{
\item{\code{metabolite_code}}{ metabolite code}
\item{\code{metabolite_name}}{ metabolite name}
......@@ -36,10 +36,10 @@ following information in columns: \itemize{
}}
\item{fixed}{character vector of fixed effects to be included in the model.
They must correspond to column names of `design`}
They must correspond to column names of \code{design}}
\item{random}{character vector of random effects to be included in the model.
They must correspond to column names of `design`}
They must correspond to column names of \code{design}}
\item{npc}{number of PCs for the PCA step}
......@@ -73,8 +73,8 @@ The method relies on a PCA step.
\details{
If \code{pathways = "auto"}, information on pathways in which metabolites are
present is automatically obtained by the function \link{pathway_search} using
\link{KEGGREST} that queries KEGG database. Results are specific to a given
organism (passed in \code{organism}). Pathways containing less than
\code{KEGGREST} that queries KEGG database. Results are specific to a given
organism (passed in \code{organism}). Pathways containing less than
\code{min_size} metabolites are filtered out.
}
\examples{
......@@ -86,10 +86,12 @@ out_test <- test_pathway(quantif, design, pathways,
out_test
\dontrun{
out_test2 <- test_pathway(quantif, design, pathways = "auto",
fixed = c("Age", "Treatment"), random = "Mouse",
npc = 2, model = "blmer", organism = "mmu")
out_test2
if (requireNamespace("KEGGREST", quietly = TRUE)) {
out_test2 <- test_pathway(quantif, design, pathways = "auto",
fixed = c("Age", "Treatment"), random = "Mouse",
npc = 2, model = "blmer", organism = "mmu")
out_test2
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment