ChiLiubio / microeco

An R package for data analysis in microbial community ecology
GNU General Public License v3.0
181 stars 55 forks source link

Error: Input colors are not enough to use #293

Closed bingheer closed 5 months ago

bingheer commented 7 months ago

Hi! Thanks for your resource, I benefit greatly from your contribution. I am in trouble when I draw figures using “plot_bar, plot_box, polt_donut, plot_line, plot_pie, plot_radar“, and I always get an error as is showed in the figure below. When drawing the first 10 OUTs, the color is not enough and the picture label is missing. Is there any method to solve this problem?

Best regards! question1 question

ChiLiubio commented 7 months ago

Could you please provide a complete step to let us reproduce your issue, including the code, data and your pckages version? To save the data, please follow the steps in the tutorial (https://chiliubio.github.io/microeco_tutorial/notes.html#save-function) and attach the compressed object.

bingheer commented 7 months ago

------------------ 原始邮件 ------------------ 发件人: "ChiLiubio/microeco" @.>; 发送时间: 2023年11月26日(星期天) 下午3:57 @.>; @.**@.>; 主题: Re: [ChiLiubio/microeco] Error: Input colors are not enough to use (Issue #293)

Sorry. I cannot open the picture with some unknown reasons. Could you please provide a complete step to let us to reproduce your issue, including the code, data and your pckages version?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

bingheer commented 7 months ago

------------------ 原始邮件 ------------------ 发件人: "ChiLiubio/microeco" @.>; 发送时间: 2023年11月26日(星期天) 下午3:57 @.>; @.**@.>; 主题: Re: [ChiLiubio/microeco] Error: Input colors are not enough to use (Issue #293) Sorry. I cannot open the picture with some unknown reasons. Could you please provide a complete step to let us to reproduce your issue, including the code, data and your pckages version? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

We use R 4.1.0 to do this work. The code and data are attached to the upload. code_and_data.zip

ChiLiubio commented 7 months ago

Hi. If you run unique(dataset$tax_table$Phylum), you can find there is a "" in the result. The solution is to use tidy_taxonomy function as we show in the tutorial (https://chiliubio.github.io/microeco_tutorial/other-examples-1.html#tidy_taxonomy-function). The following is the full steps.


library(microeco)
library(ggplot2)
library(magrittr)

dataset$tax_table %<>% tidy_taxonomy
dataset$cal_abund()

t1 <- trans_abund$new(dataset = dataset, taxrank = "Phylum", ntaxa = 10)
t1$plot_bar(others_color = "grey70", facet = "Group", xtext_keep = FALSE, legend_text_italic = FALSE)

The message of colors means you select 10 taxa, but default color_values parameter has only 8. To complete the plot, the function automatically add the colors.

bingheer commented 7 months ago

Thanks for the quick reply!

It's very useful to use tidy_taxonomy() to clean taxonomy table and make a uniform taxonomy information. Then solve this problem.

Thank you very much.