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 cladogram #232

Closed Muneer111 closed 6 months ago

Muneer111 commented 1 year ago

Dear Chi Liu I am trying to run a code t1$plot_diff_cladogram(use_taxa_num = 200, use_feature_num = 50, clade_label_level = 5, group_order = c("IC", "MC")). I am getting an error: Error: attempt to apply non-function Kindly suggest.

ChiLiubio commented 1 year ago

Hi. The error says no such function in t1. I am not sure how it happened. Please also add the steps that show how t1 is created. Thanks.

Muneer111 commented 1 year ago

Sorry to mention here, I left this error aside for now. My queries are long and I have posted them all for your convenience As I got engaged in my data analysis, for analysis the relation between Microbial groups and environmental variables. For that I have got the data file ( env_data; file attached) env_data.csv. Now after successfully running the cote up to: dataset$tidy_datset() I started running the codes from trans_env class and ran the first code like : t1 <- trans_env$new(dataset = dataset, add_data = env_data[, 1:4]) It ran successfully and gave the message The result is stored in object$res_diff ... Then I ran the code head(t1$res_diff) It showed the data results but only of Dehydrogenase activity and leaving other environmental variables like organic_carbon, Soil chlorophyll and Total Polysaccharides. Then again I ran this code : tmp <- list() followed by this code tmp[[i]] <- t1$plot_diff(measure = i, add_sig_text_size = 5, xtext_size = 12) + theme(plot.margin = unit(c(0.1, 0, 0, 1))) and it generated the error: Error in measure %in% self$data_alpha$Measure : object 'i' not found kindly mention here what to do? Thanks and Regards

ChiLiubio commented 1 year ago

Hi. Is your goal is to plot all the variables together like the example in the tutorial? If so, please use for cycle like the tutorial shows. If you just need to plot one variable, please donot use list. Just to plot it like this.

t1$plot_diff(measure = "organic_carbon", add_sig_text_size = 5, xtext_size = 12)
Muneer111 commented 1 year ago

Thank you Liu I did it. But for moving forward I am encountering some new errors. While running these codes, t1$cal_diff(method = "anova", group = "Group") tmp <- list() for(i in colnames(t1$data_env)){ tmp[[i]] <- t1$plot_diff(measure = i, add_sig_text_size = 5, xtext_size = 12) + theme(plot.margin = unit(c(0.1, 0, 0, 1), "cm")) } Error : Error in theme(plot.margin = unit(c(0.1, 0, 0, 1), "cm")) : could not find function "theme Error in unit(rep(1, nrow), "null") : 'x' and 'units' must have length > 0 I think the error is due to package is missing. I changed the version to 4.2 but again the same error then I updated the version to 4.3 and again the same version. What version is best suited for microeco package. or guide me to overcome this error. Thanks and Best Regards.

ChiLiubio commented 1 year ago

Please load the ggplot2 package: library(ggplot2) before running this.