microeco
microeco copied to clipboard
plot alpha error
Hi, i try to plot the alpha diversity by_group and found problem with significant code.
Please check the following code.
#calculate and plot the alpha diversity t_country <- trans_alpha$new(dataset = dataset2, group = "Country", by_group = "Host_taxa") t_country$cal_diff(method = "wilcox") t_country$plot_alpha(measure = "Chao1") t_country$plot_alpha(measure = "Shannon")
Hi. Could you please send me your dataset2
to check it? Please use save
function to save the data (https://chiliubio.github.io/microeco_tutorial/notes.html#save-function). I am not sure how it hapened now.
dataset.rdata.zip https://drive.google.com/file/d/1QI_OcO4Q8TtJXMrQaSEiVhutseYKfaW3/view?usp=drive_web
pls find the dataset attached!
On Thu, Feb 2, 2023 at 3:48 AM Chi Liu @.***> wrote:
Hi. Could you please send me your dataset2 to check it? Please use save function to save the data ( https://chiliubio.github.io/microeco_tutorial/notes.html#save-function). I am not sure how it hapened now.
— Reply to this email directly, view it on GitHub https://github.com/ChiLiubio/microeco/issues/177#issuecomment-1413033699, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMC3WZUFZGS274HHSDRDJ4TWVMG5LANCNFSM6AAAAAAUMIXVYE . You are receiving this because you authored the thread.Message ID: @.***>
Please drag the data in the Github issue page. I can not open the upper link via the email.
Thanks, check the following link, https://drive.google.com/file/d/1QI_OcO4Q8TtJXMrQaSEiVhutseYKfaW3/view?usp=drive_web
It can not be opened for me. Please directly send the data to my email ([email protected]). Thanks.
Hi. I found the weird result comes from the incorrect factor assignment in the 'Host_taxa ' of sample_table. If you print dataset2$sample_table$Host_taxa
, you can find there are 5 factors, not 4. Removing the factors can solve this issue.
library(magrittr)
dataset2$sample_table$Host_taxa %<>% as.character
t_country <- trans_alpha$new(dataset = dataset2, group = "Country", by_group = "Host_taxa")
t_country$cal_diff(method = "wilcox")
t_country$plot_alpha(measure = "Chao1")
Thanks, it worked. It seems that when I do the subset, a factor still remains even after tidying the dataset.
On Tue, Feb 7, 2023 at 10:56 AM Chi Liu @.***> wrote:
Hi. I found the weird result comes from the incorrect factor assignment in the 'Host_taxa ' of sample_table. If you print dataset2$sample_table$Host_taxa, you can find there are 5 factors, not 4. Removing the factors can solve this issue.
library(magrittr) dataset2$sample_table$Host_taxa %<>% as.character t_country <- trans_alpha$new(dataset = dataset2, group = "Country", by_group = "Host_taxa") t_country$cal_diff(method = "wilcox") t_country$plot_alpha(measure = "Chao1")
— Reply to this email directly, view it on GitHub https://github.com/ChiLiubio/microeco/issues/177#issuecomment-1420413470, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMC3WZTZ4UQ5PKKVA74U5XTWWIE43ANCNFSM6AAAAAAUMIXVYE . You are receiving this because you authored the thread.Message ID: @.***>
dataset <- mpa2meco("buglist_clean.tsv", sample_table =metadata1) test <- dataset$merge_taxa(taxa = "Genus") test$cal_alphadiv(PD = FALSE) t2 <- trans_alpha$new(dataset = test, group = "group",by_group="time") t2$cal_diff(method = "wilcox") I also check the "group" and "time" as.character but Error in wilcox.test.formula(formu, data = table_compare, ...) : grouping factor must have exactly 2 levels KW_genus_leveL_TIME.pdf
Hi.
Could you please attach your dataset
or test
object so that I can reproduce your issue? To save it, please follow the steps in the tutorial (https://chiliubio.github.io/microeco_tutorial/notes.html#save-function) and attach the compressed object.
test_data.zip Thank you!
Hi @milyzhou ,
I found the reason is there is NaN in "ACE" index in the alpha diversity table, i.e. test$alpha_diversity
. The temporary solution is to filter ACE or directly use Shannon metric.
test <- dataset$merge_taxa(taxa = "Genus")
test$cal_alphadiv(PD = FALSE)
test$alpha_diversity %<>% .[, !grepl("ACE", colnames(.))]
t2 <- trans_alpha$new(dataset = test, group = "group",by_group="time")
t2$cal_diff(method = "wilcox")
or
test <- dataset$merge_taxa(taxa = "Genus")
test$cal_alphadiv(PD = FALSE)
t2 <- trans_alpha$new(dataset = test, group = "group",by_group="time")
t2$cal_diff(method = "wilcox", measure = "Shannon")
I will add a filtering step in the trans_alpha class in the next version to delete the index with NaN. Thanks!
Best, Chi
Thanks! It work!Thank you again!