Learn R Programming

phyclust (version 0.1-9)

file.write: Write data to files by formats

Description

Two major file formats are supported in phyclust, Format phylip and Format fasta. These functions only write files in basic syntax.

Usage

write.fasta(seqdata, filename, classid = NULL, seqname = NULL,
    width.line = 60, lower.case = FALSE, code.type = .code.type[1],
    sep = "")
write.fasta.format(seqdata, filename, classid = NULL, seqname = NULL,
    width.line = 60, sep = "")

write.phylip(seqdata, filename, classid = NULL, seqname = NULL, width.seqname = 10, width.line = 60, lower.case = FALSE, code.type = .code.type[1], sep = "")write.phylip.format(seqdata, filename, classid = NULL, seqname = NULL, width.seqname = 10, width.line = 60, sep = "")

Arguments

seqdata
a matrix contains sequence ids as X in phyclust.
filename
a file name where data is written to.
classid
class id of sequences.
seqname
sequence names.
width.seqname
number of characters of sequence names to be stored.
width.line
width of lines for breaking lines.
lower.case
use lower case of letters to write
code.type
either "NUCLEOTIDE" (default) or "SNP".
sep
a character to split sites, "" (default) and "," for "CODON".

Value

  • Save a text file.

Details

write.fasta and write.phylip are general functions call write.fasta.format and write.phylip.format.

write.fasta.format and write.phylip.format will not do any transformation for input sequences, but directly write them into the file as code.type = NULL in write.fasta and write.phylip.

sep can specify a character which is used to split sites in file. By default, "" denote no character between sites. Only "CODON" id requires a character to avoid ambiguity

References

Phylogenetic Clustering Website: http://thirteen-01.stat.iastate.edu/snoweye/phyclust/

See Also

read.fasta, read.phylip.

Examples

Run this code
# PHYLIP
data.path <- paste(.libPaths()[1], "/phyclust/data/crohn.phy", sep = "")
my.snp <- read.phylip(data.path, code.type = "SNP")
write.phylip(my.snp$org, "new.crohn.phy", code.type = "SNP")

# FASTA
data.path <- paste(.libPaths()[1], "/phyclust/data/pony625.fas", sep = "")
(my.pony <- read.fasta(data.path))
write.fasta(my.pony$org, "new.pony.fas")

# Amino acid in PHYLIP
aa.aid <- nid2aid(my.pony$org)
aa.acode <- aid2acode(aa.aid)
write.phylip(aa.aid, "new.pony.aa.phy", code.type = "AMINO_ACID")
write.phylip.format(aa.aid, "new.pony.aa.aid.phy", sep = ",")
write.phylip.format(aa.acode, "new.pony.aa.acode.phy")

# Amino acid in FASTA
write.fasta(aa.aid, "new.pony.aa.phy", code.type = "AMINO_ACID")
write.fasta.format(aa.aid, "new.pony.aa.aid.phy", sep = ",")
write.fasta.format(aa.acode, "new.pony.aa.acode.fas")

Run the code above in your browser using DataLab