Skip to content

add getSurvival - #112

Merged
TuomasBorman merged 16 commits into
develfrom
cox
Oct 22, 2026
Merged

TuomasBorman merged 16 commits into
develfrom
cox

Conversation

@0xMuluh

@0xMuluh 0xMuluh commented May 6, 2025

Copy link
Copy Markdown
Contributor

ping #93

Signed-off-by: Daena Rys <rysdaena8@gmail.com>
@0xMuluh
0xMuluh requested review from TuomasBorman and antagomir May 6, 2025 07:43
@0xMuluh

0xMuluh commented May 6, 2025

Copy link
Copy Markdown
Contributor Author

This wrapper currently defaults to using pairwise log-ratio (PLR) transformations via coda4microbiome::coda_coxnet() , consistent with the approach described in Calle et al., 2024.

plr was selected by the authors over clr, ilr, or alr for reasons related to interpretability, sparsity, and model perfomance in high-dimensional microbiome survival analysis. While this default appears justified and performs well empirically, it may not be optimal in all cases.

If plr proves sufficient across expected use cases, we can add the unit tests around this assumption.

If user needs or new evidence suggest flexibility is needed, we should refactor to allow other transformation via a parameter (e.g., transform.method = "plr", "clr", "ilr", etc.). or mia::transformAssay()

Currently the method returns a list of objects including ggplots and dfs/matrices. We can consider addSurvival() and store in metadata?

Open to discussion on whether this needs to be prioritized now or flagged for future maintenance..

@TuomasBorman TuomasBorman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for this clear PR!

One thing to discuss is how much functionality we want to utilize from coda4microbiome package. If there are plans for broader interlinking, this PR might be fine. However, under the hood, coda_coxnet() is utilizing survival::coxph() and glmnet::cv.glmnet() and survminer for plotting.

The implementation in coda_coxnet() is not complex but includes some overhead that -- in my opinion -- does not necessarily fit well to our current design choices (transformation, printing, plotting).

Instead, this functionality for cox model could be implemented directly in miaTime package. We could take inspiration from the coda4microbiome package, but it seems that there is licence mismatch so this should be taken into account.

@antagomir

Copy link
Copy Markdown
Member

Thanks!

Indeed, I would not wrap coda4microbiome. We may like to test and run standard survival models (Cox) also with other transformation.

So let's keep separate:

  • data preparation (e.g. plr -> transformAssay)
  • statistical analysis / testing (e.g. Cox model, and glmnet if needed for feature selection)
  • summaries (e.g. tables)
  • visualizations (-> miaViz?)

This can take inspiration from coda4microbiome and cite it but Cox & GLM are more general and previously published methods. Moreover, the coda4microbiome paper did not include many comparisons to alternative transformations & methods. Our implementation should be modular and support different combinations of choices (e.g. transformation -> testing -> presentation).

The miaTime already includes data from the paper as example data, that could be used to verify the workflow (should yield the same result).

Signed-off-by: Daena Rys <rysdaena8@gmail.com>
@0xMuluh
0xMuluh requested a review from TuomasBorman August 22, 2025 11:44

@0xMuluh 0xMuluh left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread R/getSurvival.R Resolved
Comment thread R/getSurvival.R Resolved
Signed-off-by: Daena Rys <rysdaena8@gmail.com>
Signed-off-by: Daena Rys <rysdaena8@gmail.com>

@TuomasBorman TuomasBorman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! Can you also add unit tests?

Comment thread R/getSurvival.R Resolved
Comment thread R/getSurvival.R Resolved
Comment thread R/getSurvival.R Resolved
Comment thread R/getSurvival.R Resolved
Comment thread R/getSurvival.R Resolved
Comment thread R/getSurvival.R Resolved
Comment thread R/getSurvival.R Resolved
Comment thread R/getSurvival.R Resolved
Signed-off-by: Daena Rys <rysdaena8@gmail.com>
@0xMuluh

0xMuluh commented Sep 1, 2025

Copy link
Copy Markdown
Contributor Author

Thanks! Can you also add unit tests?

unit tests added after #107

@TuomasBorman TuomasBorman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!

Comment thread R/getSurvival.R Resolved
Comment thread R/getSurvival.R Resolved
Comment thread R/getSurvival.R Resolved
@antagomir

Copy link
Copy Markdown
Member

In manpage description clearly cite the publication where the data is from (note that there is a special way to add citations in roxygen). Now you only refer to R package. But there is also formal publication to cite.

Cite all references in the manpage text so that it is clear why they are added on the reference list.

Running the manpage examples gives error

The assay contains already only strictly positive values. Pseudocount is not added.
Error in list(coefficients = coefs, risk_scores = risk_scores, c_index = c_index, :
argument 6 is empty

Either the function name should be getCox or something explicit, or if it is getSurvival then there should be a method argument that specific what survival method one wants to use.

@antagomir

Copy link
Copy Markdown
Member

These are time-to-event models. How about renaming status.col into event.col?

@antagomir

Copy link
Copy Markdown
Member

getSurvival has

A list with model summaries:

    • ‘coefficients’: estimated model coefficients

    • ‘selected_features’: nonzero features in penalized model

    • ‘risk_scores’: predicted risk scores

    • ‘cindex.apparent’: apparent concordance index

    • ‘cv.cindex.mean’: mean cross-validated C-index (if penalized)

    • ‘cv.cindex.sd’: SD of cross-validated C-index (if penalized)

    • ‘fit’: fitted model object (coxph or cv.glmnet)

-> Harmonize to use "_" as the separator for all (do not mix)

-> cindex.apparent could be C.apparent, or just C ?

-> For clarity I would rename cv.cindex.mean to C.mean.cv and same for the SD ting

-> should selected_features be just nonzero_features if these are the same thing

-> coefficients is usually just coef in many R methods -> harmonize?

@0xMuluh

0xMuluh commented Sep 12, 2025

Copy link
Copy Markdown
Contributor Author

In manpage description clearly cite the publication where the data is from (note that there is a special way to add citations in roxygen). Now you only refer to R package. But there is also formal publication to cite.

The data has not been used. Will use this data instead: b752170

@0xMuluh

0xMuluh commented Sep 12, 2025

Copy link
Copy Markdown
Contributor Author

Running the manpage examples gives error

The assay contains already only strictly positive values. Pseudocount is not added.
Error in list(coefficients = coefs, risk_scores = risk_scores, c_index = c_index, :
argument 6 is empty

Thanks, there was a typo , in the return list.

0xMuluh and others added 6 commits September 12, 2025 14:21
Signed-off-by: Daena Rys <rysdaena8@gmail.com>
coxph(y ~ ., data) used every column of a data frame that included time and status, in the standard model and in the covariate model of the penalized fit. Keep the original feature names so that coefficients match rownames. Import predict from stats.
Coefficients are added to rowData and risk scores to colData, as suggested in review; the full results stay in metadata. Add a Details section describing the model and the coefficient rescaling.
Use the same seed for both fits, and check that the rescaled coefficients sum to 2 in absolute value instead of comparing them to the threshold.

@TuomasBorman TuomasBorman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you! Sorry for very long delay...

Future extension could be formula argument. Not sure how often that would be needed, so I think the current is good. But the idea would be that the user has more control in modeling the penalized version:

formula = relabundance ~ age * sex

@TuomasBorman
TuomasBorman merged commit 534c76d into devel Oct 22, 2026
0 of 3 checks passed
@TuomasBorman
TuomasBorman deleted the cox branch October 22, 2026 13:27
@0xMuluh 0xMuluh mentioned this pull request Oct 28, 2026

@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.

I would request at least these updates.

Since this is a variant of linear model it might fit better to LimROTS package as a standard alternative that can be used to benchmark the optimized survival methods in LimROTS? This way we could also be clear what is the recommended option after validation - @TuomasBorman ?

Comment thread R/getSurvival.R
#' tse, assay.type = "relabundance",
#' time.col = "event_time", event.col = "event"
#' )
#'

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.

Could we add example on how the results are summarized (e.g. as table) and visualized?

Comment thread R/getSurvival.R
#' (e.g. with \code{mia::transformAssay()}).
#'
#' @details
#' \code{getSurvival()} fits a Cox proportional hazards model with the

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.

If this only provides Cox model variants then it could be more clear to mark it as getCox (or getCoxSurvival but maybe the shorter is better). If we add more options later, then we can switch to a more generic name.

Comment thread R/getSurvival.R
#' \item \code{nfolds}: \code{Integer scalar}. Number of cross-validation
#' folds for \code{cv.glmnet}. (Default: \code{10})
#'
#' \item \code{nvar}: \code{Integer scalar}. Optional. Maximum number of

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.

if this is max number then max.var, max.features, or something could work better. Did you compare with other functions with similar parameters -> harmonize the argument name if possible.

@0xMuluh

0xMuluh commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

I would request at least these updates.

Since this is a variant of linear model it might fit better to LimROTS package as a standard alternative that can be used to benchmark the optimized survival methods in LimROTS? This way we could also be clear what is the recommended option after validation - @TuomasBorman ?

Thanks, done in #166: getCox() and addCox(), max.features, and examples with a coefficient table, a coefficient plot and Kaplan–Meier curves of the risk groups. @TuomasBorman, should it stay in miaTime or move to LimROTS?

@antagomir

antagomir commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

@0xMuluh Can you close the discussion issues above if they are resolved - will make it easier to monitor the progress on this one

Open a new issue on "formula argument" point mentioned by Tuomas above.

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.

3 participants