Removing samples from phyloseq otu_table

I am trying to remove samples from my otu_table in a phyloseq object ps . This is so I can match the samples in my sample_data (which does not have the samples stated below as I removed them due to NAs). I'm using this:

to_remove <- c("Sample1", "Sample5", "Sample10", "Sample30")

# using z first to see if it works 
z <- prune_samples(ps@otu_table, !(sample_names() %in% to_remove))

but I get an error:

# Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘prune_samples’ for signature ‘"otu_table", "logical"’

How do I fix this?

Hi,

Looking at the documentation, it seems your have flipped the arguments in prune_samples. The first one should be the samples to keep or remove, the second one the ps object
https://www.rdocumentation.org/packages/phyloseq/versions/1.16.2/topics/prune_samples

Hope this helps,
PJ

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.