PROBLEM SOLVED
______________________________
for (i in 1:n){
current_seq <- readAAStringSet(myFiles[i])
permutation <- order(names(current_seq )
current_align <- msa(current_seq[permutation],order="input")
#I prefer to make tex file first
msaPrettyPrint(current_align, output="tex", askForOverwrite=FALSE, verbose=FALSE,
file = tex_file_1, alFile = fasta_file_1,
code=tex_code)
#compile tex file
texi2pdf(tex_file_1, clean=TRUE)
#move outputs files
file.rename(from = fasta_file_1, to = fasta_file_2)
file.rename(from = tex_file_1, to = tex_file_2)
file.rename(from = pdf_file_1, to = pdf_file_2
}
#This code need to be insert in the loop
#Tex_mis take basics customisations (logo consensus etc..)
#Put all basics stuff here
tex_misc = "\\shadingmode{identical}
\\threshold{50}
\\shadingcolors{blues}
\\showsequencelogo[chemical]{top}
\\hidelogoscale
\\shownumbering{right}
\\\showconsensus{}
\\showlegend"
tex_misc = unlist(strsplit(tex_misc, split="\n"))
tex_code = c(tex_misc)
#Put the full name for each sequences
for (i in 1:33){
ind = permutation[i]
print(names(current_seq[ind]))
new_name = gsub(pattern = "_", replacement = "-",names(current_seq[ind]))
tex_code = c(tex_code,paste("\\nameseq{",i,"}{",new_name,"}",sep =""))
}
________________________________________________________
Good things to know:
https://github.com/Bioconductor-mirror/msa/blob/master/R/msaPrettyPrint.R for helping retreving default customisations (logo, colors, consensus).
You can also use msaPrettyPrint() with only its own arguments (without changing the code), looks at the tex file to find how the basics stuff are written in tex file and copy/paste them in tex_misc in here (that's how I did)
LaTeX doesnt handle every character in sequence name. Any issues may be due to a wrong char in one sequence name.
/!\ for adding several LINES in tex code, the code arguments in msaPrettyPrint() need to have a list ( eg custom_tex_code = c(), where each elements in the list/vector will be a line in the tex file
The code shown above isnt ready to direct use. I use msaPrettyPrint() in a loop because i have several multifasta file to align seperately.
I can answer questions if you have some issues. Now i'm good in this awesome function.
Awesome, Olorin! May I add a few more bits:
msaPrettyPrint()
function. See '?msaPrettyPrint
' for details.I saw right. you can see msaPrettyPrint help. If you add code arguments, it overrides all other arguments:
- Ty for the links
That is true, '
code
' overrides everything else. However, if you just want to add some customizations on top of whatmsaPrettyPrint()
configures by itself, you can use the 'furtherCode
' argument which only adds TeX code without overriding the rest.Good to know. thank you