% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ECToBlob.R
\name{ECToBlob_quad}
\alias{ECToBlob_quad}
\title{Edge Contraction to infer a Tree of Blobs - quadripartition mode}
\usage{
ECToBlob_quad(
  genedata,
  tree,
  testCorrection = "Bon",
  alpha = NA,
  beta = 0.8,
  colorCutoff = 0.05,
  plot = 3,
  refTree = NULL,
  omit = FALSE,
  lambda = 0,
  method = "MLest",
  smallsample = "precomputed",
  smallcounts = "precomputed",
  bootstraps = 10^4
)
}
\arguments{
\item{genedata}{one of:
\enumerate{
\item a character string giving the name of a file containing a list of newick 
gene trees (see argument \code{omit}),
\item a multiphylo object containing a collection of gene trees (see argument \code{omit}),
\item a table of resolved quartet counts  from a collection of
gene trees, or that table with additional columns of quartet p-values. If p_star
or both p_T1-D and qindex-D are present (such as from a previous call to this function) 
they are not recomputed.}}

\item{tree}{a tree as a phylo object, or a character string giving the name of 
a file with a newick tree, assumed to be a resolution of the true
tree of blobs}

\item{testCorrection}{a method for combining possibly dependent p-values to 
get a single p-value, one of "Cauchy", "Bon", "BBC", "CBC"}

\item{alpha}{test level for choosing inferred tree of blobs}

\item{beta}{test level for collapsing edges showing no resolution}

\item{colorCutoff}{level for changing color of edge p-values for T1 test}

\item{plot}{0 for no plot;
1 to plot all trees as edges are contracted, along with plot of tree p-values;
2 to add -log_10 of p-values < \code{colorCutoff} for T1 test, or > beta for star test, to edges in plots;
3 to add red dots at multifurcations;
4 to suppress red dots but show all edge p-values}

\item{refTree}{a reference tree, as a phylo object, to compute RF distance to 
all Tk (for simulation studies); will be unrooted}

\item{omit}{\code{FALSE} to treat unresolved quartets on gene trees as 1/3 of each resolution;
\code{TRUE} to discard unresolved quartet data; ignored if genedata given as quartet table}

\item{lambda}{parameter for power-divergence statistic (e.g., 0 for likelihood
ratio statistic, 1 for Chi-squared statistic)}

\item{method}{"MLest", "conservative", or "bootstrap"}

\item{smallsample}{"precomputed" or "bootstrap", method of obtaining p-value
when sample is small (<30)}

\item{smallcounts}{"precomputed" or "bootstrap", method of obtaining p-value
when some (but not all) counts are small}

\item{bootstraps}{number of samples for bootstrapping}
}
\value{
An invisible list with 8 elements:
\describe{
\item{$treeList}{A list corresponding to edge contraction steps.}
\item{$indexEarly}{The index in \code{$treeList} of the first tree such that
the combined tree T1 is above \code{alpha}.}
\item{$indexLate}{The index in \code{$treeList} of the first tree such that
the combined tree T1 of it and all subsequent ones is above \code{alpha}.}
\item{$alpha}{The value of \code{alpha} determining the previous 2 entries.}
\item{$beta}{The value of \code{beta} for contracting edges using the 
combined star test.}
\item{$qType}{The quartet type mode used.}
\item{$testCorrection}{The p-value combination method used.}
\item{$pTable}{A table of quartet p-values for relevant
quartet tests.}
}

In \code{$treeList}, the
first is the input tree,
the second the result of contracting edges judged unresolved
by the combined star test,
and subsequent ones the result of collapsing edges with the current
smallest combined T1 test p-value, with the final one a star tree.
Each element in this list itself a
list of \describe{
\item{$tree}{A tree, with all edge lengths 1 and a node labels
of -log of the parent edge's combined p (star for the input tree, T1 for others).}
\item{$logpTree}{-log base 10 of the combined T1 p-value of the tree using \code{testCorrection}.}
\item{$logpT1Edge}{-log base 10 of the combined T1 p-value of the edge(s)
 that were contracted from previous tree (\code{NA}
for input tree and second tree).}
\item{$numEdgeCon}{The number of edges that have been contracted from the input tree}
\item{$RF}{The RF distance between this tree and \code{refTree}, if \code{refTree} is not NULL.}
}
}
\description{
Infer the tree of blobs using edge contraction and quadripartitions
}
\details{
Given quartet gene tree count data from a network and a starting tree that is
a resolution of its tree of blobs, contract edges for which there is poor support
due to, first, star-like quartet signals and then successively the most extreme
non-tree-like signals.

p-values for star and T1 tests for individual quartets displayed on the tree are
combined by one of 4 test correction methods suitable for non-independent tests. For both
star and T1 test, only p-values for quartets defining each edge are combined.
(For T1, this means defining the edge after any star edge contractions have been done.)

The input tree should be computed by ASTRAL, or another heuristic known to
produce a resolution of the tree of blobs in ideal circumstances.

Plot levels allow for several graphical depictions of the edge contract process,
from the starting tree to a final star tree.

For testing with simulated data, a reference tree (e.g., the true Tree of Blobs) 
may be provided and the RF distance between it and each tree will be shown.
}
\examples{
data(ASTRALtreeLeopardusLescroart)
Atree=read.tree(text=ASTRALtreeLeopardusLescroart)
data(tableLeopardusLescroart)
ECToBlob_quad(tableLeopardusLescroart,Atree,"Bon")

}
\references{
\insertRef{ECTo2026}{MSCquartets}

\insertRef{MAR19}{MSCquartets}

\insertRef{LiuXie2020}{MSCquartets}

\insertRef{Chen2022}{MSCquartets}
}
