docs: Add comprehensive Rarefaction section to transformation chapter#825
docs: Add comprehensive Rarefaction section to transformation chapter#825jagadeeshkaruturi11 wants to merge 1 commit intomicrobiome:develfrom
Conversation
Added new section 12.3 Rarefaction to address issue microbiome#823. Changes include: - Introduction to rarefaction with rarefyAssay() and niter parameter - Subsection on using rarefaction with alpha diversity (addAlpha) - Subsection on using rarefaction with beta diversity (addMDS) - Function comparison explaining differences between: * addAlpha() vs getAlpha() * runMDS() vs addMDS() Includes practical code examples demonstrating iterative rarefaction with niter=100.
antagomir
left a comment
There was a problem hiding this comment.
Nice, this could be useful & apologies for delays.
Kindly see the suggestions and we can finalize.
| # Perform iterative rarefaction | ||
| tse <- rarefyAssay( | ||
| tse, | ||
| method = "subsample", | ||
| sample = min_reads, | ||
| niter = 100 | ||
| ) | ||
|
|
||
| # Calculate alpha diversity on rarefied data | ||
| tse <- addAlpha( | ||
| tse, | ||
| assay_name = "counts_rarefied", | ||
| sample = min_reads, | ||
| niter = 100 | ||
| ) |
There was a problem hiding this comment.
addAlpha can be used independently of rarefyAssay.
Hence I am thinking that it might be more clear to show these as two separate operations that can both be feasible but each on their own right. Shall we split this chunk in two parts?
| # Perform MDS ordination on rarefied data | ||
| tse <- addMDS( | ||
| tse, | ||
| assay_name = "counts_rarefied", |
There was a problem hiding this comment.
mia changed argument names last year; "assay_name" is deprecated and should be replaced with "assay.type" everywhere
|
|
||
| ```{r} | ||
| #| label: rarefaction-alpha | ||
| #| eval: false |
|
|
||
| ```{r} | ||
| #| label: rarefaction-beta | ||
| #| eval: false |
| # Perform MDS ordination on rarefied data | ||
| tse <- addMDS( | ||
| tse, | ||
| assay_name = "counts_rarefied", |
There was a problem hiding this comment.
If "niter" parameter is used then doesn't it already take care or rarifification i.e. why not use assay.type="counts"?
| **`addAlpha()` vs `getAlpha()`**: Both functions calculate alpha diversity indices, but `addAlpha()` stores the results directly into the `colData` of the TreeSummarizedExperiment object, while `getAlpha()` returns the diversity values as a separate vector or matrix. Use `addAlpha()` when you want to keep all data together in one object, and `getAlpha()` when you need the diversity values for immediate use in other calculations. | ||
|
|
There was a problem hiding this comment.
I suggest to explain this earlier, where the rarified alpha diversity analysis is shown.
| **`runMDS()` vs `addMDS()`**: The `runMDS()` function calculates multidimensional scaling coordinates and returns them as a separate matrix, whereas `addMDS()` calculates the MDS coordinates and stores them directly into the `reducedDim` slot of the TreeSummarizedExperiment object. Using `addMDS()` is generally preferred as it maintains all results within the same data object, making downstream analyses and visualization more straightforward. | ||
|
|
There was a problem hiding this comment.
You could also comment whether this is available for other ordination functions e.g. runPCA, runNMDS..?
|
Sorry, I have been too busy lately... This PR is clashing with #819 The information on rarefaction was already updated but it is not yet rendered in the book. This PR has useful information, but we should think about the right place for this. Rarefaction is commonly used only in alpha and beta diversity (e.g., This One option:
|
|
Rarefaction can be viewed as a form of transformation / normalization. Hence I think that rarefyAssay() could be explained in the transformation chapter. We can consider whether a practical example is necessary - perhaps mentioning the existence of this function would be enough(?) It might have more use in the future, even if it is currently used less. Then one could briefly mention that by doing this, and then averaging results across multiple rarified replicates has been proposed by Schloss et al. Then, links could be provided to the alpha and beta diversity sections for more detailed examples on those. This way we could avoid that the boundaries between section become blurred and contents mixed? |
|
Makes sense. So:
|
Added new section 12.3 Rarefaction to address issue #823.
Changes include:
Includes practical code examples demonstrating iterative rarefaction with niter=100.