Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/issue 822 #825

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Enhancement/issue 822 #825

wants to merge 6 commits into from

Conversation

aGuyLearning
Copy link
Collaborator

@aGuyLearning aGuyLearning commented Nov 13, 2024

Description of changes
closes #822

Changed the method signature of univariate models to allow the user to pass parameters to the lifeline. Now weilbull, neil_aalen and kmf look like

adata: AnnData, duration_col: str, event_col: str, **kwargs

and are passed on to the _univariate_model function

Technical details

this could be changed to explicitly have all parameters in each function and pass them on.

Additional context

image

@eroell eroell self-requested a review November 13, 2024 14:12
@eroell
Copy link
Collaborator

eroell commented Nov 13, 2024

Thanks a lot @aGuyLearning, awesome! Comments as per review :)

model = model_class()
model.fit(T, event_observed=E)
model.fit(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add fit_left_censoring call upon argument input left

Copy link
Collaborator

Choose a reason for hiding this comment

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

check if nelson-aalen gracefully crashes with meaningful error message

durations: Iterable,
event_observed: Iterable | None = None,
timeline: Iterable = None,
entry: Iterable | None = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

no kwargs, but full arguments listed :)

@@ -376,7 +385,9 @@ def log_logistic_aft(adata: AnnData, duration_col: str, event_col: str, entry_co
)


def _univariate_model(adata: AnnData, duration_col: str, event_col: str, model_class, accept_zero_duration=True):
def _univariate_model(
adata: AnnData, duration_col: str, event_col: str, model_class, accept_zero_duration=True, **kwargs
Copy link
Collaborator

Choose a reason for hiding this comment

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

not kwargs but pass arguments, see above

alpha: float | None = None,
ci_labels: tuple[str, str] = None,
weights: Iterable | None = None,
censoring: Literal["right", "left"] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

add comment that and "right" just calls fit and "left" calls fit_left_censoring, maybe change default value to "right" instead of None

entry: Iterable | None = None,
label: str | None = None,
alpha: float | None = None,
ci_labels: tuple[str, str] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add None to typehint to make clear its optional

@@ -116,15 +116,10 @@ def glm(


def kmf(
Copy link
Collaborator

Choose a reason for hiding this comment

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

one additional thing here; we'll also have to watch out for backwards compatibility.
Here, we could while still accepting the arguments raise a deprecation warning, where we briefly highlight the new behaviour.

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.

Make Survival Analysis Estimators consistent, and pass all required arguments
2 participants