Strange behavior, which wasn’t happening when I used the QIIME2R prior, but I am having issues now. I have a merged file w/ 5 different runs. I merged these runs and filtered the file.
I then created a tree with MAFFT and then rooted it. So I have a “rooted_tree.qza” file. I then used the command from QIIME2R:
phy<-qza_to_phyloseq(“filtered.merge.table.qza”, “rooted-tree.qza”, “taxonomy.qza”,“MSQ.mouse.master.map.txt”)
This object looks like this:
phyloseq-class experiment-level object
otu_table() OTU Table: [ 12722 taxa and 903 samples ]
sample_data() Sample Data: [ 903 samples by 34 sample variables ]
tax_table() Taxonomy Table: [ 12722 taxa by 7 taxonomic ranks ]
phy_tree() Phylogenetic Tree: [ 12722 tips and 12548 internal nodes ]
I then give the column names ranks:
colnames(tax_table(phy))=c(“Domain”, “Phylum”, “Class”, “Order”, “Family”, “Genus”, “OTU”)
This file can create a PCOA that is rooted:
When I try to subset this file by piping via sample type (e.g., Lung).
Lung.phy.table = subset_samples(phy.relative.table, Sample %in% c(‘Lung’))
Then try to recreate the PCOA with experiment I get this error:
In matrix(tree$edge[order(tree$edge[, 1]), ][, 2], byrow = TRUE, :
data length  is not a sub-multiple or multiple of the number of rows 
This sounds like it’s an issue with the tree. I’ve googled this and it’s because the tree doesn’t match the input file.
Interestingly, it also has issues with Bray distance which shouldn’t be based on the tree. I"m wondering if there’s something to do with how the object is created from the QIIME2 import? Has anyone else had this issue? Ben
edit: Just to be clear, I think I know what the problem is: when I subset the data, what is happening is that the root of the tree is in a ASV which is filtered out with the rest of the subletting to Lung samples only. So, somehow, I need to re-root the tree within this subsetted phyloseq object.
This behavior is slightly troublesome, because I did this before with the objects and I never had a problem with QIIME2 and R, so I’m wondering if something changed now that there’s some compatibility issue.
edit edit: I am an idiot. I referred to another phyloseq object.