How to extract to columns from a phyloseq sample_data object?
Hi I have converted my data into phyloseq object for statistical analysis. From the sample_data object I want to select two specific columns which I will further combine with a distance matrix. But, I am unable to extract out those two columns. I am using these codes which is reversing the following error:
My code:
sd = as.matrix(sample_data(physeq))
sd = sd %>%
select("SampleID", "type") %>%
mutate_if(is.factor,as.character)
Error reversed:
Error in UseMethod("select_") :
no applicable method for 'select_' applied to an object of class "c('matrix', 'array', 'character')"
How should I do the step?
Thanks dpc
• 7,681 views
•
link
1 answer
Hi,
The problem is that pipes, as far as I know, only works with tibble data frames or data frames. Therefore you should coerce your sample metadata from phyloseq class into a data frame class, by doing:
sd = data.frame(sample_data(physeq))
I hope this solves your problem,
António
• 0 views
•
link
Log in to answer this question.
try.