tree <- ape::read.tree(text ="((t1:1,t2:1)N2:1,(t3:1,t4:1)N3:1)N1;")
com <- Matrix::sparseMatrix(c(1,3,4,1,4,5,1,2,3,4,5,6,3,4,6),
c(1,1,1,2,2,2,3,3,3,3,3,3,4,4,4),x=1,
dimnames = list(paste0("g", 1:6), tree$tip.label))
unifrac(com, tree)
Run the code above in your browser using DataLab