Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
treediff
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
Admin message
A compter du 1er avril, attention à vos pipelines :
Nouvelles limitations de Docker Hub
Show more breadcrumbs
SCALES
treediff
Commits
d2aefee3
Commit
d2aefee3
authored
2 years ago
by
Nathalie Vialaneix
Browse files
Options
Downloads
Patches
Plain Diff
fixed a few bugs in checks, improved documentation and added DESCRIPTION
parent
e472c499
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
DESCRIPTION
+21
-9
21 additions, 9 deletions
DESCRIPTION
NAMESPACE
+2
-0
2 additions, 0 deletions
NAMESPACE
R/treediff.R
+24
-15
24 additions, 15 deletions
R/treediff.R
man/treediff.Rd
+21
-13
21 additions, 13 deletions
man/treediff.Rd
tests/testthat/test-treediff.R
+5
-6
5 additions, 6 deletions
tests/testthat/test-treediff.R
with
73 additions
and
43 deletions
DESCRIPTION
+
21
−
9
View file @
d2aefee3
Package: treediff
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Title: Testing Differences Between Families of Trees
Version: 0.1
Date: 2023-02-24
Authors@R:
person("First", "Last", , "first.last@example.com", role = c("aut", "cre"),
comment = c(ORCID = "YOUR-ORCID-ID"))
Description: What the package does (one paragraph).
Imports: dplyr, limma, reshape2, stats
License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a
license
c(person("Nathalie", "Vialaneix", , "nathalie.vialaneix@inrae.fr",
role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-1156-0639")),
person("Gwendaelle", "Cardenac", , , role = "aut"),
person("Marie", "Chavent", , "marie.chavent@u-bordeaux.fr", role = "aut"),
person("Sylvain", "Foissac", , "sylvain.foissac@inrae.fr", role = "aut"),
person("Pierre", "Neuvial", , "pierre.neuvial@math.univ-toulouse.fr",
role = "aut"),
person("Nathanael", "Randriamihamison", , , role = "aut"))
Description: This package implements a method based on cophenetic distances
and designed to perform a test to detect differences in structure
between families of trees.
Depends: R (>= 4.0.0)
Imports: dplyr, limma, stats, reshape2, testthat, rlang
Suggest: adjclust
License: GPL (>= 3)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
Suggests:
knitr,
rmarkdown
VignetteBuilder: knitr
URL: https://forgemia.inra.fr/scales/treediff
BugReports: https://forgemia.inra.fr/scales/treediff/-/issues
This diff is collapsed.
Click to expand it.
NAMESPACE
+
2
−
0
View file @
d2aefee3
...
...
@@ -3,10 +3,12 @@
S3method(print,treeTest)
S3method(summary,treeTest)
export(treediff)
import(testthat)
importFrom(dplyr,"%>%")
importFrom(dplyr,group_by)
importFrom(dplyr,summarise)
importFrom(limma,squeezeVar)
importFrom(reshape2,colsplit)
importFrom(rlang,.data)
importFrom(stats,cophenetic)
importFrom(stats,pt)
This diff is collapsed.
Click to expand it.
R/treediff.R
+
24
−
15
View file @
d2aefee3
...
...
@@ -19,10 +19,12 @@
#' different from that of \code{trees1}.
#' @param replicates A numeric vector of length 2 with the number of replicates
#' for each condition.
#' @param scale Logical. If \code{TRUE}, the trees are all rescalled to have a
#' minimum height equal to 0 and a maximum height equal to 1.
#' @param order_labels Logical. If \code{TRUE}, take a reference tree and keep
#' track of leave order.
#' @param scale Logical. If \code{TRUE}, the trees are all rescaled to have a
#' minimum height equal to 0 and a maximum height equal to 1. Default to
#' \code{FALSE}.
#' @param order_labels Logical. If \code{TRUE}, align leaves ordering in all
#' trees (required if your trees don't have their leaves ordered identically).
#' Default to \code{FALSE}.
#'
#' @return An object of class \code{treeTest} with the following entries:
#' \itemize{
...
...
@@ -58,6 +60,8 @@
#' @importFrom reshape2 colsplit
#' @importFrom stats cophenetic
#' @importFrom stats pt
#' @importFrom rlang .data
#' @import testthat
#'
#' @examples
#' leaves <- c(100, 120, 50, 80)
...
...
@@ -98,7 +102,7 @@ treediff <- function(trees1, trees2, replicates, scale = FALSE,
order_labels
=
FALSE
)
{
# Check if `replicates` is numeric vector
if
(
inh
eri
ts
(
replicates
,
"numeric"
)
!=
TRUE
)
{
if
(
!
is.num
eri
c
(
replicates
)
)
{
stop
(
"`replicates` is not a numeric vector"
)
}
...
...
@@ -169,13 +173,14 @@ treediff <- function(trees1, trees2, replicates, scale = FALSE,
# Aggregate p-values
out_aggr
<-
suppressWarnings
(
outp
%>%
group_by
(
cluster
)
%>%
summarise
(
"p.value"
=
min
(
sort
(
p.value
)
/
(
1
:
p
))
*
p
,
.groups
=
"keep"
)
%>%
group_by
(
.data
$
cluster
)
%>%
summarise
(
"p.value"
=
min
(
sort
(
.data
$
p.value
)
/
(
1
:
.data
$
p
))
*
.data
$
p
,
.groups
=
"keep"
)
%>%
unique
())
# Store results in a list
data_name
<-
paste
(
substitute
(
trees1
),
"and"
,
substitute
(
trees2
))
out
<-
list
(
"method"
=
"Tree test based on t-test"
,
out
<-
list
(
"method"
=
"Tree test based on
aggregated
t-test
s
"
,
"data.name"
=
data_name
,
"p.value"
=
out_aggr
$
p.value
,
"statistic"
=
outp
$
statistics
,
...
...
@@ -189,6 +194,8 @@ treediff <- function(trees1, trees2, replicates, scale = FALSE,
}
#' @export
#' @param x a \code{treeTest} object to print
#' @param ... not used
#' @rdname treediff
print.treeTest
<-
function
(
x
,
...
)
{
...
...
@@ -199,17 +206,18 @@ print.treeTest <- function(x, ...) {
cat
(
"\n"
)
# Print the name of the data used in the test
cat
(
"data
: "
,
x
$
data.name
,
"\n"
,
sep
=
""
)
cat
(
"data: "
,
x
$
data.name
,
"\n"
,
sep
=
""
)
# print alternative hypothesis
cat
(
"alternative hypothesis
: sets of trees
ar
e different."
)
cat
(
"alternative hypothesis:
the two
sets of trees
hav
e different
structure
."
)
cat
(
"\n\n"
)
# print the first 5 p-values
print
(
colsplit
(
x
$
p.value
,
" "
,
"p
.
values
:"
),
max
=
5
)
print
(
colsplit
(
x
$
p.value
,
" "
,
"p
-
values:"
),
max
=
5
)
}
#' @method summary treeTest
#' @param object a \code{treeTest} object to print
#' @export
#' @rdname treediff
...
...
@@ -219,7 +227,7 @@ summary.treeTest <- function(object, ...) {
cat
(
"\nSummary\n"
)
# Print the class of the object
cat
(
"\tClass
: "
,
class
(
object
))
cat
(
"\tClass: "
,
class
(
object
))
cat
(
"\n"
)
# Print the test output
...
...
@@ -227,13 +235,14 @@ summary.treeTest <- function(object, ...) {
cat
(
"\n"
)
# Print a summary of the p.value
cat
(
"
p.
value\n"
)
cat
(
"
p-
value
summary:
\n"
)
print
(
summary
(
object
$
p.value
))
cat
(
"\n"
)
# Print a summary of the `statistic` and `p.value.indiv`
summary
(
data.frame
(
"statistic"
=
object
$
statistic
,
"p.value.indiv"
=
object
$
p.value.indiv
))
summary
(
data.frame
(
"indiv. statistics"
=
object
$
statistic
,
"indiv. p-values"
=
object
$
p.value.indiv
,
check.names
=
FALSE
))
}
compute_squeeze
<-
function
(
dist_coph
,
replicates
)
{
...
...
This diff is collapsed.
Click to expand it.
man/treediff.Rd
+
21
−
13
View file @
d2aefee3
...
...
@@ -26,24 +26,32 @@ different from that of \code{trees1}.}
\item{replicates}{A numeric vector of length 2 with the number of replicates
for each condition.}
\item{scale}{Logical. If \code{TRUE}, the trees are all rescalled to have a
minimum height equal to 0 and a maximum height equal to 1.}
\item{scale}{Logical. If \code{TRUE}, the trees are all rescaled to have a
minimum height equal to 0 and a maximum height equal to 1. Default to
\code{FALSE}.}
\item{order_labels}{Logical. If \code{TRUE}, take a reference tree and keep
track of leave order.}
\item{order_labels}{Logical. If \code{TRUE}, align leaves ordering in all
trees (required if your trees don't have their leaves ordered identically).
Default to \code{FALSE}.}
\item{x}{a \code{treeTest} object to print}
\item{...}{not used}
\item{object}{a \code{treeTest} object to print}
}
\value{
An object of class \code{treeTest} with the following entries:
\itemize{
\item{p.value}{ the p-value for the treediff test.}
\item{statistic}{ the value of the Student's statistic of each leaf pair of
the tree test.}
\item{p.value.indiv}{ the p-value of the Student's test for each leaf pair
of the tree test.}
\item{method}{ a character string indicating what type of test was
performed.}
\item{data.name}{ a character string giving the names of the tree
conditions.}
\item{p.value}{ the p-value for the treediff test.}
\item{statistic}{ the value of the Student's statistic of each leaf pair of
the tree test.}
\item{p.value.indiv}{ the p-value of the Student's test for each leaf pair
of the tree test.}
\item{method}{ a character string indicating what type of test was
performed.}
\item{data.name}{ a character string giving the names of the tree
conditions.}
}
}
\description{
...
...
This diff is collapsed.
Click to expand it.
tests/testthat/test-treediff.R
+
5
−
6
View file @
d2aefee3
...
...
@@ -29,7 +29,7 @@ trees1 <- unlist(trees[1,], recursive = FALSE)
trees2
<-
unlist
(
trees
[
2
,],
recursive
=
FALSE
)
# Set the number of replicates
replicates
=
c
(
4
,
6
)
replicates
<-
c
(
4
,
6
)
test_that
(
"'treediff' works for simple cases"
,
{
...
...
@@ -70,25 +70,24 @@ test_that("'treediff' works for simple cases", {
})
## Test errors
test_that
(
"Test errors"
,
{
# Test if replicates is numeric vector
expect_error
(
treediff
(
trees1
=
trees1
,
trees2
=
trees2
,
replicates
=
"abc"
),
"`replicates` is not a numeric vector"
)
# Test if replicates is a vector of length 2
expect_error
(
treediff
(
trees1
=
trees1
,
trees2
=
trees2
,
replicates
=
c
(
1
,
2
,
3
)
),
expect_error
(
treediff
(
trees1
=
trees1
,
trees2
=
trees2
,
replicates
=
1
:
3
),
"`replicates` must be a vector of length 2."
)
# Test if output is a list with class treeTest
out
<-
treediff
(
trees1
,
trees2
,
c
(
4
,
6
))
out
<-
treediff
(
trees1
,
trees2
,
c
(
4
,
6
))
expect_true
(
inherits
(
out
,
"treeTest"
))
# Test if the number of leaves in each cluster is the same between the two
# sets of trees
trees2
[[
5
]]
$
order
<-
c
(
trees2
[[
5
]]
$
order
,
101
)
expect_error
(
treediff
(
trees1
,
trees2
,
c
(
4
,
6
)),
"the number of leaves in one or more clusters is different between the two sets of trees."
)
expect_error
(
treediff
(
trees1
,
trees2
,
c
(
4
,
6
)),
"the number of leaves in one or more clusters is different between the two sets of trees."
)
})
...
...
This diff is collapsed.
Click to expand it.
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