Skip to content

How do you set factors in the mStat object? #14

Answered by cafferychen777
RachBioHaz asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @RachBioHaz ,

Thank you for reaching out. It seems that you want to retain or set up factors in a specific order in the MicrobiomeStat object after importing from a phyloseq object. Here's how you can achieve this:

  1. After converting your phyloseq object to a MicrobiomeStat object using mStat_convert_phyloseq_to_data_obj, you'll get an object similar to peerj32.obj.
  2. To set up factors in the order you need, you can use the following code:
# Assuming 'sex' is the metadata column you want to set as a factor in a specific order
peerj32.obj$meta.dat$sex <- factor(as.factor(peerj32.obj$meta.dat$sex), levels = c("male", "female"))
  1. To check the order and the data:
print(peerj32.obj$meta.dat$sex

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@RachBioHaz
Comment options

Answer selected by cafferychen777
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants