how to solve this error when run latex in R? - r

I'm trying to generate some plots in latex using R, here is the code:
msaPrettyPrint(seq_mapped, output="pdf", showNames="none",
showLogo="none", askForOverwrite=FALSE, verbose=FALSE)
and the error:
Error in texi2dvi(texfile, quiet = !verbose, pdf = identical(output, "pdf"), :
unable to run pdflatex on 'seq_mapped.tex'
LaTeX errors:
! Paragraph ended before \inf##get was complete.
<to be read again>
\par
l.25 ...e}{/tmp/RtmppWEuqI/seq108d544be5486.fasta}
! Misplaced alignment tab character &.
\msfline ->\par &
& & & #
l.25 ...e}{/tmp/RtmppWEuqI/seq108d544be5486.fasta}
! Misplaced alignment tab character &.
\msfline ->\par & &
& & #
l.25 ...e}{/tmp/RtmppWEuqI/seq108d544be5486.fasta}
! Misplaced alignment tab character &.
\msfline ->\par & & &
& #
l.25 ...e}{/tmp/RtmppWEuqI/seq108d544be5486.fasta}
! Misplaced alignment tab character &.
\msfline ->\par & & & &
#
l.25 ...e}{/tmp/RtmppWEuqI/seq108d544be5486.fasta}
I've also tried:
msaPrettyPrint(seq_mapped, output="tex", showNames="none",
showLogo="none", askForOverwrite=FALSE, verbose=FALSE)
tools::texi2pdf("seq_mapped.tex", clean=TRUE)
but still have an error
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
Running 'texi2dvi' on 'seq_mappedt.tex' failed.
LaTeX errors:
! LaTeX Error: File `texshade.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)
! Emergency stop.
<read *>
l.4 ^^M
! ==> Fatal error occurred, no output PDF file produced!
However, the texshade.sty is installed:
system.file("tex", "texshade.sty", package="msa")
[1] ".../R/x86_64-pc-linux-gnu-library/4.1/msa/tex/texshade.sty"
Any ideas?
FYI: Ubuntu 20.04.2 LTS focal
Thanks

I just came across this thread accicentally and I am aware that it 11 months old. However, just in case that it might be of help to somebody, I dare to reply...
Well, let's first start with the second question: You use msaPrettyPrint() to write a .tex file and then you call texi2dvi(). However, you do not supply texi2dvi() with the information where texshade.sty is. This must be done, since texshade.sty is stored within the msa package's folder, and not in the standard folders where LaTeX looks for input files. Long story short - you should do this:
tools::texi2pdf("seq_mapped.tex", texinputs=system.file("tex", package="msa"),clean=TRUE)
If you do that with the same input data as in the first question, I suppose that the same problem would also arise. In order to answer that in a more qualified way, I would need to try myself with the original files? Are you able to put together a minimal example exhibiting this problem and send it to me by e-mail? (msa#bioinf.jku.at)

Related

dir? or any command followed by "?" yields a + sign. Why?

Just experimenting with help in RStudio. So I type setwd? and the help comes up in another RStudio window. Now I type ls? ( at the console ) and all I get is "+". What's it expecting? I was told you don't need to put the () in and even if you do, same thing happens. I have to escape out of it. Shut down and startup...same problem and same ole' output from setwd?.
I'm on a MacBook air M1 macOS BigSur 11.3.1
It's expecting a string/object after the ? to search the prior type of files for. The characters before the ? it is treating as a type. If nothing is before the ? it searches all types of documentation: objects, packages, etc. Examples:
Is?is
Error in `?`(Is, is) :
no documentation of type ‘Is’ and topic ‘is’ (or error in processing help)
?"is"
?is
package?methods

Error loading file in Sage

I am trying to use Sage on a mac and am not particularly computer savvy (e.g. I still haven't figured out what I am meant to do with PATH and find the installation documentation a bit forbidding). I am running sage from the command line from a particular folder which contains a file "test.sage" but when I put 'load("test.sage")' I get the following error message:
TypeError Traceback (most recent call last)
in ()
----> 1 load("test.sage")
/Applications/SageMath/src/sage/structure/sage_object.pyx in sage.structure.sage_object.load (/Applications/SageMath/src/build/cythonized/sage/structure/sage_object.c:11186)()
if sage.repl.load.is_loadable_filename(filename):
sage.repl.load.load(filename, globals())
return
/Applications/SageMath/local/lib/python2.7/site-packages/sage/repl/load.pyc in load(filename, globals, attach)
if attach:
add_attached_file(fpath)
exec(preparse_file(open(fpath).read()) + "\n", globals)
elif ext == '.spyx' or ext == '.pyx':
if attach:
Error message
TypeError: expected string without null bytes"
Earlier on I was trying the same thing and getting the message:
"IOError('did not find file %r to load or attach'"
I wonder if someone could tell me what I am doing wrong or might try to fix the problem?

In R why do you need two // sometimes to read in a directory

I figured out how to read in my files a different why then I have been taught, but I had to use two // in stead of /, like I normally do. Can someone explain why do I need two // in r to vs one / in r to read a directory, while other times / works just fine?
Look at these examples:
> data<-read.table('c:/test.txt')
> data<-read.table('c:\\test.txt')
> data<-read.table('c:\test.txt')
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") : cannot open file 'c: est.txt': Invalid argument
See? If you use single '\', sometimes it gets confusing as in this case '\t' is the tab key. '\t' fixes this as double '\' is considered as the real '\' stuff.
But try save yourself some trouble to use '/', that is a good habit.
(Seconded to #dickoa, I also suspect you actually meant '\' in the OP)

Running a Windows executable file from within R with command line options

I am trying to call a Windows program called AMDIS from within R using the call
system("C:/NIST08/AMDIS32/AMDIS_32.exe /S C:/Users/Ento/Documents/GCMS/test_cataglyphis_iberica/queens/CI23_Q_120828_01.CDF")
in order to carry out an analysis (specified using the /S switch) on a file called CI23_Q_120828_01.CDF, but it seems that no matter what I try the file is not loaded in correctly, presumably because the options are not passed along. Does anyone have a clue what I might be doing wrong?
Right now this command either
doesn't do anything,
makes AMDIS pop up, but it doesn't load the file I specify
gives me the error
Warning message:
running command 'C:/NIST08/AMDIS32/AMDIS_32.exe /S
C:/Users/Ento/Documents/GCMS/test_cataglyphis_iberica/queens/CI23_Q_120828_01.CDF'
had status 65535
(I have no idea what results in these different outcomes of the same command)
(the AMDIS command line options are described here at the page 8)
Cheers,
Tom
EDIT:
Found it had to do with forward vs backslashes - running
system("C:\\NIST08\\AMDIS32\\AMDIS_32.EXE C:\\Users\\Ento\\Documents\\GCMS\\test_cataglyphis_iberica\\queens\\CI23_Q_120828_01.CDF /S /E")
seems to work - thank you all for the suggestions!
You've heard of bquote , noquote , sQuote, dQuote , quote enquote and Quotes, well now meet shQuote!!! :-)
This little function call works to format a string to be passed to an operating system shell. Personally I find that I can get embroiled in backslash escaping hell, and shQuote saves me. Simply type the character string as you would on the command line of your choice ('sh' for Unix alikes like bash , csh for the C-shell and 'cmd' for the Windows shell ) wihtin shQuote and it will format it for a call from R using system:
shQuote("C:/NIST08/AMDIS32/AMDIS_32.exe /S C:/Users/Ento/Documents/GCMS/test_cataglyphis_iberica/queens/CI23_Q_120828_01.CDF" , type = "cmd" )
#[1] "\"C:/NIST08/AMDIS32/AMDIS_32.exe /S C:/Users/Ento/Documents/GCMS/test_cataglyphis_iberica/queens/CI23_Q_120828_01.CDF\""
More generally, you can use shQuote like this:
system( shQuote( "mystring" , type = c("cmd","sh") ) , ... )

Maths in LaTex table of contents

I am trying to add a table of contents for my LaTex document. The issue I am having is that this line:
\subsubsection{The expectation of \(X^2\)}
Causes an error in the file that contains the table of contents
\contentsline {subsubsection}{\numberline {1.2.3}
The expectation of \relax $X^2\relax \GenericError { }{
LaTeX Error: Bad math environment delimiter}{
See the LaTeX manual or LaTeX Companion for explanation.}
{Your command was ignored.\MessageBreak Type I <command> <return>
to replace it with another command,\MessageBreak or <return> to
continue without it.}}{5}
Which causes the document not to be generated.
Does anyone have a solution to having maths in sections while still having the table of contents
You should use the Amsmath inline math delimiter $ instead of \( and \). Thus:
\subsubsection{The expectation of $X^2$}
Note: be sure to remove the currently generated .toc file first, otherwise the error will not go away.
If you wish to continue using \(...\) as your math delimiters, you can load the (officially supported) fixltx2e package. This is where fixes to LaTeX go that cannot be integrated into the main sources because of the possibility of backwards compatibility problems.
(In short, your problem is that \( and \) by default aren't "robust" and hence can't be used in places like section headings and captions; the fixltx2e package fixes this.)
Could you try again with putting the $ signs around the expression? What error do you get?

Resources