Comments (7)
Should be there.
Help.zip
from metagmisc.
Hello Cameron!
It is difficult to say why it's not working without seeing the data.
I think that it could be because of the small number of reads in some samples (probably after rarefaction). Could you post the results of:
sample_sums(p.b.a.m.s.lab)
taxa_are_rows(p.b.a.m.s.lab)
With best regards,
Vladimir
from metagmisc.
from metagmisc.
Hello Cameron,
By default, phyloseq_mult_raref
does not remove OTUs with zero abundance (trimOTUs = FALSE
).
So you may remove these OTUs after the averaging:
prune_taxa(taxa_sums(p.rf) > 0, p.rf)
Please let me know if it works for you.
With best regards,
Vladimir
from metagmisc.
from metagmisc.
Maybe you can me send me your phyloseq object and I'll take a look why it doesn't work as expected?
Just remove the metadata and anonymize or shuffle the labels.
from metagmisc.
This discrepancy in the number of observed OTUs is due to the large number of OTUs with very small relative abundance (<= 0.054%).
So when you rarefy data multiple times, there is a small probability that rare OTUs will be present in some iterations, but not in the others. After the averaging, abundance of these OTUs will be very small (not zero!), so they will remain in the OTU table.
We can find these OTUs:
# Remove taxonomy table to speed up psmelt
p.rf@tax_table <- NULL
p.rf.1@tax_table <- NULL
# Convert p.rf.1 to relative abundances
p.rf.1 <- transform_sample_counts(p.rf.1, function(x) x / sum(x) )
multr <- psmelt(p.rf)
singr <- psmelt(p.rf.1)
# Compare OTU abundances in p.rf & p.rf.1
compare <- multr
compare$Samp_OTU <- with(compare, interaction(Sample, OTU))
singr$Samp_OTU <- with(singr, interaction(Sample, OTU))
compare$Abundance_R1 <- singr[match(x = compare$Samp_OTU, table = singr$Samp_OTU), "Abundance"]
compare$Abundance_R1[ is.na(compare$Abundance_R1) ] <- 0
compare <- compare[-which(compare$Abundance == 0 & compare$Abundance_R1 == 0), ]
ggplot(data = compare, aes(x = Abundance_R1, y = Abundance)) + geom_point() +
labs(x = "Single rarefaction", y = "Averaged across multiple rarefactions")
# Extract OTUs that are missing in single-rarefied data, but present in multiple rarefactions
diffs <- compare[ compare$Abundance_R1 == 0, ]
length(unique(diffs$OTU))
summary(diffs$Abundance)
# Min. 1st Qu. Median Mean 3rd Qu. Max.
# 0.00000100 0.00001800 0.00003400 0.00005179 0.00006525 0.00054000
# Here is a long tail of rare OTUs which were absent in single-rarefied data
ggplot(data = compare, aes(x = Abundance_R1, y = Abundance)) + geom_point() +
labs(x = "Single rarefaction", y = "Averaged across multiple rarefactions") +
ylim(c(0, max(diffs$Abundance)))
Relative abundances of single rarefaction iteration vs averaged across multiple rarefaction iterations:
Tail with rare OTUs which were absent in single-rarefied data:
from metagmisc.
Related Issues (20)
- phyloseq_replace_zero and phyloseq_transform_aldex_clr HOT 1
- Prevalence plots (total OTU abundance vs OTU prevalence) HOT 1
- Error in dimnames(x) when trying to normalize OTU table in a phyloseq object HOT 2
- Problem installing vmikk/metagMisc HOT 5
- `dissimilarity_to_distance` - error if number of OTUs > number of samples
- shared otus function problem HOT 4
- phyloseq_filter_prevalence error
- phyloseq_to_df error: Sample names HOT 4
- Error in validObject(.Object) : invalid class “otu_table” object: OTU abundance data must have non-zero dimensions HOT 2
- Average rarified OTU/ASV table after multiple rarefaction HOT 3
- Rewrite `get_max_taxonomic_rank` using `data.table`
- phyloseq_inext: merge fail HOT 1
- Error in validObject(.Object) : invalid class “otu_table” object: OTU abundance data must have non-zero dimensions. HOT 6
- phyloseq_inext -- error in rbind HOT 3
- [adonis_pairwise function] Deprecation notice: Replace vegan::adonis with vegan::adonis2 HOT 2
- Prevalence function missing from install HOT 3
- Rewrite `prevalence` function using `data.table` HOT 1
- error in function phyloseq_filter_prevalence HOT 14
- Implement robust alternative to SES
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from metagmisc.