Learn R Programming

seedy (version 1.3)

librtoDNA: Convert simulation objects to DNA sequences or Nexus/Fasta files.

Description

Creates a character string or matrix of nucleotides (C, A, G, T), output to vector, matrix or Nexus file.

Usage

librtoDNA(sampleID, libr, nuc, ref.strain, key, sampletime=NULL, 
          strings = FALSE, filename = NULL, format = "nexus")

Arguments

sampleID
Vector of sample IDs to output.
libr
Library object from simulation functions. A list in which each entry represents a unique genotype, and is a vector of mutated nucleotide positions relative to the reference sequence.
nuc
Nucleotide database from simulation functions. A list (corresponding to libr) in which each entry represents a unique genotype, and is a vector of mutated nucleotides relative to the reference sequence.
ref.strain
Reference strain to which the libr and nuc objects are compared (string of integers in 1,...,4).
key
Vector of sample IDs corresponding to the order of libr.
sampletime
Vector of sample times. If specified, incorporates sample times into genome name in Nexus file.
strings
If TRUE, returns a character vector, each element containing one genotype. Otherwise, returns a (number of genotypes)x(length of genome) character matrix.
filename
File to which sequence data should be written. Output format is Nexus. Not written out if NULL.
format
File format to be exported (if filename!=NULL). Options are "nexus" and "fasta".

Value

  • A character vector or matrix, depending on strings.

Examples

Run this code
data(withinhost)
G <- librtoDNA(sampleID=withinhost$obs.strain, libr=withinhost$libr, nuc=withinhost$nuc, 
               ref.strain=withinhost$ref.strain, key=withinhost$librstrains, strings=TRUE)

Run the code above in your browser using DataLab