Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PHOENICS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PANORAMICS
PHOENICS
Commits
987ccf30
Commit
987ccf30
authored
1 year ago
by
GUILMINEAU Camille
Browse files
Options
Downloads
Patches
Plain Diff
corrections in test_pathway function: test of inputs and documentation
parent
2a1943ac
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
NAMESPACE
+9
-3
9 additions, 3 deletions
NAMESPACE
R/test_pathway.R
+42
-17
42 additions, 17 deletions
R/test_pathway.R
man/test_pathway.Rd
+39
-26
39 additions, 26 deletions
man/test_pathway.Rd
with
90 additions
and
46 deletions
NAMESPACE
+
9
−
3
View file @
987ccf30
...
...
@@ -4,12 +4,18 @@ S3method(head,pathwayRes)
S3method(plot,pathwayRes)
S3method(print,pathwayRes)
S3method(summary,pathwayRes)
export(PCApath)
export(from_ASICS_to_PHOENICS)
export(overlap_coefficient)
import(blme)
import(lme4)
export(test_pathway)
importFrom(FactoMineR,PCA)
importFrom(KEGGREST,keggList)
importFrom(MetaboAnalystR,CalculateOraScore)
importFrom(MetaboAnalystR,CreateMappingResultTable)
importFrom(MetaboAnalystR,CrossReferencing)
importFrom(MetaboAnalystR,InitDataObjects)
importFrom(MetaboAnalystR,SetKEGG.PathLib)
importFrom(MetaboAnalystR,SetMetabolomeFilter)
importFrom(MetaboAnalystR,Setup.MapData)
importFrom(blme,blmer)
importFrom(factoextra,fviz_eig)
importFrom(factoextra,fviz_pca_ind)
...
...
This diff is collapsed.
Click to expand it.
R/test_pathway.R
+
42
−
17
View file @
987ccf30
#' @title
Test of metabolic pathway
s based on longitudinal metabolomics data
#' @title
Pathway differential analysi
s based on longitudinal metabolomics data
#'
#' @description
#' TODO : explain the main steps of the function
#' @description For each pathway, perform a PCA on the metabolites
#' quantification matrix and select a `npc` number of principal components,
#' then fit a mixed model on the new matrix and test the fixed effects
#' significance
#'
#' @param quantif dataframe or matrix of the quantification of the metabolites, with the samples in rownames and the metabolites codes in colnames
#' @param design dataframe or matrix, contains the samples in rownames and the factors to be included in the model in colnames
#' @param pathways dataframe or matrix, contains a row for each metabolite in a pathway
#' @param quantif dataframe or matrix of the quantification of the metabolites,
#' with the samples in row names and the metabolites codes in column names
#' @param design dataframe or matrix, contains the samples in rownames and the
#' factors to be included in the model in colnames
#' @param pathways dataframe or matrix, contains the columns "pathway_name",
#' "pathway_code", "metabolite_code" and "metabolite_name" and a row for each
#' metabolite in a pathway
#' @param npc number of PC to select
#' @param model a character string indicating if the model should be fitted using lme or blme package
#' @param fixed vector of fixed effects to be included in the model, must be in design colnames
#' @param random vector of random effects to be included in the model, must be in design colnames
#' @param organism organism code in KEGG database, needed if pathways == "auto"
#' @param model a character string indicating if the model should be fitted
#' using lme or blme package
#' @param fixed vector of fixed effects to be included in the model, must be in
#' design colnames
#' @param random vector of random effects to be included in the model, must be
#' in design colnames
#' @param organism organism code in KEGG database (three or four letters),
#' needed if pathways == "auto"
#'
#' @return an object of class pathwayRes
#' TODO : describe the returned object
#' @return an object of class pathwayRes: list of pathways which contains for
#' each pathway:
#' - a dataframe with the pathway name and pathway code
#' - a dataframe with the metabolites names and metabolites codes in the pathway
#' - a PCA object
#' - the output of the model
#' - a list of dataframes with the p-values (before and after correction) of
#' each tested effect
#'
#' @importFrom FactoMineR PCA
#' @importFrom lme4 lmer
#' @importFrom blme blmer
#' @importFrom tibble column_to_rownames
#' @importFrom
tibble rownames_to_column
#' @importFrom
KEGGREST keggList
#'
#' @examples
#' load(system.file("data", "example.rda", package = "phoenics"))
...
...
@@ -42,7 +58,8 @@
#' @export
test_pathway
<-
function
(
quantif
,
design
,
pathways
=
"auto"
,
fixed
,
random
,
npc
=
1L
,
model
=
c
(
"lmer"
,
"blmer"
),
organism
=
NULL
)
{
npc
=
1L
,
model
=
c
(
"lmer"
,
"blmer"
),
organism
=
NULL
)
{
# Inputs tests
if
(
!
is.character
(
fixed
))
{
...
...
@@ -76,7 +93,16 @@ test_pathway <- function(quantif, design, pathways = "auto", fixed, random,
if
(
is.null
(
organism
))
{
stop
(
"`organism` is missing."
)
}
# TODO: pathway_search(quantif, organism)
kegg_org
<-
keggList
(
"organism"
)
kegg_org
<-
as.data.frame
(
kegg_org
)
kegg_org
<-
unique
(
kegg_org
$
organism
)
if
(
organism
%in%
kegg_org
)
{
# TODO: pathway_search(quantif, organism)
}
else
{
stop
(
"`organism` must be KEGG organism code."
)
}
}
else
{
stop
(
"`pathways` must be \"auto\" or a dataframe or a matrix."
)
}
...
...
@@ -173,8 +199,7 @@ test_pathway <- function(quantif, design, pathways = "auto", fixed, random,
return
(
out
)
})
simes
<-
as.data.frame
(
simes
)
simes
<-
tibble
::
rownames_to_column
(
simes
,
"pathway"
)
colnames
(
simes
)[
2
]
<-
"pval"
colnames
(
simes
)[
1
]
<-
"pval"
simes
$
FDR
<-
p.adjust
(
simes
$
pval
)
return
(
simes
)
})
...
...
This diff is collapsed.
Click to expand it.
man/test_pathway.Rd
+
39
−
26
View file @
987ccf30
...
...
@@ -2,54 +2,67 @@
% Please edit documentation in R/test_pathway.R
\name{test_pathway}
\alias{test_pathway}
\title{
Test of metabolic pathway
s based on longitudinal metabolomics data}
\title{
Pathway differential analysi
s based on longitudinal metabolomics data}
\usage{
test_pathway(
quantif,
design,
pathways,
npc,
model = c("lme", "blme"),
pathways = "auto",
fixed,
random,
organism
npc = 1L,
model = c("lmer", "blmer"),
organism = NULL
)
}
\arguments{
\item{quantif}{dataframe or matrix of the quantification of the metabolites, with the samples in rownames and the metabolites codes in colnames}
\item{quantif}{dataframe or matrix of the quantification of the metabolites,
with the samples in row names and the metabolites codes in column names}
\item{design}{dataframe or matrix, contains the samples in rownames and the factors to be included in the model in colnames}
\item{design}{dataframe or matrix, contains the samples in rownames and the
factors to be included in the model in colnames}
\item{pathways}{dataframe or matrix, contains a row for each metabolite in a pathway}
\item{pathways}{dataframe or matrix, contains the columns "pathway_name",
"pathway_code", "metabolite_code" and "metabolite_name" and a row for each
metabolite in a pathway}
\item{npc}{number of PC to select}
\item{fixed}{vector of fixed effects to be included in the model, must be in
design colnames}
\item{model}{a character string indicating if the model should be fitted using lme or blme package}
\item{random}{vector of random effects to be included in the model, must be
in design colnames}
\item{
fixed}{vector of fixed effects to be included in the model, must be in design colnames
}
\item{
npc}{number of PC to select
}
\item{random}{vector of random effects to be included in the model, must be in design colnames}
\item{model}{a character string indicating if the model should be fitted
using lme or blme package}
\item{organism}{organism code in KEGG database, needed if pathways == "auto"}
\item{organism}{organism code in KEGG database (three or four letters),
needed if pathways == "auto"}
}
\value{
an object of class pathwayRes
TODO : describe the returned object
an object of class pathwayRes: list of pathways which contains for
each pathway:
- a dataframe with the pathway name and pathway code
- a dataframe with the metabolites names and metabolites codes in the pathway
- a PCA object
- the output of the model
- a list of dataframes with the p-values (before and after correction) of
each tested effect
}
\description{
TODO : explain the main steps of the function
For each pathway, perform a PCA on the metabolites
quantification matrix and select a `npc` number of principal components,
then fit a mixed model on the new matrix and test the fixed effects
significance
}
\examples{
load(file = "data/design_example.rda")
load(file = "data/pathways_example.rda")
load(file = "data/quantif_example.rda")
quantif <- format_ASICS_quantif(quantif)
object <- test_pathway(quantif, design, pathways, npc = 2, model = "blme",
fixed = c("Age", "Treatment"), random = c("Mouse"))
print.pathwayRes(object)
summary.pathwayRes(object)
plot.pathwayRes(object)
head.pathwayRes(object)
load(system.file("data", "example.rda", package = "phoenics"))
quantif <- from_ASICS_to_PHOENICS(quantif)
out_test <- test_pathway(quantif, design, pathways,
fixed = c("Age", "Treatment"), random = "Mouse", npc = 2L,
model = "blmer")
out_test
}
\references{
...
...
This diff is collapsed.
Click to expand it.
GUILMINEAU Camille
@camille.guilmineau
mentioned in issue
#18 (closed)
·
1 year ago
mentioned in issue
#18 (closed)
mentioned in issue #18
Toggle commit list
GUILMINEAU Camille
@camille.guilmineau
mentioned in issue
#5 (closed)
·
1 year ago
mentioned in issue
#5 (closed)
mentioned in issue #5
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment