diff --git a/Docs/ChangeLog.md b/Docs/ChangeLog.md index 29daf0a..0ed95eb 100644 --- a/Docs/ChangeLog.md +++ b/Docs/ChangeLog.md @@ -1,3 +1,8 @@ +# Version: 1.119.4 +## Date: 2024-12-3 +### Changes: +- New: added an option to plot violin plot to replace the box plot in the basic plot part. + # Version: 1.119.3 ## Date: 2024-12-3 ### Changes: diff --git a/Docs/MetaX_Cookbook.assets/basic_stats_heatmap.png b/Docs/MetaX_Cookbook.assets/basic_stats_heatmap.png index 1ac0a1b..48d91b9 100644 Binary files a/Docs/MetaX_Cookbook.assets/basic_stats_heatmap.png and b/Docs/MetaX_Cookbook.assets/basic_stats_heatmap.png differ diff --git a/Docs/MetaX_Cookbook.assets/basic_stats_heatmap_seeting.png b/Docs/MetaX_Cookbook.assets/basic_stats_heatmap_seeting.png index b31c45a..a136072 100644 Binary files a/Docs/MetaX_Cookbook.assets/basic_stats_heatmap_seeting.png and b/Docs/MetaX_Cookbook.assets/basic_stats_heatmap_seeting.png differ diff --git a/Docs/MetaX_Cookbook.assets/basic_stats_pca.png b/Docs/MetaX_Cookbook.assets/basic_stats_pca.png index 75078c9..8714e93 100644 Binary files a/Docs/MetaX_Cookbook.assets/basic_stats_pca.png and b/Docs/MetaX_Cookbook.assets/basic_stats_pca.png differ diff --git a/Docs/MetaX_Cookbook.assets/co_network_page.png b/Docs/MetaX_Cookbook.assets/co_network_page.png index e034b93..ae8dee9 100644 Binary files a/Docs/MetaX_Cookbook.assets/co_network_page.png and b/Docs/MetaX_Cookbook.assets/co_network_page.png differ diff --git a/Docs/MetaX_Cookbook.assets/dev_menu.png b/Docs/MetaX_Cookbook.assets/dev_menu.png index 4226d2e..1b2d60b 100644 Binary files a/Docs/MetaX_Cookbook.assets/dev_menu.png and b/Docs/MetaX_Cookbook.assets/dev_menu.png differ diff --git a/Docs/MetaX_Cookbook.assets/group_control_test.png b/Docs/MetaX_Cookbook.assets/group_control_test.png index 50635a3..59ed96c 100644 Binary files a/Docs/MetaX_Cookbook.assets/group_control_test.png and b/Docs/MetaX_Cookbook.assets/group_control_test.png differ diff --git a/Docs/MetaX_Cookbook.assets/group_in_condition.png b/Docs/MetaX_Cookbook.assets/group_in_condition.png index 581301c..3945bd2 100644 Binary files a/Docs/MetaX_Cookbook.assets/group_in_condition.png and b/Docs/MetaX_Cookbook.assets/group_in_condition.png differ diff --git a/Docs/MetaX_Cookbook.assets/pca_setting.png b/Docs/MetaX_Cookbook.assets/pca_setting.png index 43e7841..0c3e396 100644 Binary files a/Docs/MetaX_Cookbook.assets/pca_setting.png and b/Docs/MetaX_Cookbook.assets/pca_setting.png differ diff --git a/Docs/MetaX_Cookbook.assets/settings.png b/Docs/MetaX_Cookbook.assets/settings.png index a602658..ab7261d 100644 Binary files a/Docs/MetaX_Cookbook.assets/settings.png and b/Docs/MetaX_Cookbook.assets/settings.png differ diff --git a/Docs/MetaX_Cookbook.assets/settings_page2.png b/Docs/MetaX_Cookbook.assets/settings_page2.png index b597afe..93128dc 100644 Binary files a/Docs/MetaX_Cookbook.assets/settings_page2.png and b/Docs/MetaX_Cookbook.assets/settings_page2.png differ diff --git a/Docs/MetaX_Cookbook.assets/sub_meta.png b/Docs/MetaX_Cookbook.assets/sub_meta.png index 9df3005..64a2d46 100644 Binary files a/Docs/MetaX_Cookbook.assets/sub_meta.png and b/Docs/MetaX_Cookbook.assets/sub_meta.png differ diff --git a/Docs/MetaX_Cookbook.assets/t_test.png b/Docs/MetaX_Cookbook.assets/t_test.png index 91f5c0c..c5b215b 100644 Binary files a/Docs/MetaX_Cookbook.assets/t_test.png and b/Docs/MetaX_Cookbook.assets/t_test.png differ diff --git a/Docs/MetaX_Cookbook.assets/taxa_func_link_page.png b/Docs/MetaX_Cookbook.assets/taxa_func_link_page.png index f279bb5..2bfe6f6 100644 Binary files a/Docs/MetaX_Cookbook.assets/taxa_func_link_page.png and b/Docs/MetaX_Cookbook.assets/taxa_func_link_page.png differ diff --git a/Docs/MetaX_Cookbook.assets/taxa_func_link_page2.png b/Docs/MetaX_Cookbook.assets/taxa_func_link_page2.png index 5a2994c..fa57a3e 100644 Binary files a/Docs/MetaX_Cookbook.assets/taxa_func_link_page2.png and b/Docs/MetaX_Cookbook.assets/taxa_func_link_page2.png differ diff --git a/Docs/MetaX_Cookbook.assets/trends_page.png b/Docs/MetaX_Cookbook.assets/trends_page.png index 75a8904..c6b57df 100644 Binary files a/Docs/MetaX_Cookbook.assets/trends_page.png and b/Docs/MetaX_Cookbook.assets/trends_page.png differ diff --git a/Docs/MetaX_Cookbook.md b/Docs/MetaX_Cookbook.md index a8b1696..beb5c26 100644 --- a/Docs/MetaX_Cookbook.md +++ b/Docs/MetaX_Cookbook.md @@ -257,7 +257,7 @@ We can select **meta** **groups** or **samples** (default a - Select **Sub Meta** to plot with two meta - - sub_meta + - - Change settings in the **PLOT PARAMETER** tab @@ -269,11 +269,11 @@ We can select **meta** **groups** or **samples** (default a **e.g. :** Select PBS, BAS and others groups **only in** Individual V1 - - group_in_condition + - - Select **specific Samples** to Analysis - - image-20230728113359732 + - @@ -309,7 +309,7 @@ We can select **meta** **groups** or **samples** (default a ### Heatmap and Bar Plot -basic_stats_heatmap + - **Select items(Taxa, Function, Taxa-Func and Peptide ) to plot:** - Add **All Taxa**, or select one we are interested in. @@ -340,17 +340,10 @@ We can select **meta** **groups** or **samples** (default a - **Rename Samples**: Add group info to each sample name - **Rename Taxa**: Only keep the last taxonomic level to reduce to name - **Plot Mean**: calculate the mean of each group before plotting - + - **Sub Meta:** select a second meta, then combine two meta by mean for Heatmap and 3D bar plot - - **For Heatmap** - - **Theme**: The theme of the heatmap - - **scale**: Scale method of the heatmap - - **Show All Labels:** if show all labels in the heatmap - - **For Bar** - - **Bar Ldg**: Show the legend when plotting Bar - - **Bar %:** Transfer each col to percent when plotting Bar - - basic_stats_heatmap_seeting - + - + - Plot all color maps to view by right click **Theme** - ![right_click_theme](MetaX_Cookbook.assets/right_click_theme.png) - all_cmap diff --git a/metax/gui/main_gui.py b/metax/gui/main_gui.py index 13067c2..5726901 100644 --- a/metax/gui/main_gui.py +++ b/metax/gui/main_gui.py @@ -4499,10 +4499,13 @@ def get_title_by_table_name(self, table_name): elif method == 'box': plot_samples = self.checkBox_box_plot_samples.isChecked() + violinplot = self.checkBox_box_violinplot.isChecked() + log_scale = self.checkBox_box_log_scale.isChecked() BasicPlot(self.tfa).plot_box_sns(df=df, title_name=title_name, show_fliers=show_fliers, width=width, height=height, font_size=font_size, theme=theme, rename_sample = rename_sample, plot_samples = plot_samples, - legend_col_num=legend_col_num, sub_meta = sub_meta) + legend_col_num=legend_col_num, sub_meta = sub_meta, + violinplot=violinplot, log_scale=log_scale) elif method == 'corr': cluster = self.checkBox_corr_cluster.isChecked() diff --git a/metax/gui/metax_gui/main_window.ui b/metax/gui/metax_gui/main_window.ui index 9191950..42448ed 100644 --- a/metax/gui/metax_gui/main_window.ui +++ b/metax/gui/metax_gui/main_window.ui @@ -246,7 +246,7 @@ 0 0 462 - 527 + 531 @@ -1447,7 +1447,7 @@ QTabWidget::Triangular - 0 + 1 @@ -1831,7 +1831,7 @@ 0 0 885 - 237 + 239 @@ -2098,19 +2098,6 @@ - - - - - 0 - 0 - - - - show Fliers - - - @@ -2124,19 +2111,6 @@ - - - - - 0 - 0 - - - - Plot Samples - - - @@ -2607,6 +2581,50 @@ + + + + + + + 0 + 0 + + + + Plot Samples + + + + + + + + 0 + 0 + + + + show Fliers + + + + + + + Log Scale + + + + + + + + + Plot as Violinplot + + + @@ -2687,6 +2705,12 @@ + + + 0 + 0 + + Select for plotting @@ -2724,7 +2748,7 @@ false - + 0 0 @@ -2740,7 +2764,7 @@ false - + 0 0 @@ -2756,7 +2780,7 @@ false - + 0 0 @@ -2899,7 +2923,7 @@ - + 0 0 @@ -3162,7 +3186,7 @@ 0 0 885 - 187 + 170 @@ -5989,8 +6013,8 @@ 0 0 - 865 - 117 + 535 + 94 @@ -6533,7 +6557,7 @@ false - + 0 0 @@ -6549,7 +6573,7 @@ false - + 0 0 @@ -6565,7 +6589,7 @@ false - + 0 0 @@ -6717,7 +6741,7 @@ 0 0 885 - 168 + 170 @@ -7133,13 +7157,13 @@ - + 0 0 - Focus List + Select Focus @@ -7359,19 +7383,6 @@ - - - - - 0 - 0 - - - - List for Plotting - - - @@ -7384,7 +7395,7 @@ 16777215 - 260 + 250 @@ -7402,7 +7413,7 @@ 0 0 885 - 119 + 123 @@ -7630,7 +7641,7 @@ - + 0 0 @@ -7828,61 +7839,6 @@ - - - - - - false - - - - 0 - 0 - - - - Drop Item - - - - - - - false - - - - 0 - 0 - - - - Clean List - - - - - - - false - - - - 0 - 0 - - - - Add a list to the drawing box, make sure there is one item per line. - - - Add A list - - - - - @@ -7892,6 +7848,12 @@ + + + 0 + 0 + + Select for plotting @@ -8121,6 +8083,61 @@ + + + + + + false + + + + 0 + 0 + + + + Drop Item + + + + + + + false + + + + 0 + 0 + + + + Clean List + + + + + + + false + + + + 0 + 0 + + + + Add a list to the drawing box, make sure there is one item per line. + + + Add A list + + + + + @@ -8141,7 +8158,7 @@ QTabWidget::Triangular - 0 + 1 @@ -9537,7 +9554,7 @@ 0 0 885 - 166 + 158 @@ -10738,7 +10755,7 @@ 0 0 991 - 23 + 21 diff --git a/metax/gui/metax_gui/ui_main_window.py b/metax/gui/metax_gui/ui_main_window.py index a668a49..dfc4155 100644 --- a/metax/gui/metax_gui/ui_main_window.py +++ b/metax/gui/metax_gui/ui_main_window.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'c:\Users\max\OneDrive - University of Ottawa\code\TaxaFunc\MetaX\metax\gui\metax_gui\main_window.ui' +# Form implementation generated from reading ui file 'c:\Users\Qing\OneDrive - University of Ottawa\code\TaxaFunc\MetaX\metax\gui\metax_gui\main_window.ui' # # Created by: PyQt5 UI code generator 5.15.9 # @@ -147,7 +147,7 @@ def setupUi(self, metaX_main): self.toolBox_2.setMaximumSize(QtCore.QSize(1677, 16777215)) self.toolBox_2.setObjectName("toolBox_2") self.page_2 = QtWidgets.QWidget() - self.page_2.setGeometry(QtCore.QRect(0, 0, 462, 527)) + self.page_2.setGeometry(QtCore.QRect(0, 0, 462, 531)) self.page_2.setObjectName("page_2") self.gridLayout_27 = QtWidgets.QGridLayout(self.page_2) self.gridLayout_27.setObjectName("gridLayout_27") @@ -904,7 +904,7 @@ def setupUi(self, metaX_main): self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidgetContents = QtWidgets.QWidget() - self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 885, 237)) + self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 885, 239)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.gridLayout_34 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents) self.gridLayout_34.setObjectName("gridLayout_34") @@ -1035,14 +1035,6 @@ def setupUi(self, metaX_main): self.label_137.setFont(font) self.label_137.setObjectName("label_137") self.gridLayout_34.addWidget(self.label_137, 8, 0, 1, 1) - self.checkBox_box_if_show_fliers = QtWidgets.QCheckBox(self.scrollAreaWidgetContents) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.checkBox_box_if_show_fliers.sizePolicy().hasHeightForWidth()) - self.checkBox_box_if_show_fliers.setSizePolicy(sizePolicy) - self.checkBox_box_if_show_fliers.setObjectName("checkBox_box_if_show_fliers") - self.gridLayout_34.addWidget(self.checkBox_box_if_show_fliers, 6, 2, 1, 1) self.label_122 = QtWidgets.QLabel(self.scrollAreaWidgetContents) font = QtGui.QFont() font.setBold(True) @@ -1050,14 +1042,6 @@ def setupUi(self, metaX_main): self.label_122.setFont(font) self.label_122.setObjectName("label_122") self.gridLayout_34.addWidget(self.label_122, 0, 0, 1, 1) - self.checkBox_box_plot_samples = QtWidgets.QCheckBox(self.scrollAreaWidgetContents) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.checkBox_box_plot_samples.sizePolicy().hasHeightForWidth()) - self.checkBox_box_plot_samples.setSizePolicy(sizePolicy) - self.checkBox_box_plot_samples.setObjectName("checkBox_box_plot_samples") - self.gridLayout_34.addWidget(self.checkBox_box_plot_samples, 6, 1, 1, 1) self.horizontalLayout_34 = QtWidgets.QHBoxLayout() self.horizontalLayout_34.setObjectName("horizontalLayout_34") self.checkBox_pca_if_show_group_name_in_label = QtWidgets.QCheckBox(self.scrollAreaWidgetContents) @@ -1301,6 +1285,31 @@ def setupUi(self, metaX_main): self.spinBox_basic_plot_upset_max_rank.setObjectName("spinBox_basic_plot_upset_max_rank") self.horizontalLayout_105.addWidget(self.spinBox_basic_plot_upset_max_rank) self.gridLayout_34.addLayout(self.horizontalLayout_105, 5, 2, 1, 1) + self.horizontalLayout_108 = QtWidgets.QHBoxLayout() + self.horizontalLayout_108.setObjectName("horizontalLayout_108") + self.checkBox_box_plot_samples = QtWidgets.QCheckBox(self.scrollAreaWidgetContents) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.checkBox_box_plot_samples.sizePolicy().hasHeightForWidth()) + self.checkBox_box_plot_samples.setSizePolicy(sizePolicy) + self.checkBox_box_plot_samples.setObjectName("checkBox_box_plot_samples") + self.horizontalLayout_108.addWidget(self.checkBox_box_plot_samples) + self.checkBox_box_if_show_fliers = QtWidgets.QCheckBox(self.scrollAreaWidgetContents) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.checkBox_box_if_show_fliers.sizePolicy().hasHeightForWidth()) + self.checkBox_box_if_show_fliers.setSizePolicy(sizePolicy) + self.checkBox_box_if_show_fliers.setObjectName("checkBox_box_if_show_fliers") + self.horizontalLayout_108.addWidget(self.checkBox_box_if_show_fliers) + self.checkBox_box_log_scale = QtWidgets.QCheckBox(self.scrollAreaWidgetContents) + self.checkBox_box_log_scale.setObjectName("checkBox_box_log_scale") + self.horizontalLayout_108.addWidget(self.checkBox_box_log_scale) + self.gridLayout_34.addLayout(self.horizontalLayout_108, 6, 1, 1, 1) + self.checkBox_box_violinplot = QtWidgets.QCheckBox(self.scrollAreaWidgetContents) + self.checkBox_box_violinplot.setObjectName("checkBox_box_violinplot") + self.gridLayout_34.addWidget(self.checkBox_box_violinplot, 6, 2, 1, 1) self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.gridLayout_40.addWidget(self.scrollArea, 0, 0, 1, 1) self.gridLayout_26.addWidget(self.groupBox_basic_plot, 12, 0, 1, 3) @@ -1356,6 +1365,11 @@ def setupUi(self, metaX_main): self.gridLayout_23 = QtWidgets.QGridLayout(self.tab_13) self.gridLayout_23.setObjectName("gridLayout_23") self.label_32 = QtWidgets.QLabel(self.tab_13) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.label_32.sizePolicy().hasHeightForWidth()) + self.label_32.setSizePolicy(sizePolicy) self.label_32.setObjectName("label_32") self.gridLayout_23.addWidget(self.label_32, 5, 0, 1, 1) self.line_8 = QtWidgets.QFrame(self.tab_13) @@ -1378,7 +1392,7 @@ def setupUi(self, metaX_main): self.verticalLayout.setObjectName("verticalLayout") self.pushButton_basic_heatmap_drop_item = QtWidgets.QPushButton(self.tab_13) self.pushButton_basic_heatmap_drop_item.setEnabled(False) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.pushButton_basic_heatmap_drop_item.sizePolicy().hasHeightForWidth()) @@ -1387,7 +1401,7 @@ def setupUi(self, metaX_main): self.verticalLayout.addWidget(self.pushButton_basic_heatmap_drop_item) self.pushButton_basic_heatmap_clean_list = QtWidgets.QPushButton(self.tab_13) self.pushButton_basic_heatmap_clean_list.setEnabled(False) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.pushButton_basic_heatmap_clean_list.sizePolicy().hasHeightForWidth()) @@ -1396,7 +1410,7 @@ def setupUi(self, metaX_main): self.verticalLayout.addWidget(self.pushButton_basic_heatmap_clean_list) self.pushButton_basic_heatmap_add_a_list = QtWidgets.QPushButton(self.tab_13) self.pushButton_basic_heatmap_add_a_list.setEnabled(False) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.pushButton_basic_heatmap_add_a_list.sizePolicy().hasHeightForWidth()) @@ -1458,7 +1472,7 @@ def setupUi(self, metaX_main): self.horizontalLayout_29.addWidget(self.checkBox_basic_heatmap_top_filtered) self.gridLayout_23.addLayout(self.horizontalLayout_29, 6, 1, 1, 2) self.label_34 = QtWidgets.QLabel(self.tab_13) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Preferred) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_34.sizePolicy().hasHeightForWidth()) @@ -1601,7 +1615,7 @@ def setupUi(self, metaX_main): self.scrollArea_2.setWidgetResizable(True) self.scrollArea_2.setObjectName("scrollArea_2") self.scrollAreaWidgetContents_2 = QtWidgets.QWidget() - self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 885, 187)) + self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 885, 170)) self.scrollAreaWidgetContents_2.setObjectName("scrollAreaWidgetContents_2") self.gridLayout_50 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_2) self.gridLayout_50.setObjectName("gridLayout_50") @@ -3071,7 +3085,7 @@ def setupUi(self, metaX_main): self.scrollArea_3.setWidgetResizable(True) self.scrollArea_3.setObjectName("scrollArea_3") self.scrollAreaWidgetContents_4 = QtWidgets.QWidget() - self.scrollAreaWidgetContents_4.setGeometry(QtCore.QRect(0, 0, 865, 117)) + self.scrollAreaWidgetContents_4.setGeometry(QtCore.QRect(0, 0, 535, 94)) self.scrollAreaWidgetContents_4.setObjectName("scrollAreaWidgetContents_4") self.gridLayout_68 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_4) self.gridLayout_68.setObjectName("gridLayout_68") @@ -3372,7 +3386,7 @@ def setupUi(self, metaX_main): self.verticalLayout_2.setObjectName("verticalLayout_2") self.pushButton_co_expr_drop_item = QtWidgets.QPushButton(self.tab_5) self.pushButton_co_expr_drop_item.setEnabled(False) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.pushButton_co_expr_drop_item.sizePolicy().hasHeightForWidth()) @@ -3381,7 +3395,7 @@ def setupUi(self, metaX_main): self.verticalLayout_2.addWidget(self.pushButton_co_expr_drop_item) self.pushButton_co_expr_clean_list = QtWidgets.QPushButton(self.tab_5) self.pushButton_co_expr_clean_list.setEnabled(False) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.pushButton_co_expr_clean_list.sizePolicy().hasHeightForWidth()) @@ -3390,7 +3404,7 @@ def setupUi(self, metaX_main): self.verticalLayout_2.addWidget(self.pushButton_co_expr_clean_list) self.pushButton_co_expr_add_a_list = QtWidgets.QPushButton(self.tab_5) self.pushButton_co_expr_add_a_list.setEnabled(False) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.pushButton_co_expr_add_a_list.sizePolicy().hasHeightForWidth()) @@ -3468,7 +3482,7 @@ def setupUi(self, metaX_main): self.scrollArea_4.setWidgetResizable(True) self.scrollArea_4.setObjectName("scrollArea_4") self.scrollAreaWidgetContents_5 = QtWidgets.QWidget() - self.scrollAreaWidgetContents_5.setGeometry(QtCore.QRect(0, 0, 885, 168)) + self.scrollAreaWidgetContents_5.setGeometry(QtCore.QRect(0, 0, 885, 170)) self.scrollAreaWidgetContents_5.setObjectName("scrollAreaWidgetContents_5") self.gridLayout_49 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_5) self.gridLayout_49.setObjectName("gridLayout_49") @@ -3698,7 +3712,7 @@ def setupUi(self, metaX_main): self.horizontalLayout_41.addWidget(self.comboBox_co_expr_meta) self.gridLayout_47.addLayout(self.horizontalLayout_41, 0, 0, 1, 4) self.label_72 = QtWidgets.QLabel(self.tab_5) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_72.sizePolicy().hasHeightForWidth()) @@ -3803,21 +3817,13 @@ def setupUi(self, metaX_main): self.comboBox_trends_group_sample.addItem("") self.horizontalLayout_115.addWidget(self.comboBox_trends_group_sample) self.gridLayout_24.addLayout(self.horizontalLayout_115, 2, 0, 1, 1) - self.label_98 = QtWidgets.QLabel(self.tab_15) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.label_98.sizePolicy().hasHeightForWidth()) - self.label_98.setSizePolicy(sizePolicy) - self.label_98.setObjectName("label_98") - self.gridLayout_24.addWidget(self.label_98, 6, 0, 1, 1) self.line_18 = QtWidgets.QFrame(self.tab_15) self.line_18.setFrameShape(QtWidgets.QFrame.HLine) self.line_18.setFrameShadow(QtWidgets.QFrame.Sunken) self.line_18.setObjectName("line_18") self.gridLayout_24.addWidget(self.line_18, 1, 0, 1, 5) self.groupBox_expression_trends_plot_settings = QtWidgets.QGroupBox(self.tab_15) - self.groupBox_expression_trends_plot_settings.setMaximumSize(QtCore.QSize(16777215, 260)) + self.groupBox_expression_trends_plot_settings.setMaximumSize(QtCore.QSize(16777215, 250)) self.groupBox_expression_trends_plot_settings.setObjectName("groupBox_expression_trends_plot_settings") self.gridLayout_60 = QtWidgets.QGridLayout(self.groupBox_expression_trends_plot_settings) self.gridLayout_60.setObjectName("gridLayout_60") @@ -3825,7 +3831,7 @@ def setupUi(self, metaX_main): self.scrollArea_5.setWidgetResizable(True) self.scrollArea_5.setObjectName("scrollArea_5") self.scrollAreaWidgetContents_6 = QtWidgets.QWidget() - self.scrollAreaWidgetContents_6.setGeometry(QtCore.QRect(0, 0, 885, 119)) + self.scrollAreaWidgetContents_6.setGeometry(QtCore.QRect(0, 0, 885, 123)) self.scrollAreaWidgetContents_6.setObjectName("scrollAreaWidgetContents_6") self.gridLayout_57 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_6) self.gridLayout_57.setObjectName("gridLayout_57") @@ -3960,7 +3966,7 @@ def setupUi(self, metaX_main): self.gridLayout_60.addWidget(self.scrollArea_5, 0, 0, 1, 1) self.gridLayout_24.addWidget(self.groupBox_expression_trends_plot_settings, 10, 0, 1, 5) self.listWidget_trends_list_for_ploting = QtWidgets.QListWidget(self.tab_15) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.listWidget_trends_list_for_ploting.sizePolicy().hasHeightForWidth()) @@ -4061,42 +4067,17 @@ def setupUi(self, metaX_main): self.checkBox_trends_top_filtered.setObjectName("checkBox_trends_top_filtered") self.horizontalLayout_46.addWidget(self.checkBox_trends_top_filtered) self.gridLayout_24.addLayout(self.horizontalLayout_46, 5, 1, 1, 3) - self.verticalLayout_3 = QtWidgets.QVBoxLayout() - self.verticalLayout_3.setObjectName("verticalLayout_3") - self.pushButton_trends_drop_item = QtWidgets.QPushButton(self.tab_15) - self.pushButton_trends_drop_item.setEnabled(False) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pushButton_trends_drop_item.sizePolicy().hasHeightForWidth()) - self.pushButton_trends_drop_item.setSizePolicy(sizePolicy) - self.pushButton_trends_drop_item.setObjectName("pushButton_trends_drop_item") - self.verticalLayout_3.addWidget(self.pushButton_trends_drop_item) - self.pushButton_trends_clean_list = QtWidgets.QPushButton(self.tab_15) - self.pushButton_trends_clean_list.setEnabled(False) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pushButton_trends_clean_list.sizePolicy().hasHeightForWidth()) - self.pushButton_trends_clean_list.setSizePolicy(sizePolicy) - self.pushButton_trends_clean_list.setObjectName("pushButton_trends_clean_list") - self.verticalLayout_3.addWidget(self.pushButton_trends_clean_list) - self.pushButton_trends_add_a_list = QtWidgets.QPushButton(self.tab_15) - self.pushButton_trends_add_a_list.setEnabled(False) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pushButton_trends_add_a_list.sizePolicy().hasHeightForWidth()) - self.pushButton_trends_add_a_list.setSizePolicy(sizePolicy) - self.pushButton_trends_add_a_list.setObjectName("pushButton_trends_add_a_list") - self.verticalLayout_3.addWidget(self.pushButton_trends_add_a_list) - self.gridLayout_24.addLayout(self.verticalLayout_3, 7, 0, 1, 1) self.line_19 = QtWidgets.QFrame(self.tab_15) self.line_19.setFrameShape(QtWidgets.QFrame.HLine) self.line_19.setFrameShadow(QtWidgets.QFrame.Sunken) self.line_19.setObjectName("line_19") self.gridLayout_24.addWidget(self.line_19, 3, 0, 1, 5) self.label_100 = QtWidgets.QLabel(self.tab_15) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.label_100.sizePolicy().hasHeightForWidth()) + self.label_100.setSizePolicy(sizePolicy) self.label_100.setObjectName("label_100") self.gridLayout_24.addWidget(self.label_100, 4, 0, 1, 1) self.horizontalLayout_44 = QtWidgets.QHBoxLayout() @@ -4216,6 +4197,36 @@ def setupUi(self, metaX_main): self.line_31.setFrameShadow(QtWidgets.QFrame.Sunken) self.line_31.setObjectName("line_31") self.gridLayout_24.addWidget(self.line_31, 8, 0, 1, 5) + self.verticalLayout_3 = QtWidgets.QVBoxLayout() + self.verticalLayout_3.setObjectName("verticalLayout_3") + self.pushButton_trends_drop_item = QtWidgets.QPushButton(self.tab_15) + self.pushButton_trends_drop_item.setEnabled(False) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.pushButton_trends_drop_item.sizePolicy().hasHeightForWidth()) + self.pushButton_trends_drop_item.setSizePolicy(sizePolicy) + self.pushButton_trends_drop_item.setObjectName("pushButton_trends_drop_item") + self.verticalLayout_3.addWidget(self.pushButton_trends_drop_item) + self.pushButton_trends_clean_list = QtWidgets.QPushButton(self.tab_15) + self.pushButton_trends_clean_list.setEnabled(False) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.pushButton_trends_clean_list.sizePolicy().hasHeightForWidth()) + self.pushButton_trends_clean_list.setSizePolicy(sizePolicy) + self.pushButton_trends_clean_list.setObjectName("pushButton_trends_clean_list") + self.verticalLayout_3.addWidget(self.pushButton_trends_clean_list) + self.pushButton_trends_add_a_list = QtWidgets.QPushButton(self.tab_15) + self.pushButton_trends_add_a_list.setEnabled(False) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.pushButton_trends_add_a_list.sizePolicy().hasHeightForWidth()) + self.pushButton_trends_add_a_list.setSizePolicy(sizePolicy) + self.pushButton_trends_add_a_list.setObjectName("pushButton_trends_add_a_list") + self.verticalLayout_3.addWidget(self.pushButton_trends_add_a_list) + self.gridLayout_24.addLayout(self.verticalLayout_3, 6, 0, 2, 1) self.tabWidget.addTab(self.tab_15, "") self.gridLayout_12.addWidget(self.tabWidget, 0, 0, 1, 1) self.tabWidget_TaxaFuncAnalyzer.addTab(self.tab_diff_stats, "") @@ -4981,7 +4992,7 @@ def setupUi(self, metaX_main): self.scrollArea_7.setWidgetResizable(True) self.scrollArea_7.setObjectName("scrollArea_7") self.scrollAreaWidgetContents_8 = QtWidgets.QWidget() - self.scrollAreaWidgetContents_8.setGeometry(QtCore.QRect(0, 0, 885, 166)) + self.scrollAreaWidgetContents_8.setGeometry(QtCore.QRect(0, 0, 885, 158)) self.scrollAreaWidgetContents_8.setObjectName("scrollAreaWidgetContents_8") self.gridLayout_66 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_8) self.gridLayout_66.setObjectName("gridLayout_66") @@ -5597,7 +5608,7 @@ def setupUi(self, metaX_main): self.statusbar.setObjectName("statusbar") metaX_main.setStatusBar(self.statusbar) self.menuBar = QtWidgets.QMenuBar(metaX_main) - self.menuBar.setGeometry(QtCore.QRect(0, 0, 991, 23)) + self.menuBar.setGeometry(QtCore.QRect(0, 0, 991, 21)) self.menuBar.setObjectName("menuBar") self.menuTools = QtWidgets.QMenu(self.menuBar) self.menuTools.setObjectName("menuTools") @@ -5665,10 +5676,10 @@ def setupUi(self, metaX_main): self.stackedWidget.setCurrentIndex(0) self.tabWidget_TaxaFuncAnalyzer.setCurrentIndex(5) self.toolBox_2.setCurrentIndex(0) - self.tabWidget_4.setCurrentIndex(0) + self.tabWidget_4.setCurrentIndex(1) self.tabWidget_3.setCurrentIndex(0) self.tabWidget.setCurrentIndex(0) - self.tabWidget_2.setCurrentIndex(0) + self.tabWidget_2.setCurrentIndex(1) self.tabWidget_6.setCurrentIndex(0) self.toolBox_metalab_res_anno.setCurrentIndex(0) self.tabWidget_5.setCurrentIndex(0) @@ -5887,9 +5898,7 @@ def retranslateUi(self, metaX_main): self.label_160.setText(_translate("metaX_main", "Dot Size")) self.label_155.setText(_translate("metaX_main", "Counts Plot")) self.label_137.setText(_translate("metaX_main", "Sunburst")) - self.checkBox_box_if_show_fliers.setText(_translate("metaX_main", "show Fliers")) self.label_122.setText(_translate("metaX_main", "general")) - self.checkBox_box_plot_samples.setText(_translate("metaX_main", "Plot Samples")) self.checkBox_pca_if_show_group_name_in_label.setToolTip(_translate("metaX_main", "Add group name to Sample names")) self.checkBox_pca_if_show_group_name_in_label.setText(_translate("metaX_main", "Rename Samples")) self.checkBox_pca_if_show_lable.setToolTip(_translate("metaX_main", "Show label text in diagram")) @@ -5922,6 +5931,10 @@ def retranslateUi(self, metaX_main): self.checkBox_basic_plot_upset_show_percentage.setText(_translate("metaX_main", "Show Percentages")) self.label_206.setText(_translate("metaX_main", "Min Subset Size")) self.label_208.setText(_translate("metaX_main", "Max Rank")) + self.checkBox_box_plot_samples.setText(_translate("metaX_main", "Plot Samples")) + self.checkBox_box_if_show_fliers.setText(_translate("metaX_main", "show Fliers")) + self.checkBox_box_log_scale.setText(_translate("metaX_main", "Log Scale")) + self.checkBox_box_violinplot.setText(_translate("metaX_main", "Plot as Violinplot")) self.checkBox_basic_in_condtion.setText(_translate("metaX_main", "In Condition")) self.tabWidget_4.setTabText(self.tabWidget_4.indexOf(self.tab_12), _translate("metaX_main", "Basic Plot")) self.label_32.setText(_translate("metaX_main", "Select for plotting")) @@ -6175,7 +6188,7 @@ def retranslateUi(self, metaX_main): self.comboBox_co_expr_table.setItemText(2, _translate("metaX_main", "Taxa-Functions")) self.comboBox_co_expr_table.setItemText(3, _translate("metaX_main", "Peptides")) self.label_143.setText(_translate("metaX_main", "Meta")) - self.label_72.setText(_translate("metaX_main", "Focus List")) + self.label_72.setText(_translate("metaX_main", "Select Focus")) self.pushButton_co_expr_add_top.setToolTip(_translate("metaX_main", "Add conditionally filtered items to the drawing box")) self.pushButton_co_expr_add_top.setText(_translate("metaX_main", "Add Top to List")) self.pushButton_co_expr_plot.setText(_translate("metaX_main", "Plot Co-Expression Network")) @@ -6198,7 +6211,6 @@ def retranslateUi(self, metaX_main): self.label_215.setText(_translate("metaX_main", "Select")) self.comboBox_trends_group_sample.setItemText(0, _translate("metaX_main", "Group")) self.comboBox_trends_group_sample.setItemText(1, _translate("metaX_main", "Sample")) - self.label_98.setText(_translate("metaX_main", "List for Plotting")) self.groupBox_expression_trends_plot_settings.setTitle(_translate("metaX_main", "Plotting Parameter")) self.checkBox_trends_plot_interactive_rename_taxa.setText(_translate("metaX_main", "Simplify Taxa Names")) self.checkBox_trends_plot_interactive_plot_samples.setText(_translate("metaX_main", "Plot Samples")) @@ -6227,10 +6239,6 @@ def retranslateUi(self, metaX_main): self.comboBox_trends_top_by.setItemText(9, _translate("metaX_main", "Deseq2-up(log2FC)")) self.comboBox_trends_top_by.setItemText(10, _translate("metaX_main", "Deseq2-down(log2FC)")) self.checkBox_trends_top_filtered.setText(_translate("metaX_main", "Filter with threshold")) - self.pushButton_trends_drop_item.setText(_translate("metaX_main", "Drop Item")) - self.pushButton_trends_clean_list.setText(_translate("metaX_main", "Clean List")) - self.pushButton_trends_add_a_list.setToolTip(_translate("metaX_main", "Add a list to the drawing box, make sure there is one item per line.")) - self.pushButton_trends_add_a_list.setText(_translate("metaX_main", "Add A list")) self.label_100.setText(_translate("metaX_main", "Select for plotting")) self.label_96.setText(_translate("metaX_main", "Table")) self.comboBox_trends_table.setItemText(0, _translate("metaX_main", "Taxa")) @@ -6248,6 +6256,10 @@ def retranslateUi(self, metaX_main): self.pushButton_trends_plot_interactive_line.setText(_translate("metaX_main", "Plot Interactive Line")) self.label_145.setText(_translate("metaX_main", "Calculate Cluster")) self.checkBox_5.setText(_translate("metaX_main", "Show Plotting Parameter")) + self.pushButton_trends_drop_item.setText(_translate("metaX_main", "Drop Item")) + self.pushButton_trends_clean_list.setText(_translate("metaX_main", "Clean List")) + self.pushButton_trends_add_a_list.setToolTip(_translate("metaX_main", "Add a list to the drawing box, make sure there is one item per line.")) + self.pushButton_trends_add_a_list.setText(_translate("metaX_main", "Add A list")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_15), _translate("metaX_main", "Expression Trends")) self.tabWidget_TaxaFuncAnalyzer.setTabText(self.tabWidget_TaxaFuncAnalyzer.indexOf(self.tab_diff_stats), _translate("metaX_main", "Expression Analysis")) self.pushButton_others_plot_heatmap.setText(_translate("metaX_main", "Plot Heatmap")) diff --git a/metax/taxafunc_ploter/basic_plot.py b/metax/taxafunc_ploter/basic_plot.py index b64aa9f..86ba8ff 100644 --- a/metax/taxafunc_ploter/basic_plot.py +++ b/metax/taxafunc_ploter/basic_plot.py @@ -251,42 +251,41 @@ def plot_pca_sns(self, df, title_name = 'Table', show_label = True, plt.close('all') raise e - - def plot_box_sns(self, df, title_name = 'Table', show_fliers = False, width=10, height=8, - font_size = 10, theme:str|None = None, rename_sample:bool = False, - plot_samples:bool = False, legend_col_num: int | None = None, sub_meta:str|None = 'None'): + def plot_box_sns(self, df, title_name='Table', show_fliers=False, width=10, height=8, + font_size=10, theme: str | None = None, rename_sample: bool = False, + plot_samples: bool = False, legend_col_num: int | None = None, + sub_meta: str | None = 'None', violinplot: bool = False, log_scale: bool = False): - def create_df(self, df, sub_meta:str|None = 'None', plot_samples:bool = False): + def create_df(self, df, sub_meta: str | None = 'None', plot_samples: bool = False): df = df.copy() - # replace 0 with nan due to optimization of boxplot + # Replace 0 with NaN to optimize boxplot/violinplot visualization df = df.replace(0, np.nan) - + sample_list = df.columns - + group_list = [self.tfa.get_group_of_a_sample(sample) for sample in sample_list] - # get unique groups, and keep the order + # Get unique groups while preserving order group_order = [x for i, x in enumerate(group_list) if i == group_list.index(x)] - + group_map = {sample: self.tfa.get_group_of_a_sample(sample) for sample in sample_list} - + df = df.melt(var_name='Sample', value_name='Intensity') df['Group'] = df['Sample'].map(group_map) - + if plot_samples: - # resort the by sample_list + # Sort by sample_list df = df.sort_values(by='Sample', key=lambda x: x.map({v: i for i, v in enumerate(sample_list)})) else: if sub_meta not in ['None', None]: sub_group_map = {sample: self.tfa.get_group_of_a_sample(sample, sub_meta) for sample in sample_list} df['SubGroup'] = df['Sample'].map(sub_group_map) else: - df['SubGroup'] = df['Group'] # copy the group to sub group, avoid error - # resort the by group + df['SubGroup'] = df['Group'] # Copy group to SubGroup to avoid errors + # Sort by group df = df.sort_values(by='Group', key=lambda x: x.map({v: i for i, v in enumerate(group_order)})) - + return df - - + df = create_df(self, df, sub_meta, plot_samples) unique_groups = df['Group'].unique() if plot_samples else df['SubGroup'].unique() @@ -295,28 +294,43 @@ def create_df(self, df, sub_meta:str|None = 'None', plot_samples:bool = False): distinct_colors = self.get_distinct_colors(len(unique_groups)) color_palette = dict(zip(unique_groups, distinct_colors)) else: - # color_palette = dict(zip(unique_groups, sns.color_palette("deep", len(unique_groups)))) color_palette = None - # set style + # Set style if theme is not None and theme != 'Auto': plt.style.use(theme) else: custom_params = {"axes.spines.right": False, "axes.spines.top": False} sns.set_theme(style="ticks", rc=custom_params) - # set size + # Set size plt.figure(figsize=(width, height)) - ax = sns.boxplot( - data=df, - x="Sample" if plot_samples else "Group", - y="Intensity", - hue="Group" if sub_meta in ["None", None] or plot_samples else "SubGroup", - palette=color_palette, - showfliers=show_fliers, - legend=True, - ) - # set x label + plot_func = sns.violinplot if violinplot else sns.boxplot # Determine plot type + + # Prepare specific kwargs for violinplot + plot_kwargs = { + "data": df, + "x": "Sample" if plot_samples else "Group", + "y": "Intensity", + "hue": "Group" if sub_meta in ["None", None] or plot_samples else "SubGroup", + "palette": color_palette, + "legend": True, + "log_scale": log_scale, + } + if violinplot: + plot_kwargs.update({ + "cut": 0, + "linewidth": 1, + }) + else: # Boxplot + plot_kwargs.update({ + "showfliers": show_fliers, + }) + + # Plot + ax = plot_func(**plot_kwargs) + + # Set x-axis labels x_labels = ax.get_xticklabels() if rename_sample and plot_samples: for label in x_labels: @@ -326,34 +340,33 @@ def create_df(self, df, sub_meta:str|None = 'None', plot_samples:bool = False): ax.set_xticklabels(x_labels, rotation=90, horizontalalignment='right', fontsize=font_size) ax.set_xlabel('Sample' if plot_samples else 'Group', - fontsize=font_size+2) + fontsize=font_size + 2) + + ax.set_ylabel('Intensity', fontsize=font_size + 2) + plot_title = 'Violinplot' if violinplot else 'Boxplot' + ax.set_title(f'{plot_title} of Intensity of {title_name}', + fontsize=font_size + 2, fontweight='bold') - ax.set_ylabel('Intensity', fontsize=font_size+2) - ax.set_title(f'Boxplot of Intensity of {title_name}', - fontsize=font_size+2, fontweight='bold') - if legend_col_num != 0: - # set legend for group, out of the box - plt.legend(bbox_to_anchor=(1.02, 1), loc='upper left', borderaxespad=0., - fontsize=font_size+2, ncol= (len(unique_groups)//30 + 1 ) if legend_col_num is None else legend_col_num) - + # Set legend for groups outside the plot + plt.legend(bbox_to_anchor=(1.02, 1), loc='upper left', borderaxespad=0., + fontsize=font_size + 2, ncol=(len(unique_groups) // 30 + 1) if legend_col_num is None else legend_col_num) else: - #hide the legend - ax.legend([],[], frameon=False) - - # set line if sub_meta is not None + # Hide legend + ax.legend([], [], frameon=False) + + # Add vertical lines to separate groups if sub_meta is not None if sub_meta not in ['None', None] and not plot_samples: for i, group in enumerate(df['Group'].unique()): if i != 0: ax.axvline(i - 0.5, linestyle='--', linewidth=1, color='grey', alpha=0.8) - - # set grid line for y axis is visible + + # Set grid line for y-axis ax.grid(True, axis='y') - # move the botton up + # Adjust layout plt.subplots_adjust(bottom=0.2) plt.tight_layout() plt.show() - # plt.close() return ax def plot_corr_sns( diff --git a/metax/utils/version.py b/metax/utils/version.py index 35786cc..3dce8db 100644 --- a/metax/utils/version.py +++ b/metax/utils/version.py @@ -1,2 +1,2 @@ -__version__ = '1.119.3' +__version__ = '1.119.4' API_version = '4' \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index d884910..896d1e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "MetaXTools" -version = "1.119.3" +version = "1.119.4" description = "MetaXTools is a novel tool for linking peptide sequences with taxonomic and functional information in Metaproteomics." readme = "README_PyPi.md" license = { text = "NorthOmics" }