YuLab-SMU/ggmsa

Error in if (freq > 0.9) { : missing value where TRUE/FALSE needed

Closed this issue · 4 comments

Hi all,

I want to create a graph combing the phylogenetic tree, fasta sequence, and some phenotypic traits.
When I first tried msaplot() to align the fasta sequence with the tree., there is no issue. Now I use ggmsa to align the tree with corresponding fasta file, it generates the following error message:
"Error in if (freq > 0.9) { : missing value where TRUE/FALSE needed"

Here is my r code:

tre <- read.tree("/Users/dklabuser/limin/data_analysis/pan-genome/genomic_comparison/pTi_roary_output/accessory_binary_genes.fa.newick")
n <- MRCA(tre, c("Tul003", "Teh002"))
tre <- root(tre,node = n)

p <- ggtree(tre, layout = "rectangular") +
  geom_tiplab(size=1.5) 

# rotate the tree for T-DNA right border alignment.
p <- flip(p, 6, 34) %>% flip(19,32)

nt_sequence <- system.file("extdata","/Users/dklabuser/limin/Dissertation_papers/dissertation/chapter4_genetic_diversity/RB_aln.fasta", package = "ggmsa")

ggmsa(nt_sequence,1,24,char_width = 0.5, color = "Chemistry_AA", seq_name = TRUE, use_dot = TRUE)

Here is the error message of the previous code:

Screen Shot 2021-02-19 at 1 39 35 PM

Does anyone know what goes wrong with my codes? and how to solve this issue
Your help is greatly appreciated!

Best,
Limin

Hi, Limin

The input FASTA file dispenses with the need for system.file() function.

nt_sequence <- system.file("extdata","/Users/dklabuser/limin/Dissertation_papers/dissertation/chapter4_genetic_diversity/RB_aln.fasta", package = "ggmsa")

just specify the path directly, like this:
nt_sequence <- "/Users/dklabuser/limin/Dissertation_papers/dissertation/chapter4_genetic_diversity/RB_aln.fasta"

Best,
Lang

Hi, Limin

The input FASTA file dispenses with the need for system.file() function.

nt_sequence <- system.file("extdata","/Users/dklabuser/limin/Dissertation_papers/dissertation/chapter4_genetic_diversity/RB_aln.fasta", package = "ggmsa")

just specify the path directly, like this:
nt_sequence <- "/Users/dklabuser/limin/Dissertation_papers/dissertation/chapter4_genetic_diversity/RB_aln.fasta"

Best,
Lang

Hi, Lang,

Thank you so much! It works now. I actually follow the codes in the tutorial here https://github.com/YuLab-SMU/ggmsa

Now I want to graph the alignment with the tree, there is an error again, I follow the tutorial codes,

# to combine the above two trees into one
nt_sequence <- "/Users/dklabuser/limin/Dissertation_papers/dissertation/chapter4_genetic_diversity/RB_aln.fasta"

x <- readDNAStringSet(nt_sequence)
data1 = tidy_msa(nt_sequence)
p1 + geom_facet(geom = geom_msa, data = data1, panel = "msa", font = Null, color = "Chemistry_AA") +
  xlim_tree(1)

And there is an error again,
Screen Shot 2021-02-19 at 8 08 02 PM

Any suggestion on what may cause this error?

Thank you so much!
Best,
Limin

p1 + geom_facet(geom = geom_msa, data = data1, panel = "msa", font = Null, color = "Chemistry_AA") + xlim_tree(1)

Null is illegal in R, pls using NULL instead of it.
Besides,we recommend the NT color scheme (color = "Chemistry_NT") when the input is DNA alignment.

p1 + geom_facet(geom = geom_msa, data = data1, panel = "msa", font = Null, color = "Chemistry_AA") + xlim_tree(1)

Null is illegal in R, pls using NULL instead of it.
Besides,we recommend the NT color scheme (color = "Chemistry_NT") when the input is DNA alignment.

Hi Lang,

Thank you so much. Everything works now. The graph is so beautiful!

Best,
Limin