Indeed. I’ve built a tree from all representative (unique) sequences, the problem is still that each tip in the tree can correspond to multiple groups.
Or am I totally off here. Do I use the wrong fasta to build the tree from in the first place?
Do you have a names file associated with this data? The names file is a record of which sequences are represented by the unique sequence in your fasta file. For example, if you have fasta file
>Seq_1
AAAA
>Seq_4
ATAT
Then a names file could record that Seq_1 is also representative of Seq_2 and Seq_3. Your groups file would then record that Seq_1 was in Group A, Seq_2 in Group B and Seq_3 in Group C.
This is also the function of the count table, to more succinctly summarise the names/groups data.
I’m not sure I understand the problem and without knowing how to do it in mother, but:
if you have a tree where each representative sequence corresponds to one tip, it is (almost) always the case that the same sequences are found in different samples. Otherwise each sample would have a complete unique OTU composition. AFAIK, uni-frac explicitly quantifies the fraction of shared (uni) branch length, and weighted unifrac simply weights the branches by the abundance of the OTU at the corresponding tips.
In R, you can compute the unifrac distance easily with the phyloseq package (Picante has it too but not weighted and much slower):
example
OTU: your OTU table
ID: Your metadata table with sample names as rownames, corresponding to sample names in OTU table
TREE: your phylogenetic tree, with tip labels corresponding to OTU names in OTU table