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

merging two phyloseq objects is duplicating phyloseq objects #1734

Open lauraDRH opened 8 months ago

lauraDRH commented 8 months ago

Hi there!

I am having some trouble merging two phyloseq objects.

I have a ps that contains two types of samples: trees and bushes. Each of these categories have more than 2000 samples. My aim was to remove from only the tree samples, some specific OTUs but without removing them from the bush samples. For this I did the following:

  1. I separated my ps in two:

     trees <- subset_samples(ps1, type=="trees")
     bushes<- subset_samples(ps1, type=="bushes")
  2. I found those OTUs that I wanted to remove from trees and removed them.

  3. I merged both objects again, to create my new ps

ps2 <- merge_phyloseq(trees, bushes)

This seemed to worked completely fine, as those missing OTUs in trees were filled with 0 when I merged the objects. However, I notice that my original ps1 had a size of 2.4GB, and now my merged object ps2 has double the size 4.8GB. The number of samples, OTUs and taxa seems to be the same, so I do not know what has been doubled.

I think this is giving me problems to do further analysis, like ordinations.

I would appreciate any notes on this issue. Or maybe even if there is a different way to remove OTUs from only one type of samples.

cheers!! Laura