View source: R/helper.functions.R
write.nexus | R Documentation |
Takes a character
vector or a DNAStringSet
and write a nexus
file to disk.
write.nexus(
x,
aln = FALSE,
gapOpening = c(-18, -16),
gapExtension = c(-2, -1),
dir.out,
fn,
charset = FALSE,
locusIDs,
locusLength,
verbose = FALSE
)
x |
Either a |
aln |
Logical. Whether x is an alignment |
gapOpening |
Integer (negative). Penalty for opening a gap in the alignment |
gapExtension |
Integer (negative). Penalty for extending a gap in the alignment |
dir.out |
The path where to save the output |
fn |
The output file name |
charset |
Whether a charset block should be added at the end of the nexus file |
locusIDs |
|
locusLength |
Integer vector with the length of each locus (if
|
If x
is a character
vector, it will convert it to a
DNAStringSet
. if aln=FALSE
, write.nexus
will align the
sequences first and then write the nexus file. If aln=TRUE
, it will
assume that all sequences have the same length and are aligned.
If charset=TRUE
, write.nexus
will append a character block at
the end of the file. This is sometimes used to partition the alignment when
it is imported in software like BEAST2
Writes a nexus file to disk
seqs <- c("AAATTTT", "GAATTCT")
names(seqs) <- c("seq1", "seq2")
x <- Biostrings::DNAStringSet(seqs)
locusNames <- c("locus1", "locus2")
locusLen <- c(3, 4)
tmpDir <- tempdir(check = TRUE)
write.nexus(x, aln=TRUE, dir.out=tmpDir, fn="aln.nex", charset=TRUE,
locusIDs=locusNames, locusLength=locusLen)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.