exporting q2 fragment insertion tree

Hi everyone,

I'm trying to use a multi fasta file with ASV sequences as header and sequence to generate a fragment insertion tree using sepp-refs-gg-13-8.qza. First, I import the representative sequences into QIIME 2 as an artifact and then run the qiime fragment-insertion sepp command. The command is working but when I look at the qza tree file on iTOL or when I import the tree as a nwk file into R the tip labels are numbers corresponding to the GG IDs and not the original headers in my fasta file. This is making it challenging to integrate the new tree into an existing phyloseq object. I understand that the new tree may not contain every ASV from the original table, this isn't the problem. The problem is understanding the correspondence between the tip labels on the new tree and the ASVs in the table.

Any tips to produce a fragment insertion tree that retains the original ASV labels would be super helpful.

Thanks!
Connor

Hi @Connor_Fitzpatrick, welcome to :qiime2: !

This is quite similar to this thread

In brief you can run qiime phylogeny filter-tree ..., to remove all tips that are not represented as features in your feature table.

I'd also highly recommend q2-empress for viewing your tree. In fact, check out this YouTube video, specifically at time point 9:20, that provides a simple tutorial on empress.

-Mike

1 Like

Hi Mike,

Thanks for the response! Yes, this issue has come up a couple of times on the forum but I never found the answer I was looking for.

So my issue isn't pruning unwanted tips from the tree, the tutorial provides a nice example of this using qiime fragment-insertion filter-features. My plan was to do this in R by pruning all tips that do not match an ASV sequence in the original table. However, I can't do this because none of the tip labels match any of my ASV sequences and I think this is because the original name of the inserted fragment is not retained in the insertion tree? Is this correct? Even when I run the tutorial commands found here the output tree does not have any of the names from the representative sequence file. I guess there is some backend way that qiime fragment-insertion filter-features gets around this and I could just use this functionality but ultimately I do need a tree that has tip labels that match the original ASV labels.

Thanks,
Connor

1 Like

Note the qiime fragment-insertion filter-features ... command removes ASVs from the table that did not insert into the tree. But it'd be possible that the tree may have tips (sequence / SILVA / GreenGenes IDs) that are not in the table.

Removing unwanted tips from the tree using the qiime phylogeny filter-tree ... command is the same thing as pruning all the tips that do not match the ASVs in the original table.

This shouldn't be. In fact, below is a screen shot (using empress) of a SEPP tree I produced using the SILVA reference from here. You can see my ASV sequence:

I'd be happy to look at your SEPP input / output files, via DM.

-Mike

1 Like

Mike, thanks for your continued help on this. I repeated my attempts using the SILVA reference and it worked fine. The command with the GG reference was producing trees with far fewer tips than expected (i.e. the reference tree wasn't even properly constructed and output) and I couldn't get it to work even with the ref-seqs.qza file from the tutorial website.

So if anyone else has trouble perhaps try the SILVA reference instead of the GG reference as listed in the tutorial. By the way, importing the resultant newick tree into R and then pruning to include only inserted fragments from a vector of ASV labels was simple in case anyone is trying to do this (courtesy of Liam Revell Phylogenetic Tools for Comparative Biology: Prune tree to a list of taxa):

assuming ASV labels is in "seq.names" vector

tree<-phytools::read.newick("~/tree.nwk")
pruned.tree<-drop.tip(tree, tree$tip.label[-na.omit(match(seq.names, tree$tip.label))])