Open rogarcia1992 opened 4 years ago
Hi,
Could you share the error you get when you try to run the model.matrix command?
Kevin
Hi,
See error below:
x <- model.matrix(~ Sample_ID, data = FT_A_HIDF_DIDF@sam_data) Error in terms.formula(object, data = data) : 'data' argument is of the wrong type
You'll have to convertFT_A_HIDF_DIDF@sam_data
to a data frame before feeding it into the model.matrix()
function.
Hi,
Yes, I found a code that allows me to do that from a phyloseq object (see code below). The example data in the package (i.e. - Crohn) has the meta_data with covariates and otu_table merged or contained in the same obj. Is this the only way that it works or can I use a meta_data imported from excel to feed it to model.matrix() and then the otu_table obtained from a phyloseq obj for Y and Z? Thanks!
OTU1 = as(otu_table(physeq1), "matrix")
if(taxa_are_rows(physeq1)){OTU1 <- t(OTU1)}
OTUdf = as.data.frame(OTU1)
Hi,
I have a phyloseq object containing otu_table, sam_data, and tax_table. Is there a way I can use this phyloseq object for example in model.matrix? I tried the following:
x <- model.matrix(~Sample_ID, data = myphyloseq_obj@sam_data)
However, it did not work. Any advice on how to do this? In your paper I read you used a phyloseq object.
Thanks!