joey711 / phyloseq

phyloseq is a set of classes, wrappers, and tools (in R) to make it easier to import, store, and analyze phylogenetic sequencing data; and to reproducibly share that data and analysis with others. See the phyloseq front page:
http://joey711.github.io/phyloseq/
586 stars 186 forks source link

merge_phyloseq deleting samples #1771

Open efgellerson opened 2 months ago

efgellerson commented 2 months ago

Hi there, I have run into a weird issue using phyloseq. I am working with two objects, ps1919 with 35 samples and ps1144 with 185 samples. When I merge the two, they are deleting 10 cases, since the new object (allps) has 210 samples instead of 220. Any ideas on this issue? I've checked the OTU tables for the samples that are being deleted, and they do have reads, so it's not like they're empty and deleting them. My code is below if that helps. Thanks!

ps1144 <- phyloseq(otu_table1144,sample_data(metadata1144), tax_table1144)
ps1919 <- phyloseq(otu_table1919,sample_data(metadata1919), tax_table1919)

dna <- Biostrings::DNAStringSet(taxa_names(ps1144))
names(dna) <- taxa_names(ps1144)
ps1144 <- merge_phyloseq(ps1144, dna)
taxa_names(ps1144) <- paste0("ASV", seq(ntaxa(ps1144)))
ps1144

dna <- Biostrings::DNAStringSet(taxa_names(ps1919))
names(dna) <- taxa_names(ps1919)
ps1919 <- merge_phyloseq(ps1919, dna)
taxa_names(ps1919) <- paste0("ASV", seq(ntaxa(ps1919)))
#after this point I check each of tables (metadata, OTU table, and taxa table, and the samples that are being deleted are all from ps1919, but they are in the tables with information)

allps <- merge_phyloseq(ps1144, ps1919)
#after merging here I do the same check and there are only 210 cases, and the 10 samples I'm trying to look at are gone! 
G-gnome commented 2 months ago

I think that maybe the sample names may not be overlapping 100% between the phyloseq objects. Maybe check that they are the same between the objects for those that are being dropped?

sample_names(ps1144) sample_names(ps1919)