ChiLiubio / microeco

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

Error in plot_diff_cladogram #258

Closed StanleyDeng27 closed 6 months ago

StanleyDeng27 commented 1 year ago

hi! i try to use the function plot_diff_cladogram, and i just follow the microeco tutorial, and the location is Chapter 6 Model-based class.I can execute LEfSe normally, the figure of LDA score and relative abundance is normal. But when i try to show the cladogram of the differential features in the taxonomic tree, as the following code: lefse is my project, and the group is 1 and 2. I can't get the graphics right. And the warnings are long and repetitive, so I've kept only part of them. In the sample_table, I converted the group column into a factor form, but the problem still cannot be solved. This problem has troubled me for a long time, I don't know how to solve it, if I can get your help, I will be very grateful!

lefse$plot_diff_cladogram(use_taxa_num = 200, use_feature_num = 50, clade_label_level = 5, group_order = c("1","2")) Select 50 significant features ... Select 200 most abundant taxa as the background cladogram ... Warning: Ignoring unknown parameters: levelWarning: Ignoring unknown parameters: levelWarning: Ignoring unknown parameters: levelWarning: Ignoring unknown parameters: levelWarning: Ignoring unknown parameters: levelWarning: Ignoring unknown parameters: levelWarning: Ignoring unknown parameters: levelWarning: Ignoring unknown parameters: levelWarning: Ignoring unknown parameters: level

StanleyDeng27 commented 1 year ago

I tried the solution you provided to other users, I don't know if it is the same as mine, but it still doesn't solve the problem dataset$tax_table %<>% tidy_taxonomy dataset$cal_abund()

l1 <- trans_diff$new( dataset = dataset, method = "lefse", group = "group", taxa_level = "all", alpha = 0.01, p_adjust_method = "fdr", lefse_norm = 1000000, nresam = 0.6667, boots = 100, )

clad <- l1$plot_diff_cladogram( filter_taxa = 0.0001, use_taxa_num = 200, use_feature_num = 50, clade_label_level = 5, only_select_show = FALSE, group_order =NULL, node_size_offset = 1.5, annotation_shape = 21, annotation_shape_size = 4.5, clade_label_size =1, alpha = 0.2 ) Select 50 significant features ... Select 200 most abundant taxa as the background cladogram ... Warning: Ignoring unknown parameters: levelWarning: Ignoring unknown parameters: levelWarning: Ignoring unknown parameters: levelWarning: Ignoring unknown parameters: levelWarning: Ignoring unknown parameters: levelWarning: Ignoring unknown parameters: levelWarning: Ignoring unknown parameters: levelWarning: Ignoring unknown parameters: level

ChiLiubio commented 1 year ago

Hi. Could you please attach your data and the scripts so that I can reproduce your result? Please save your microtable object following the tutorial (https://chiliubio.github.io/microeco_tutorial/notes.html#save-function) and provide your lefse steps, i.e. steps from trans_diff part. Please also provide your microeco version. It is important. Thanks.

StanleyDeng27 commented 1 year ago

dataset.zip version:microeco_0.20.0

load("./dataset.RData") lefse <- trans_diff$new(dataset = dataset, method = "lefse", group = "group", alpha = 0.05, lefse_subgroup = NULL, p_adjust_method = "none")

lefse$plot_diff_bar(use_number = 1:40, width = 0.8, group_order = c("1", "2"))

lefse$plot_diff_cladogram(use_taxa_num = 200, use_feature_num = 50, clade_label_level = 5, group_order = c("1","2")) #this step is problematic

ChiLiubio commented 1 year ago

Hi. Please first adjust use_taxa_num parameter to 150 and try again.

g1 <- lefse$plot_diff_cladogram(use_taxa_num = 150, use_feature_num = 50, clade_label_level = 5, group_order = c("1","2"))
ggplot2::ggsave("test.pdf", g1, width = 14, height= 10)

It is a bug. The total effective taxa (without unidentified) number is less than 200 in your dataset. The program lack a checking step, leading to NA and chaos in the running. Please temporarily ingore the warinings as they comes from the inner function of dependent ggtree package. Thanks very much for your finding!

Best, Chi

StanleyDeng27 commented 1 year ago

hi! It did work! I re-analyzed it using your code and was indeed able to solve my problem. Thank you so much for your help!

Best, Deng