Skip to content

Create multimedia.qmd - #768

Open
YihanLiu4023 wants to merge 31 commits into
microbiome:develfrom
YihanLiu4023:patch-1
Open

Create multimedia.qmd#768
YihanLiu4023 wants to merge 31 commits into
microbiome:develfrom
YihanLiu4023:patch-1

Conversation

@YihanLiu4023

Copy link
Copy Markdown
Contributor

No description provided.

@antagomir antagomir left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Check the suggestions and the following:

  1. increase support for the mia and (Tree)SummarizedExperiment methods when possible, this is very useful for compatibility with many other methods; I added suggestions. Also multimedia seems to support SE so this should be done.

  2. Let us try to avoid repetition in the code; this has now two almost identical parts. Shall we prepare example data that is readily usable for the examples?

  3. I am wondering if there would be a way to combine the two mediation chapters into one?

  4. If we consider these methods widely usable we should consider providing wrappers for the interpretation, summaries, and visualizations of the results; either as contributions to "multimedia" package, or into mia or some other pkg (doesn't matter which pkg as long as it works)

Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
@antagomir

Copy link
Copy Markdown
Member

Could you resolve the cases you have closed (from the "Resolve" buttons)?

@YihanLiu4023

Copy link
Copy Markdown
Contributor Author

Fixed most of the detailed comments, still working on the more genral ones like creating pkg. Will finish this asap

@antagomir

Copy link
Copy Markdown
Member

Can you resolve the completed suggestions above and confirm if this is ready to merge?

YihanLiu4023 and others added 2 commits August 30, 2025 02:36
Just fixed some minor inconsistence in the name of variables
@antagomir

Copy link
Copy Markdown
Member

To be checked in more detail before merge, regarding the following:

  1. May require additional wrapper functions to extract the relevant information from data objects more intuitively (but those should be in multimedia pkg or mia, so not sure if it is feasible to do as part of this PR - but if not, then it is unclear when this would take place).

  2. Are the examples now sufficiently short & concise (data cleaning steps usually avoided in OMA examples; some explanations could be added instead).

@YihanLiu4023

Copy link
Copy Markdown
Contributor Author

To be checked in more detail before merge, regarding the following:

  1. May require additional wrapper functions to extract the relevant information from data objects more intuitively (but those should be in multimedia pkg or mia, so not sure if it is feasible to do as part of this PR - but if not, then it is unclear when this would take place).
  2. Are the examples now sufficiently short & concise (data cleaning steps usually avoided in OMA examples; some explanations could be added instead).

Hi Leo, thank you for the suggestions. I have added some wrapper functions, especially to where you indicated. For the data cleanning steps, do you mean we can remove those part, and add some texts to explain instead?

@antagomir

Copy link
Copy Markdown
Member

The data cleaning part would work best if we include a suitable cleaned demo data in the R pkg, then we can skip the data cleaning steps in OMA. The problem is that if we could do this with every single method but then more than half of the book might easily be data cleaning examples, and this is also shifting the focus from the actual method to general data processing steps -> can we include demo data set/s in the multimedia, mia, or other pkg, or can we use already existing demo data sets?

@antagomir

Copy link
Copy Markdown
Member

Regarding the wrappers, we could see if we can include these in a package if they would be generally useful anyway.

@himelmallick

Copy link
Copy Markdown

Hi Leo – just wanted to quickly chime in here. This dataset is a special case where we don’t have a conventional, well-defined outcome for mediation analysis. Instead, the outcome is a dysbiosis score derived from taxonomic profiles, as described by Lloyd-Price et al. (2019), which, to my knowledge, hasn’t been implemented elsewhere. We are already drawing the data from curatedMetagenomicData, but creating the dysbiosis score is a necessary step to showcase the mediation analysis.

@antagomir

Copy link
Copy Markdown
Member

Thanks. I think that dysbiosis score could then stay there. Let's check @TuomasBorman feedback.

@TuomasBorman TuomasBorman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks very good! However, there are couple points to discuss.

This book is intended as teaching material to demonstrate specific analyses and tasks. The main focus is on the underlying ideas and concepts rather than implementation details. Therefore, the code is kept as simple as possible to achieve the intended outcomes. More polished analyses, including advanced plots, are better suited for workflow packages (we are also considering creating workflow package to showcase more complex analyses).

There are couple lengthy code chunks that do operations to results. Having these long chunks have opposite effect as readers are exhausted by the amount of code and they cannot focus on the main points. Everything that is not relevant for the main point should be removed even though plots or names would not be optimal.

Ideally, these wrappers will be implemented in a package, but of course it takes some time. At least, we should have plan to implement them. If we just leave it here, these will be never implemented as we are very busy with everything.

Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
@antagomir

Copy link
Copy Markdown
Member

Can you @YihanLiu4023 confirm when you're ready with the updates? Can you also press the "Update branch" button above to ensure that this PR is in sync with the latest devel branch.

@YihanLiu4023

Copy link
Copy Markdown
Contributor Author

Updated file submitted!

@antagomir antagomir left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - some points to clarify still.

Overall this looks good but it will be essential to consider the following:

  1. Data cleaning operations should be either ignored, or readily cleaned demo data set should be used (it can be placed to one of our packages). Otherwise OMA would be primarily a data cleaning example collection..

  2. We need to check if any ready-made functionality is available to fetch and visualize results from mediation analyses. Now this is done with custom code. Maybe multimedia package has some utilities and if not, we should see if some tasks are so central that they should be standardized (either into multimedia package as contributed PR, or into mia).

Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
@antagomir

antagomir commented Jan 9, 2026

Copy link
Copy Markdown
Member

This seems nearly complete.

I picked the following points from above. Can you confirm this is OK @YihanLiu4023 ?

  1. Data cleaning operations: add and use readily cleaned demo data set for the examples. This will keep the examples more focused on the actual core point (mediation). If suitable demo data does not exist, we can add it in mia or another package (should be done before merging this but is straightfwd if the data is already prepared - we can help with this as necessary).
  2. Minor update on the visualisations as discussed above. Mostly just cite the multimedia homepage (and publication) for further guidance and examples.

@YihanLiu4023

Copy link
Copy Markdown
Contributor Author

This seems nearly complete.

I picked the following points from above. Can you confirm this is OK @YihanLiu4023 ?

  1. Data cleaning operations: add and use readily cleaned demo data set for the examples. This will keep the examples more focused on the actual core point (mediation). If suitable demo data does not exist, we can add it in mia or another package (should be done before merging this but is straightfwd if the data is already prepared - we can help with this as necessary).
  2. Minor update on the visualisations as discussed above. Mostly just cite the multimedia homepage (and publication) for further guidance and examples.

@YihanLiu4023

Copy link
Copy Markdown
Contributor Author

Hi, I uploaded a new version according to the comments but had 1 failing check: Style code. I also ran the style workflow locally in R. However, the automated styler check reformatted the R chunks back to 2-space indentation. Is there any way to solve this?

@RiboRings

Copy link
Copy Markdown
Member

Thanks!

Looks pretty good! I still have a couple of comments.

@RiboRings RiboRings left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments, please have a look below and resolve them when addressed.

Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd

@RiboRings RiboRings left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much, I'm confident we'll be ready in one or two more rounds of review. Please keep up the great work! 🥇

Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd
@YihanLiu4023

Copy link
Copy Markdown
Contributor Author

Sorry I just realized the data loading is not yet updated (all the other comments till now is updated). I would push a new one right away.

Comment thread inst/pages/multimedia.qmd Outdated

@RiboRings RiboRings left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more comments.

Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
Comment thread inst/pages/multimedia.qmd Outdated
@antagomir

Copy link
Copy Markdown
Member

@YihanLiu4023 can you resolve the remaining comments, then we approach completion?

@antagomir

Copy link
Copy Markdown
Member

@YihanLiu4023 kindly confirm when this is complete based on the feedback.

@antagomir

Copy link
Copy Markdown
Member

@RiboRings you commented, could you resolve responses that are ok?

@RiboRings

Copy link
Copy Markdown
Member

Hi @YihanLiu4023! I opened a pull request with some adjustments to your branch: YihanLiu4023#1

Please accept it so the changes are reflected here, and check that the code still runs correctly.

@RiboRings

RiboRings commented Aug 6, 2026

Copy link
Copy Markdown
Member

Two main considerations:

I am not getting what exactly is multi-omic about multimedia. In the chapter, microbiome and pathway experiments are analysed separately (with identical pipelines). In my understanding this isn't considered multi-omics since it isn't combining different omics into a single analysis.

If the idea is to study mediation using several features together (from a single omic type), multivariate would be the correct term to use here. But it should not be called multi-omic or multimodal.

Also, the chapter is relatively computationally intensive. To keep the book deployment short, reduce bootstrap iterations to the minimum where you still get similar results, and comment that ideally some N iterations should be run.

@YihanLiu4023

Copy link
Copy Markdown
Contributor Author

YihanLiu4023#1

Accepted!

@YihanLiu4023

Copy link
Copy Markdown
Contributor Author

Two main considerations:

I am not getting what exactly is multi-omic about multimedia. In the chapter, microbiome and pathway experiments are analysed separately (with identical pipelines). In my understanding this isn't considered multi-omics since it isn't combining different omics into a single analysis.

If the idea is to study mediation using several features together (from a single omic type), multivariate would be the correct term to use here. But it should not be called multi-omic or multimodal.

Also, the chapter is relatively computationally intensive. To keep the book deployment short, reduce bootstrap iterations to the minimum where you still get similar results, and comment that ideally some N iterations should be run.

  1. Yes, with species and pathway analysed separately, this is multivariate rather than multi-omic. I have renamed in all related part as "multivariate mediation". I also re-wrote the intro paragraph to describe high-dimensional mediation within a single omic layer.

  2. I reduced all B to 10 and added a note in the narrative: "To keep the book build time short, we use only B = 10 bootstrap iterations below; for real applications we recommend B >= 500 (ideally 1000 or more) to obtain stable percentile confidence intervals, so the CI widths shown here should be interpreted as illustrative rather than definitive."

@RiboRings

RiboRings commented Aug 9, 2026

Copy link
Copy Markdown
Member

Thanks a lot @YihanLiu4023!

This is ready from my side.

@antagomir @himelmallick @TuomasBorman any other thoughts on the last few comments above or just in general?

@YihanLiu4023

Copy link
Copy Markdown
Contributor Author

Thanks a lot @YihanLiu4023!

This is ready from my side.

@antagomir @himelmallick @TuomasBorman any other thoughts on the last few comments above or just in general?

Sounds great, thanks! I'm happy to work on any further comments.

@antagomir antagomir left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Could you clarify the necessity of the second case (pathways)? At a quick look it seems very similar to the first part (taxa).

Comment thread inst/pages/multimedia.qmd
na.rm = TRUE
))

is_healthy <- tse$disease == "healthy"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you incorporate this in the tse data itself?

tse$is_healthy <- ...

then it will be managed together with the other data

Comment thread inst/pages/multimedia.qmd
# Plot the bootstrap distribution
ggplot(boot_overall$indirect, aes(indirect_effect)) +
geom_histogram(bins = 20, fill = "#69b3a2", color = "black") +
ggtitle("Bootstrap Distribution of Overall Indirect Effect (B = 10)") +

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ggtitle is nowadays replaced by labs(title=...), can you switch to that?

Comment thread inst/pages/multimedia.qmd
# Define mediator-specific indirect effects for bootstrap resampling
indirect_each <- function(mdl, exper) {
res <- estimate(mdl, exper)
alpha <- sapply(res@mediation@estimates, function(m) coef(m)["treatmentT1"])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there no more direct way to pick the estimates than res@mediation@estimates? Usually there are getters to pick these things and these have advantages.

Comment thread inst/pages/multimedia.qmd

# Scale counts to [0, 1]
assay(se) <- assay(se) / 100

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TuomasBorman should we add this as ready-made demo data set? This processing code takes quite some space.

Comment thread inst/pages/multimedia.qmd
the outcome, but pathways abundances as the mediation variables instead of the
relative species abundance.

## Performing multivariate mediation analysis for pathways abundances {#sec-pathways-abundances}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part seems very much like repetition of what was already above.

Is this just a different data type (e.g. pathways), or is there a genuine difference so that it is justified to include this full second example workflow starting here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants