[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ micropan  (version  1.0  ) ](/packages/micropan/versions/1.0)

#  panTree: Constructing pan-genome trees

##  Description

Creates a pan-genome tree based on a pan-matrix and a distance function.

##  Usage

    
    
    panTree(pan.matrix, dist.FUN=distManhattan, nboot=0, linkage="average", ...)

##  Arguments

pan.matrix

A ` Panmat ` object, see ` [ panMatrix
](/link/panMatrix?package=micropan&version=1.0) ` .

dist.FUN

A valid distance function, see below.

nboot

Number of bootstrap samples.

linkage

The linkage function, see below.

...

Additional parameters passed on to the specified distance function, see
Details below.

##  Value

This function returns a ` Pantree ` object, which is a small (S3) extension to
a ` [ list ](/link/list?package=micropan&version=1.0) ` with 4 components.
These components are named  Htree  ,  Nboot  ,  Nbranch  and  Dist.FUN  .
Htree  is a ` [ hclust ](/link/hclust?package=micropan&version=1.0) ` object.
This is the actual tree.  Nboot  is the number of bootstrap samples.  Nbranch
is a vector listing the number of times each split/clade in the tree was
observed in the bootstrap procedure.  Dist.FUN  is the name of the distance
function used to construct the tree.

##  Details

A pan-genome tree is a graphical display of the genomes in a pan-genome study,
based on some pan-matrix (Snipen & Ussery, 2010). ` [ panTree
](/link/panTree?package=micropan&version=1.0) ` is a constructor that computes
a ` Pantree ` object, use ` [ plot.Pantree
](/link/plot.Pantree?package=micropan&version=1.0) ` to actually plot the
tree. The parameter  dist.FUN  must be a function that takes as input a
numerical matrix ( ` Panmat ` object) and returns a ` [ dist
](/link/dist?package=micropan&version=1.0) ` object. See ` [ distManhattan
](/link/distManhattan?package=micropan&version=1.0) ` or ` [ distJaccard
](/link/distJaccard?package=micropan&version=1.0) ` for examples of such
functions. Any additional arguments (  ...  ) are passed on to this function.
If you want to have bootstrap-values in the tree, set  nboot  to some
appropriate number (e.g.  nboot=100  ). The tree is created by ` [ hclust
](/link/hclust?package=micropan&version=1.0) ` (hierarchical clustering) using
the  average  linkage function, which is according to Snipen & Ussery, 2010.
You may specify alternatives by the parameter  linkage  , see ` [ hclust
](/link/hclust?package=micropan&version=1.0) ` for details.

##  References

Snipen, L., Ussery, D.W. (2010). Standard operating procedure for computing
pangenome trees. Standards in Genomic Sciences, 2:135-141.

##  See Also

` [ panMatrix ](/link/panMatrix?package=micropan&version=1.0) ` , ` [
distManhattan ](/link/distManhattan?package=micropan&version=1.0) ` , ` [
distJaccard ](/link/distJaccard?package=micropan&version=1.0) ` , ` [
plot.Pantree ](/link/plot.Pantree?package=micropan&version=1.0) ` .

##  Examples

[ Run this code
](https://www.datacamp.com/datalab/preview?_tag=rdocs&rdocsPath=packages%2Fmicropan%2Fversions%2F1.0%2Ftopics%2FpanTree&utm_source=r-docs&utm_medium=docs&utm_term=panTree&utm_content=run_example_in_datalab)

    
    
    # Loading a Panmat object, constructing a tree and plotting it
    data(list="Mpneumoniae.blast.panmat",package="micropan")
    my.tree <- panTree(Mpneumoniae.blast.panmat)
    plot(my.tree)
    
    # Computing some weights to be used in the distManhattan 
    # function below...
    w <- geneWeights(Mpneumoniae.blast.panmat,type="shell")
    # Creating another tree with scaled and weighted distances and bootstrap values
    my.tree <- panTree(Mpneumoniae.blast.panmat, scale=0.1, weights=w)
    
    # ...and plotting with alternative labels and colors from Mpneumoniae.table
    data(list="Mpneumoniae.table",package="micropan")
    labels <- Mpneumoniae.table$Strain
    names(labels) <-