Skip to content

Paired multi-factor analysis#32

Merged
BorisMuzellec merged 26 commits intomainfrom
multifactor
Jan 9, 2023
Merged

Paired multi-factor analysis#32
BorisMuzellec merged 26 commits intomainfrom
multifactor

Conversation

@BorisMuzellec
Copy link
Copy Markdown
Collaborator

@BorisMuzellec BorisMuzellec commented Jan 5, 2023

This (big) PR aims to implement paired multi-factor analysis.
It is now possible to provide several design factors to a DeseqDataSet, as long as they are bi-level.

TODO: an example notebook (in another PR ?)

@BorisMuzellec BorisMuzellec marked this pull request as ready for review January 5, 2023 14:06
@BorisMuzellec BorisMuzellec requested review from a user, arthurPignetOwkin and maikia January 5, 2023 14:06
Copy link
Copy Markdown
Collaborator

@maikia maikia left a comment

Choose a reason for hiding this comment

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

nice work @BorisMuzellec
I think it might be useful to start doing unit test to separate functions (maybe not here as it's already a large PR), ie not just compare the results to R but test for different inputs to the new function. It will be much easier to debug once error appears and you can test for more edge cases this way

self.design_matrix = build_design_matrix(
self.clinical,
design_factor,
design_factors,
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.

just a minor comment: I would suggest to add the argument names which adds for the clarity of read (not required for merge though)

Copy link
Copy Markdown
Collaborator Author

@BorisMuzellec BorisMuzellec Jan 9, 2023

Choose a reason for hiding this comment

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

Hi Maria, not sure what you mean, do you mean we should write design=design_factors in the arguments?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've named all arguments in 3c0ded6

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.

yes, that's what I meant. Thanks :-)

with parallel_backend("loky", inner_max_num_threads=1):
mu_hat_ = np.array(
Parallel(
# mu_hat is initialized differently depending on the number of different factor
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.

do you think it might be useful to through a warning or otherwise give the comment to the user on which fit was used? Or at least add it to the docstring so it is easier to find? (please ignore if you don't think it is useful information to the user)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That's a good question. Personally I don't think a warning is necessary, as the _mu_hat attribute is not meant to be accessed by the user (it's an intermediate value). DESeq2 does this silently too. If that's OK for you, I'll leave this as is for now.

dds : DeseqDataSet
DeseqDataSet for which dispersion and LFCs were already estimated.

contrast : list[str] or None
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.

from this description I am not sure what contrast actually is (just the format of it) and when to use it instead of None. Could you add a short description?

Copy link
Copy Markdown
Collaborator Author

@BorisMuzellec BorisMuzellec Jan 9, 2023

Choose a reason for hiding this comment

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

I've expanded the description of this argument : 8c2197a

Let me know if this helps, or if it is still a bit obscure

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.

yes, thanks!

# Build contrast if None
if contrast is not None:
# TODO : tests on the contrast
self.contrast = contrast
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.

maybe check if the contrast is indeed given as required? ie three strings in a list and through an error otherwise

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added tests in 39f4211 and b0e35f5

offset,
prior_no_shrink_scale,
prior_scale,
"L-BFGS-B",
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.

maybe add a comment that it's an optimizer

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've added the argument name ("optimizer") in 3c0ded6

@BorisMuzellec
Copy link
Copy Markdown
Collaborator Author

Thanks a lot @maikia for your review, it was super helpful :).
I've pushed a few commits based on your suggestions, could you have a look at them when you have time? Thanks!

@BorisMuzellec BorisMuzellec requested a review from maikia January 9, 2023 13:07
Copy link
Copy Markdown
Collaborator

@maikia maikia left a comment

Choose a reason for hiding this comment

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

All good to go, thanks for your updates @BorisMuzellec

@BorisMuzellec BorisMuzellec merged commit 780b48e into main Jan 9, 2023
@BorisMuzellec BorisMuzellec deleted the multifactor branch January 9, 2023 14:11
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.

2 participants