Skip to content
Snippets Groups Projects
Commit c0217284 authored by Nathalie Vialaneix's avatar Nathalie Vialaneix
Browse files

very minor corrections in code

parent 849278dd
No related branches found
No related tags found
No related merge requests found
# Generated by roxygen2: do not edit by hand
export(fisher_mix)
export(treediff)
importFrom(dplyr,"%>%")
importFrom(dplyr,group_by)
importFrom(dplyr,summarise)
importFrom(limma,squeezeVar)
importFrom(reshape2,colsplit)
importFrom(stats,cophenetic)
importFrom(stats,pt)
importFrom(stats,rf)
......@@ -17,7 +17,8 @@
#' @param replicates A numeric vector of length 2 with the number of replicates
#' for each condition.
#'
#' @return An object of class \code{treeTest} with the following entries: \itemize{
#' @return 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.}
......@@ -29,10 +30,11 @@
#' conditions.}
#' }
#'
#' @author Pierre Neuvial \email{pierre.neuvial@math.univ-toulouse.fr}\cr
#' Nathanaël Randriamihamison\cr
#' @author Gwendaelle Cardenac\cr
#' Marie Chavent \email{marie.chavent@u-bordeaux.fr}\cr
#' Sylvain Foissac \email{sylvain.foissac@inrae.fr}\cr
#' Pierre Neuvial \email{pierre.neuvial@math.univ-toulouse.fr}\cr
#' Nathanaël Randriamihamison\cr
#' Nathalie Vialaneix \email{nathalie.vialaneix@inrae.fr}
#'
#' @references Neuvial Pierre, Randriamihamison Nathanaël, Chavent Marie,
......@@ -52,11 +54,10 @@
#'
#'
#' @examples
#' leaves <- c(100, 120, 50, 80)
#'
#' leaves <- c(100,120,50,80)
#'
#' trees <- sapply(leaves, FUN = function(l){
#' base_data <- matrix(rnorm(2000), nrow = l, ncol = 200)
#' trees <- sapply(leaves, FUN = function(leaf) {
#' base_data <- matrix(rnorm(2000), nrow = leaf, ncol = 200)
#'
#' ## generates two sets of trees with 4 clusters with 100, 120, 50 and 80
#' ## leaves respectively
......@@ -79,22 +80,22 @@
#' return(list("trees1" = trees1, "trees2" = trees2))
#' })
#'
#' trees1 <- unlist(trees[1,], recursive = FALSE)
#' trees2 <- unlist(trees[2,], recursive = FALSE)
#' replicates = c(4, 6)
#' trees1 <- unlist(trees[1, ], recursive = FALSE)
#' trees2 <- unlist(trees[2, ], recursive = FALSE)
#' replicates <- c(4, 6)
#'
#' tree_pvals <- treediff(trees1, trees2, replicates)
#' ## 4 p-values, one for each cluster
#' tree_pvals$p.value
treediff <- function(trees1, trees2, replicates){
treediff <- function(trees1, trees2, replicates) {
# Check if `replicates` is numeric vector
if (inherits(replicates, "numeric") != TRUE){
if (inherits(replicates, "numeric") != TRUE) {
stop("`replicates` is not a numeric vector")
}
# Check if the length of replicates is 2
if (length(replicates) != 2){
if (length(replicates) != 2) {
stop("`replicates` must be a vector of length 2.")
}
......@@ -111,7 +112,7 @@ treediff <- function(trees1, trees2, replicates){
tree_order2 <- lapply(trees2, "[[", "order")
leaves2 <- sapply(tree_order2, length)
if (!identical(unique(leaves1), unique(leaves2))){
if (!identical(unique(leaves1), unique(leaves2))) {
stop("the number of leaves in one or more clusters is different between ",
"the two sets of trees.")
}
......@@ -230,7 +231,7 @@ compute_pvalue <- function(average_coph, squeezed_var, replicates) {
cluster <- average_coph$cluster
# Calculate the numerator for the t-statistic
numerator <- Reduce("-", average_coph[,-3])
numerator <- Reduce("-", average_coph[, -3])
# Store replicates values for each group
n1 <- replicates[1]
......
......@@ -21,7 +21,8 @@ different from that of \code{trees1}.}
for each condition.}
}
\value{
An object of class \code{htest} with the following entries: \itemize{
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.}
......@@ -42,11 +43,10 @@ method. The p-values are obtained by the treediff method, as described in
(Neuvial \emph{et al.}, 2023).
}
\examples{
leaves <- c(100, 120, 50, 80)
leaves <- c(100,120,50,80)
trees <- sapply(leaves, FUN = function(l){
base_data <- matrix(rnorm(2000), nrow = l, ncol = 200)
trees <- sapply(leaves, FUN = function(leaf) {
base_data <- matrix(rnorm(2000), nrow = leaf, ncol = 200)
## generates two sets of trees with 4 clusters with 100, 120, 50 and 80
## leaves respectively
......@@ -69,9 +69,9 @@ trees <- sapply(leaves, FUN = function(l){
return(list("trees1" = trees1, "trees2" = trees2))
})
trees1 <- unlist(trees[1,], recursive = FALSE)
trees2 <- unlist(trees[2,], recursive = FALSE)
replicates = c(4, 6)
trees1 <- unlist(trees[1, ], recursive = FALSE)
trees2 <- unlist(trees[2, ], recursive = FALSE)
replicates <- c(4, 6)
tree_pvals <- treediff(trees1, trees2, replicates)
## 4 p-values, one for each cluster
......@@ -84,9 +84,10 @@ structure between families of trees. \emph{Preprint submitted for
publication}.
}
\author{
Pierre Neuvial \email{pierre.neuvial@math.univ-toulouse.fr}\cr
Nathanaël Randriamihamison\cr
Gwendaelle Cardenac\cr
Marie Chavent \email{marie.chavent@u-bordeaux.fr}\cr
Sylvain Foissac \email{sylvain.foissac@inrae.fr}\cr
Pierre Neuvial \email{pierre.neuvial@math.univ-toulouse.fr}\cr
Nathanaël Randriamihamison\cr
Nathalie Vialaneix \email{nathalie.vialaneix@inrae.fr}
}
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