Learn R Programming

phylosim (version 3.0.5)

readAlignment.PhyloSim: Read alignment from file

Description

Read alignment from file.

This method reads an alignment by using the read.dna function from the ape package and stores in the PhyloSim object. If a tree is already attached to the PhyloSim object, the alignment must at least contain the sequences corresponding to tip nodes (but it may also contain additional ancestral sequences).

Usage

# S3 method for PhyloSim
readAlignment(this, file, format="fasta", ...)

Arguments

this

A PhyloSim object.

file

A file name specified by either a variable of mode character, or a double-quoted string.

format

a character string specifying the format of the DNA sequences. Four choices are possible: "interleaved", "sequential", "clustal", or "fasta", or any unambiguous abbreviation of these.

...

Not used.

Value

The PhyloSim object (invisible).

See Also

For more information see PhyloSim.

Examples

Run this code
# NOT RUN {
	# get a safe file name
	fname<-paste("PhyloSim_dummy_fas_",Sys.getpid(),sep="")
	# write out a fasta alignment
	cat("> t3\nGTCTTT-CG-\n",file=fname);
	cat("> t4\nG--TC-TCGG\n",file=fname,append=TRUE);
	cat("> t2\nG--TC-TCGG\n",file=fname,append=TRUE);
	cat("> t1\nGTC-G-TCGG",file=fname,append=TRUE);
	# construct a PhyloSim object,
	# set the phylo object
	sim<-PhyloSim(phylo=rcoal(4))
	# read the alignment
	readAlignment(sim,fname)
	# remove alignment file
	unlink(fname)
	# plot the tree & alignment
	plot(sim)
 
# }

Run the code above in your browser using DataLab