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

Decouple dataset from plots #332

Merged
merged 15 commits into from
Sep 20, 2024
Merged

Conversation

mschwoer
Copy link
Contributor

@mschwoer mschwoer commented Sep 18, 2024

Again, a lot of changes at once. But mostly moved code, and changes to __init__ methods .. see individual commit, I hope they make sense

@mschwoer mschwoer marked this pull request as ready for review September 18, 2024 16:37
Base automatically changed from decouple-dataset-from-statistics to development September 20, 2024 21:34
@mschwoer mschwoer merged commit 963a91f into development Sep 20, 2024
5 checks passed
@mschwoer mschwoer deleted the decouple-dataset-from-plots branch September 20, 2024 21:48
)

pass
# def plot_imputed_values(self): # TODO not used
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a requested feature and should be an issue to add the interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

# method = None


class PlotUtils:
@staticmethod
def _update_colors_plotly(fig, color_dict):
# plotly doesnt allow to assign color to certain group
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh yes it does. Mark as todo.

group2,
column=None,
method=None,
*,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

it makes people using this class downstream always use keyword arguments when creating an instance in this case

so before it was possible to have a

VolcanoPlot(mat, rawinput, ...)

now it makes us explicitly do

VolcanoPlot(mat=mat, rawinput=rawinput, ...)

Copy link
Collaborator

Choose a reason for hiding this comment

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

in terms of why do we need this — probably to prevent errors with the order of positional arguments

if plot:
self._perform_differential_expression_analysis()
self._annotate_result_df()
self._add_hover_data_columns()
self._plot()

# TODO this changes the actual metadata .. is this intended?
def _add_metadata_column(self, group1_list: list, group2_list: list):
# TODO this used to change the actual metadata .. was this intended?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do I get this right:
It used to add the _comparison_column to the DataSet metadata.
Now it returns the altered metadata to VolcanoPlot, which serves the purporse during the Volcano plot generation, but it is never back propagated to the metadata attribute of DataSet?
If that is so, then this is now fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

exactly. It overwrites the instance variable self.metadata with the updated metadata, but does not change the original value.

Note that these instance variables (mat, metadata, ...) in principle still can be changed in case they are mutable pd.DataFrame, dict, ..:
if in Statistics something like self.mat["new_column"] = 123" is done, then it will change the actual matobject of theDataSet(this fact is used to updatepreprocessing_info`)

Copy link
Collaborator

@JuliaS92 JuliaS92 left a comment

Choose a reason for hiding this comment

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

I am not sure I like the clutter of DataSet with all the plotting wrappers, especially considering all the feature requests that we have. Could we maybe do the same thing as with the statistics and preprocessing and initialize a plot class once with the data, so we can then do DataSet.plot.Volcano?

Copy link
Collaborator

@boopthesnoot boopthesnoot left a comment

Choose a reason for hiding this comment

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

👍

@@ -17,6 +17,7 @@
class Statistics:
def __init__(
self,
*,
Copy link
Collaborator

Choose a reason for hiding this comment

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

is the keyword-only the new default for the repo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not really, it's just for these very long argument lists .. ideally, only the data that is required for the operations is passed via constructor, and parameters (e.g. for plotting) are passed in the actual plot functions..

group2,
column=None,
method=None,
*,
Copy link
Collaborator

Choose a reason for hiding this comment

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

it makes people using this class downstream always use keyword arguments when creating an instance in this case

so before it was possible to have a

VolcanoPlot(mat, rawinput, ...)

now it makes us explicitly do

VolcanoPlot(mat=mat, rawinput=rawinput, ...)

group2,
column=None,
method=None,
*,
Copy link
Collaborator

Choose a reason for hiding this comment

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

in terms of why do we need this — probably to prevent errors with the order of positional arguments

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