write.fas: Write DNA Sequences to File

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

Description

Write DNA sequences and morphological data to FASTA, PHYLIP, or NEXUS formatted files.

Usage

1
2
3
4
5
6
7
8
9
	
write.fas(x, file, block.width = FALSE, 
    truncate = FALSE, append = FALSE)

write.phy(x, file, block.width = FALSE, 
    strict = FALSE)

write.nex(x, file, block.width = 60, 
    taxblock = FALSE)

Arguments

x

an object of class DNAbin (usually as matrix, but write.fas also accepts lists) or a list of objects of class DNAbin (only write.nex) or a data frame containing standard (morphological, etc.) data (only write.nex).

file

a character string giving the filename; a special case is file = "", which causes the file content to be written on the standard output connection (i.e. the console). If file is left unspecified (default), the file content is returned as a vector of mode "character" and can be used as a building block for more complex data files.

block.width

an integer, giving the number of characters per line.

truncate

truncation of taxon names to the number of characters given as a integer, otherwise (default) taxon names will not be changed.

append

logical, if TRUE the sequences will be appended to file (if it exists).

strict

logical, if TRUE the names of the sequences will be truncated to 10 strings.

taxblock

logical, if TRUE, a tax block will be added to the NEXUS file.

Details

write.nex can handle multiple DNA sequence alignments, which are handed over as a list of objects of class DNAbin. Correct matching of the rows in the alignments is cared for automatically, hence the individual alignments can contain different numbers of samples and samples need not be in the same order.

Value

None, except when called with file left unspecified, which causes the file content to be returned as a vector of mode "character". This is particularly useful for constructing special types of input files, e.g. for MrBayes (mrbayes).

Author(s)

Christoph Heibl

References

Maddison, D.R., D.L. Swofford, and W.P. Maddison. 1997. NEXUS: an extensible file format for systematic information. Syst. Biol. 46: 590-621.

See Also

read.fas, read.phy, and read.nex for reading of DNA sequence files.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
data(ips.cox1)
data(ips.28S)

## Examples for FASTA files
## ------------------------
write.fas(ips.cox1[1:5, 1:120], block.width = 60)

## Examples for PHYLIP files
## ------------------------
write.phy(ips.cox1[1:5, 1:20], block.width = 40)

## Examples for NEXUS files
## ------------------------
x <- list(cox1 = ips.cox1[1:5, 1:10], 
          rna28S = ips.28S[1:5, 1:30])
write.nex(x, block.width = 20)

# Truncation of taxonnames:
# -------------------------
rownames(ips.cox1)[1] <- "AVeeeeeeeeeeeeeeeeeryLongName"
write.fas(ips.cox1, truncate = 10)

# If truncation leads to identical taxonnames,
# a warning will be issued:
# -------------------------
rownames(ips.cox1)[1:2] <- "AVeeeeeeeeeeeeeeeeeryLongName"
write.fas(ips.cox1, truncate = 10)

ips documentation built on July 4, 2019, 5:04 p.m.