microeco
microeco copied to clipboard
ploting specific taxa
Hi! This question is very basic, but I can't seem to understand it; I just want to see the distribution of a specific group using graphs. For example, Verrucomicrobia in the toy data set, but I always get an error. Is there any method in microeco to simply visualize the distribution of relat abund of a single OTU or taxa across treatment? Thank you!
dataset
dataset # 404 original sequences dataset_subset <-clone(dataset)
###dataset_subset dataset_subset$tax_table %<>% base::subset(Phylum == "p__Verrucomicrobia") dataset_subset$tidy_dataset()
check
dataset_subset # OK head(dataset_subset$tax_table) # OK only Verrucomicrobia
recalculate abundances (needed?)
dataset_subset$cal_abund() dataset_subset$taxa_abund # seems OK, only Verrucomicrobia, several Classes
plot:
t1 <- trans_abund$new(dataset = dataset_subset, taxrank = "Class", ntaxa = 2)
Error (although I see several classes...)
Error in if (ntaxa_use > sum(mean_abund > show)) { : missing value where TRUE/FALSE needed
Hi. The steps seem to be fine. So I may need your data to reproduce it. Could you please attach your data so that I can reproduce your issue? To save the "dataset", please follow the steps in the tutorial (https://chiliubio.github.io/microeco_tutorial/notes.html#save-function) and attach the compressed object.
Hello thanks! I am using microeco tutorial data, to help you find the problem:
rm(list = ls()) library(microeco) packageVersion("microeco") # 0.20.0
dataset # 404 original sequences dataset_subset <-clone(dataset)
dataset_subset$tax_table %<>% base::subset(Phylum == "p__Verrucomicrobia") dataset_subset$tidy_dataset()
dataset_subset # OK, 14 sequences head(dataset_subset$tax_table) # OK only Verrucomicrobia
dataset_subset$cal_abund() dataset_subset$taxa_abund # seems OK, only Verrucomicrobia, several Classes
t1 <- trans_abund$new(dataset = dataset_subset, taxrank = "Class", ntaxa = 2)
-> Error in if (ntaxa_use > sum(mean_abund > show)) { : missing value where TRUE/FALSE needed
Hi. I find that the reason is surprising NaN in sample 'S113' in each table of taxa_abund
. It comes from all the 0 abundance of each feature for this sample. Actually tidy_dataset function can filter the sample with 0 abundance, but it failed for this. I will fix it. To temporally solve it, you can run dataset_subset$tidy_dataset()
with double times.
rm(list = ls())
library(microeco)
library(magrittr)
packageVersion("microeco") # 0.20.0
dataset # 404 original sequences
dataset_subset <-clone(dataset)
dataset_subset$tax_table %<>% base::subset(Phylum == "p__Verrucomicrobia")
dataset_subset$tidy_dataset()
dataset_subset$tidy_dataset()
dataset_subset # OK, 14 sequences
head(dataset_subset$tax_table) # OK only Verrucomicrobia
dataset_subset$cal_abund()
dataset_subset$taxa_abund # seems OK, only Verrucomicrobia, several Classes
t1 <- trans_abund$new(dataset = dataset_subset, taxrank = "Class", ntaxa = 2)
Thanks for your intresting finding!
Best, Chi
Hi. I have fixed this bug in github. I plan to release the next version of microeco v1.2.1 in the coming several days.
Thank you very much for arranging this; it's very useful. I have an additional question. What if we need to see the percentage abundance relative to the total of the data (not just the numbers of reads left in the subset). For this, we could calculate the abundances before creating the subset. In this example, everything goes well up until the plot, where, strangely, it doesn't use the data from the subset_dataset but from the original dataset instead:
dataset_subset <-clone(dataset)
calculate abundances here
dataset_subset$cal_abund()
###dataset_subset dataset_subset$tax_table %<>% base::subset(Phylum == "p__Verrucomicrobia") dataset_subset$tax_table # OK
dataset_subset$tidy_dataset() dataset_subset$tidy_dataset()
###check dataset_subset # OK head(dataset_subset$tax_table) # OK only Verrucomicrobia
###plot: t2 <- trans_abund$new(dataset = dataset_subset, taxrank = "Class", ntaxa = 3) t2$plot_box(group = "Group", xtext_angle = 30) # I see other phyla...why?
Hi. The design of tidy_dataset
does not change the features in taxa_abund
list. It first manipulates otu_table, tax_table etc. Then select the samples in tables of taxa_abund
, alpha_diversity
table etc when main_data parameter is FALSE. So for those taxa_abund and alpha_diversity, this function only filter samples, no features. To temporarily solve this, we can use:
library(microeco)
library(magrittr)
dataset_subset <-clone(dataset)
dataset_subset$cal_abund()
# directly manipulate the taxa_abund list
dataset_subset$taxa_abund$Class %<>% .[grepl("p__Verrucomicrobia", rownames(.)), ]
###plot:
t2 <- trans_abund$new(dataset = dataset_subset, taxrank = "Class", ntaxa = 3)
t2$plot_box(group = "Group", xtext_angle = 30)
OK, good to know. Thanks for all the explanations!