Headers removed when importing phyloseq object for decontam

Just to follow up, I tried importing each of components separately (i.e. the feature table, tree, taxonomy and metadata) using Qiime2R read_qza and combining them into a phyloseq object as follows (based on the Qiime2R tutorial here):

phy2<-phyloseq( otu_table(Bam_asvs$data, taxa_are_rows = T), phy_tree(Bam_tree$data), tax_table(as.data.frame(gg_taxtable) %>% select(-Confidence) %>% column_to_rownames("Feature.ID") %>% as.matrix()), #moving the taxonomy to the way phyloseq wants it sample_data(metadata %>% as.data.frame() %>% column_to_rownames("#SampleID")) )

and the metadata headers seem to have been retained. Still not sure what went wrong with the initial command, though.