Qiime2R-Sorting data in Rstudio


(Fabiola ) #1

Hi, I have looked through the forum and did not see an answer to my question and to be honest, I am unsure if this is even the proper forum for my question.

I imported my alpha diversity metrics to Rstudio using Qiime2R, but I am having a problem figuring out how to sort the x-axis so that the data is in the order I need them to be (for boxplots). Since this file does not show like a normal excel sheet where I can sort using regular R codes, I wanted to see if you guys had come upon this problem and or have an idea where I can ask such questions.

This is what my graph looks like but I need to flip the first 2 boxplots (site=represents a specific fire year), please let me know if you have any ideas and or If I need to re-run the core-metrics and relabel my metadata so that it shows in the correct order.


(Fabiola ) #2

Hi Nicholas,

I am so sorry, I just found one of your topics on something slightly similar and I realized that the .qza files all run based on the metadata so I went ahead and changed the names and It worked, but if you have a better suggestion please let me know.


#3

Hi,

I am not sure your whether plot was created with ggplot2::ggplot() or base::plot(), anyway, you can change x-axis order by changing factor levels.

Suppose x-axis labels are in dataframe’s “group” column (df$group),

df$group <- factor(df$group, levels = c("NS-B", "Carl-B", "Tb Mt-B", "Tri-B"))

I hope this will help.

Best,
Hiro


(system) closed #4

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