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
9de3c1fa
Commit
9de3c1fa
authored
2 years ago
by
Nathalie Vialaneix
Browse files
Options
Downloads
Patches
Plain Diff
minor corrections in treediff
parent
98805182
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
R/treediff.R
+7
-3
7 additions, 3 deletions
R/treediff.R
tests/testthat/test-treediff.R
+10
-6
10 additions, 6 deletions
tests/testthat/test-treediff.R
with
17 additions
and
9 deletions
R/treediff.R
+
7
−
3
View file @
9de3c1fa
...
...
@@ -128,6 +128,10 @@ treediff <- function(trees1, trees2, replicates, scale = FALSE,
stop
(
"the number of leaves in one or more clusters is different between "
,
"the two sets of trees."
)
}
# Check if 'scale' and 'order_labels' are logical
if
(
!
is.logical
(
scale
))
stop
(
"'scale' must be logical"
)
if
(
!
is.logical
(
order_labels
))
stop
(
"'order_labels' must be logical"
)
# Merge trees from both conditions
trees
<-
c
(
trees1
,
trees2
)
...
...
@@ -142,7 +146,7 @@ treediff <- function(trees1, trees2, replicates, scale = FALSE,
coph_dist
<-
sapply
(
trees
,
cophenetic
,
simplify
=
FALSE
)
# Normalize
if
(
scale
==
TRUE
)
{
if
(
scale
)
{
coph_dist
<-
normalize_trees
(
coph_dist
)
}
...
...
@@ -155,8 +159,8 @@ treediff <- function(trees1, trees2, replicates, scale = FALSE,
},
coph_dist
,
labels_perm
)
# Convert the result to a list of vectors
coph_vect
<-
lapply
(
1
:
ncol
(
coph_vect
),
function
(
col
)
{
return
(
as.vector
(
coph_vect
[,
col
]))
coph_vect
<-
lapply
(
1
:
ncol
(
coph_vect
),
function
(
a
col
)
{
return
(
as.vector
(
coph_vect
[,
a
col
]))
})
}
else
{
coph_vect
<-
lapply
(
coph_dist
,
function
(
adist
)
{
...
...
This diff is collapsed.
Click to expand it.
tests/testthat/test-treediff.R
+
10
−
6
View file @
9de3c1fa
...
...
@@ -137,16 +137,17 @@ test_that("Test for the scale argument", {
res
<-
treediff
(
trees1
,
trees2
,
replicates
,
scale
=
TRUE
)
# Check the output object has the expected names
expect_named
(
res
,
c
(
"method"
,
"data.name"
,
"p.value"
,
"statistic"
,
"p.value.indiv"
))
expect_named
(
res
,
c
(
"method"
,
"data.name"
,
"p.value"
,
"statistic"
,
"p.value.indiv"
))
# Perform the treediff test without scaling
result1
<-
treediff
(
trees1
,
trees2
,
replicates
)
result2
<-
treediff
(
trees1
,
trees2
,
replicates
,
scale
=
FALSE
)
result3
<-
treediff
(
trees1
,
trees2
,
replicates
,
scale
=
5
)
expect_error
({
result3
<-
treediff
(
trees1
,
trees2
,
replicates
,
scale
=
5
)
},
"'scale' must be logical"
)
expect_equal
(
result1
,
result2
)
expect_equal
(
result1
,
result3
)
})
# Test for the order_labels argument
...
...
@@ -162,8 +163,11 @@ test_that("Test for the order_labels argument", {
hclust
(
dist
(
mtcars
[,
7
:
8
]),
method
=
"ward.D2"
))
# Perform the treediff test with and without ordering the labels
res1
<-
treediff
(
trees1
,
trees2
,
c
(
2
,
2
),
order_labels
=
TRUE
)
res2
<-
treediff
(
trees1
,
trees2
,
c
(
2
,
2
),
order_labels
=
FALSE
)
res1
<-
treediff
(
trees1
,
trees2
,
c
(
2
,
2
),
order_labels
=
TRUE
)
res2
<-
treediff
(
trees1
,
trees2
,
c
(
2
,
2
),
order_labels
=
FALSE
)
expect_error
({
res3
<-
treediff
(
trees1
,
trees2
,
c
(
2
,
2
),
order_labels
=
5
)
},
"'order_labels' must be logical"
)
# Test that the p-values are the same for both tests
expect_equal
(
res1
,
res2
)
...
...
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