add.leaf {poolfstat}R Documentation

Test all possible connection of a leaf to a graph with non-admixed and or admixed edges

Description

Test all possible connection of a leaf to a graph with non-admixed and or admixed edges

Usage

add.leaf(
  x,
  leaf.to.add,
  fstats,
  only.test.non.admixed.edges = FALSE,
  only.test.admixed.edges = FALSE,
  verbose = TRUE,
  ...
)

Arguments

x

An object of class graph.params or fitted.graph (see details)

leaf.to.add

Name of the leaf to add

fstats

Object of class fstats that contains estimates of the fstats (see compute.fstats)

only.test.non.admixed.edges

If TRUE the function only test non.admixed edges (may be far faster)

only.test.admixed.edges

If TRUE the function only test admixed edges

verbose

If TRUE extra information is printed on the terminal

...

Some parameters to be passed the function fit.graph called internally

Details

The input object x needs to be of class graph.params (as generated by the function generate.graph.params) or fitted.graph (as generated by the function fit.graph or by the function add.leaf itself in the graphs.fit.res elements of the output list). This is to ensure that the matrix describing the structure of the graph (graph slot of these objects) is valid (note that it can be plotted for checks). Hence graph.params objects may have been generated without fstats information (that should be supplied independently to the add.leaf function to obtain information on the fstats involving the candidate leaf defined with the leaf.to.add argument). By default the function tests all the possible positions of a newly added edge connecting the candidate leaf to the graph with both non-admixed (including a new rooting with the candidate leaf as an outgroup) and admixed edges. If n_e is the the number of non-admixed edges of the original graph, the number of tested graphs for non-admixed edges equals n_e+1. The newly added node is named "N-"name of the leaf to add (or with more N if the name already exists). For admixed edges, the number of tested graphs equals n_e*(n_e-1)/2 and for a given tested graph, three nodes named "S-"name of the leaf to add, "S1-"name of the leaf to add and "S2-"name of the leaf to add (or with more S if the name already exists) are added and the admixture proportions are named with a letter (A to Z depending on the number of admixed nodes already present in the graph).

Value

A list with the following elements:

  1. "n.graphs": The number of tested graphs

  2. "fitted.graphs.list": a list of fitted.graph objects (indexed from 1 to n.graphs and in the same order as the list "graphs") containing the results of fitting of each graph.

  3. "best.fitted.graph": The graph (object of class fitted.graph) with the minimal BIC (see function fit.graph) among all the graphs within fitted.graphs.list

  4. "bic": a vector of the n.graphs BIC (indexed from 1 to n.graphs and in the same order as the "fitted.graphs.list" list) (see fit.graph details for the computation of the scores).

See Also

see fit.graph and generate.graph.params.


[Package poolfstat version 2.2.0 Index]