WriteDendrogram: Write a Dendrogram to Newick Format

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/WriteDendrogram.R

Description

Writes a dendrogram object to a file in Newick (also known as New Hampshire) parenthetic format.

Usage

1
2
3
4
5
6
7
WriteDendrogram(x,
                file = "",
                quoteLabels = TRUE,
                convertBlanks = !quoteLabels,
                internalLabels = TRUE,
                digits = 10,
                append = FALSE)

Arguments

x

An object of class dendrogram.

file

A connection or a character string naming the file path where the tree should be exported. If "" (the default), the tree is printed to the standard output connection, the console unless redirected by sink.

quoteLabels

Logical specifying whether to place leaf labels in double quotes.

convertBlanks

Logical specifying whether to convert spaces in leaf labels to underscores.

internalLabels

Logical indicating whether to write any “edgetext” preceding a node as an internal node label.

digits

The maximum number of digits to print for edge lengths.

append

Logical indicating whether to append to an existing file. Only applicable if file is a character string. If FALSE (the default), then the file is overwritten.

Details

WriteDendrogram will write a dendrogram object to a file in standard Newick format. Note that special characters (commas, square brackets, colons, semi-colons, and parentheses) present in leaf labels will likely cause a broken Newick file unless quoteLabels is TRUE (the default).

Value

NULL.

Author(s)

Erik Wright [email protected]

See Also

IdClusters, ReadDendrogram

Examples

1
2
3
4
5
dists <- matrix(c(0, 10, 20, 10, 0, 5, 20, 5, 0),
    nrow=3,
    dimnames=list(c("dog", "elephant", "horse")))
dend <- IdClusters(dists, method="NJ", type="dendrogram")
WriteDendrogram(dend)

Example output

Loading required package: Biostrings
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colMeans, colSums, colnames, do.call,
    duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
    lapply, lengths, mapply, match, mget, order, paste, pmax, pmax.int,
    pmin, pmin.int, rank, rbind, rowMeans, rowSums, rownames, sapply,
    setdiff, sort, table, tapply, union, unique, unsplit, which,
    which.max, which.min

Loading required package: S4Vectors
Loading required package: stats4

Attaching package: 'S4Vectors'

The following object is masked from 'package:base':

    expand.grid

Loading required package: IRanges
Loading required package: XVector

Attaching package: 'Biostrings'

The following object is masked from 'package:base':

    strsplit

Loading required package: RSQLite

  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |======================================================================| 100%

Time difference of 0.14 secs

("dog":10,("horse":7.5,"elephant":2.5):2.5);

DECIPHER documentation built on Nov. 1, 2018, 4:42 a.m.