msaPrettyPrint
function provides an R interface to the
powerful LaTeX package texshade.sty which allows for a
highly customizable plots of multiple sequence alignments.msaPrettyPrint(x, y, output=c("pdf", "tex", "dvi", "asis"), subset=NULL, file=NULL, alFile=NULL, askForOverwrite=TRUE, psFonts=FALSE, code=NA, paperWidth=11, paperHeight=8.5, margins=c(0.1, 0.3), shadingMode=c("identical", "similar", "functional"), shadingModeArg=NA, shadingColors=c("blues", "reds", "greens", "grays", "black"), showConsensus=c("bottom", "top", "none"), consensusColors=c("ColdHot", "HotCold", "BlueRed", "RedBlue", "GreenRed", "RedGreen", "Gray"), consensusThreshold=50, showLogo=c("top", "bottom", "none"), logoColors=c("chemical", "rasmol", "hydropathy", "structure", "standard area", "accessible area"), showLogoScale=c("none", "leftright", "left", "right"), showNames=c("left", "right", "none"), showNumbering=c("right", "left", "none"), showLegend=TRUE, furtherCode=NA, verbose=FALSE)
MultipleAlignment
,
which includes the classes MsaAAMultipleAlignment
,
MsaDNAMultipleAlignment
, and
MsaRNAMultipleAlignment
.IRanges
. If missing,
the entire multiple alignment is printed.x
if not all sequences should be printed.x
along with the proper suffix
which depends on the type of output specified with the output
argument. Note that this might lead to
invalid file names if not the name of an object, but an R expression
is passed as argument x
.msaPrettyPrint
first writes the multiple alignment x
to a .fasta
file. The name of this file can be
determined with the alFile
argument. If no name
is given, the name of the output file defaults to name of the
object provided as argument x
along with the suffix
.fasta
. Note that this might lead to
invalid file names if not the name of an object, but an R expression
is passed as argument x
.TRUE
(default),
msaPrettyPrint
asks whether existing files should be
overwritten or not. If askForOverwrite
is set to FALSE
,
files are overwritten without further notice.TRUE
, msaPrettyPrint
produces LaTeX
code that includes the LaTeX package times.sty; if FALSE
,
msaPrettyPrint
produces LaTeX
code based on the standard LaTeX fonts (default). Ignored for
output="asis"
.texshade
environment. This overrides all arguments
that customize the appearance of the output. Instead, all
customizations must be done as LaTeX commands provided by the
package texshade.sty directly. This option should only be used
by expert users and for special applciations in which the
possibilities of the customizations of the msaPrettyPrint
function turn out to be insufficient.output="asis"
."identical"
, "similar"
, and "functional"
are supported (see documentation of
texshade.sty for details)."identical"
and
"similar"
, shadingModeArg
must
be a single numeric threshold between 0 and 100 or two thresholds
between 0 and 100 in increasing order. For shading mode
"functional"
, valid shadingModeArg
arguments are
"charge"
, "hydropathy"
, "structure"
,
"chemical"
, "rasmol"
,
"standard area"
, and "accessible area"
(see documentation of
texshade.sty for details)."shadingColors"
arguments are "blues"
, "reds"
,
"greens"
, "grays"
, and "black"
(see documentation of
texshade.sty for details)."bottom"
, "top"
, and
"none"
(the latter option suppresses printing of the
consensus sequence)."ColdHot"
,
"HotCold"
, "BlueRed"
, "RedBlue"
, "GreenRed"
,
"RedGreen"
, and "Gray"
(see documentation of
texshade.sty for details)."top"
, "bottom"
, or
"none"
(the latter option suppresses printing of the
consensus sequence). If a sequence logo and a consensus
sequence should be shown together, they can only be located at
opposite sides."chemical"
,
"rasmol"
, "hydropathy"
, "structure"
,
"standard area"
, and "accessible area"
(see
documentation of texshade.sty for details)."left"
, "right"
,
"leftright"
, and "none"
(the latter option suppresses
that the axis is displayed)."left"
, "right"
, and
"none"
(the latter option suppresses that names are displayed)."left"
, "right"
, and
"none"
(the latter option suppresses that numbers are displayed).
If sequence names and numbers should be shown together,
they can only be located at opposite sides.TRUE
(default), a legend is
printed at the end of the alignment.texshade
environment; all text passed as
furtherCode
is placed between the commands created by
msaPrettyPrint
and the end of the texshade
environment.
Note the difference to the code
argument: while the
code
argument replaces all LaTeX code in the
texshade
environment, the code passed as
furtherCode
argument is added to the LaTeX code in the
texshade
environment.TRUE
(default), progress messages are
printed and also the output of running (PDF)LaTeX (if
applicable) is printed to the R session.texshade
environment.
msaPrettyPrint
function writes a multiple alignment
to a .fasta
file and creates LaTeX code for
pretty-printing the multiple alignment on the basis of the
LaTeX package texshade.sty. If output="asis"
,
msaPrettyPrint
prints a LaTeX fragment consisting of the
texshade
environment to the console. The parameters described
above can be used to customize the way the multiple alignment is
formatted. If output="tex"
, a complete LaTeX file including
preamble is created. For output="dvi"
and output="pdf"
,
the same kind of LaTeX file is created, but processed using (PDF)LaTeX
to produce a final DVI or PDF file, respectively. The file
argument be used to determine the file name of the final output file
(except for the output="asis"
which does not create an output
file). The choice output="asis"
is particularly useful for Sweave or
knitr documents. If msaPrettyPrint
is called with
output="asis"
in a code chunk with results="tex"
(Sweave) or results="asis"
(knitr), then the resulting LaTeX
fragment consisting of the texshade
environment is directly
included in the LaTeX document that is created from the Sweave/knitr
document.
As noted above, if they are not specified explicitly, output file
names are determined automatically. It is important to point out that
all file names need to be LaTeX-compliant, i.e. no special characters
and spaces (!) are allowed. If a file name would be invalid,
msaPrettyPrint
makes a default choice.
Moreover, if sequence names are to be printed, there might be names
that are not LaTeX-compliant and lead to LaTeX errors. In order
to check that in advance, the function msaCheckNames
is available.
Note that texi2dvi
and texi2pdf
always
save the resulting DVI/PDF files to the current working directory,
even if the LaTeX source file is in a different directory.
That is also the reason why the temporary file is created in the
current working directory in the example below.
https://www.ctan.org/pkg/texshade
Beitz, E. (2000) TeXshade: shading and labeling of multiple sequence alignments using LaTeX2e Bioinformatics 16(2):135-139. DOI: 10.1093/bioinformatics/16.2.135.
msaCheckNames
## read sequences
filepath <- system.file("examples", "exampleAA.fasta", package="msa")
mySeqs <- readAAStringSet(filepath)
## call unified interface msa() for default method (ClustalW) and
## default parameters
myAlignment <- msa(mySeqs)
## show resulting LaTeX code with default settings
msaPrettyPrint(myAlignment, output="asis", askForOverwrite=FALSE)
## create PDF file according to some custom settings
tmpFile <- tempfile(pattern="msa", tmpdir=".", fileext=".pdf")
tmpFile
msaPrettyPrint(myAlignment, file=tmpFile, output="pdf",
showNames="left", showNumbering="none", showLogo="top",
showConsensus="bottom", logoColors="rasmol",
verbose=FALSE, askForOverwrite=FALSE)
## Not run:
# library(Biobase)
# openPDF(tmpFile)## End(Not run)
Run the code above in your browser using DataLab