Closed WangWaud closed 2 months ago
Hi. Could you please provide an example that I can reproduce? The example should also show the issue that two figures of two different data have the same results. If you need to attach your dataset, please follow the tutorial (https://chiliubio.github.io/microeco_tutorial/notes.html#save-function). The microtable object (dataset) is enough for the example, please donot provide the txt/tsv files.
As you can see, the Chao1 and Observed index of the same samples are the same.
library(microeco)
library(magrittr)
library(ggplot2)
library(phyloseq)
library(ggsci)
library(dplyr)
library(ggsignif)
load("example.RData")
dataset_filtered$cal_abund()
dataset_filtered$tidy_dataset()
dataset_filtered$tax_table[dataset_filtered$tax_table == ""] <- "unassigned"
t1 <- trans_abund$new(dataset = dataset_filtered, taxrank = "Phylum", ntaxa = 10, groupmean = "Group")
# α多样性 --------------------------------------------------------------------
t1 <- trans_alpha$new(dataset = dataset_filtered, group = "Group")
t1$cal_diff(method = "anova",p_adjust_method = "fdr")
t1$res_diff
# 手动绘制α多样性 ----------------------------------------------------------------
ggplot(data=t1$data_alpha[t1$data_alpha$Measure=="Chao1",],
aes(x=Group,y=Value,fill=Group))+
geom_boxplot(outlier.color = "#D55740", outlier.shape = 1) +
geom_jitter(alpha = 0.7) +
theme_classic() +
geom_signif(comparisons = list(c("BEC","BEI"),
c("MEC","MEI")),
test = t.test, map_signif_level=T)+
scale_fill_npg() +
labs(x = NULL, y = "Chao1") +
theme(axis.title = element_text(size = 16),
axis.text = element_text(color = "black", size = 16),
axis.text.y = element_text(size = 14),
legend.text = element_text(color = "black", size = 9),
strip.text = element_text(size = 14),
legend.title = element_text(size = 12),
legend.background = element_rect(fill = NA))
ggsave("Chao1.PDF", width = 8, height = 6, dpi = 300)
ggplot(data=t1$data_alpha[t1$data_alpha$Measure=="Observed",],
aes(x=Group,y=Value,fill=Group))+
geom_boxplot(outlier.color = "#D55740", outlier.shape = 1) +
geom_jitter(alpha = 0.7) +
theme_classic() +
geom_signif(comparisons = list(c("BEC","BEI"),
c("MEC","MEI")),
test = t.test, map_signif_level=T)+
scale_fill_npg() +
labs(x = NULL, y = "Chao1") +
theme(axis.title = element_text(size = 16),
axis.text = element_text(color = "black", size = 16),
axis.text.y = element_text(size = 14),
legend.text = element_text(color = "black", size = 9),
strip.text = element_text(size = 14),
legend.title = element_text(size = 12),
legend.background = element_rect(fill = NA))
ggsave("Chao1.PDF", width = 8, height = 6, dpi = 300)
The dataset was updated. By running the code that I uploaded, you may repeat my problem. Thanks! example.RData.zip
Hi. To verify the result, please run the following steps. We can find it is same with the results of vegan package. The reason that obs and chao1 have very similar results is the rare taxa are very low in your data. For example, sum(dataset_filtered$otu_table[, 1] == 1)
shows 0 feature with abundance 1. Chao1 index highly depends on the rare taxa (1 and 2), which is nessary to estimate the possible species number.
library(microeco)
library(magrittr)
load("example.RData")
dataset_filtered$cal_abund()
dataset_filtered$cal_alphadiv()
View(dataset_filtered$alpha_diversity)
tmp <- vegan::estimateR(t(dataset_filtered$otu_table))
View(tmp)
I got it. Thanks very much!
Hi, there! These days I'm trying to visualize the α diversity of different microbiome data, the problem is whatever the data is, the Chao1 index and observed index were always the same, and thus the figures were the same. I'm wondering whether it is abnormal or not and why. The code is as follows:
If you need more information, plz let me know. Thanks! Looking forward to your reply.