Skip to content

Commit

Permalink
- New: 1. Added an option to calculate the mean by the domainat value…
Browse files Browse the repository at this point in the history
… in eache group for plot_mean parameter in DEV Settings. 2. Added a statistics bar plot for basic plot part. 3. Added a attributes table of Taxa-Function result.

- Fix: Fixed the bug of calculating the Functional Redundancy in the T-Test and ANOVA part.
  • Loading branch information
byemaxx committed Nov 5, 2024
1 parent e076ceb commit 18c068e
Show file tree
Hide file tree
Showing 15 changed files with 381 additions and 163 deletions.
7 changes: 7 additions & 0 deletions Docs/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Version: 1.117.1
## Date: 2024-11-5
### Changes:
- New: 1. Added an option to calculate the mean by the domainat value in eache group for plot_mean parameter in DEV Settings. 2. Added a statistics bar plot for basic plot part. 3. Added a attributes table of Taxa-Function result.
- Fix: Fixed the bug of calculating the Functional Redundancy in the T-Test and ANOVA part.


# Version: 1.117.0
## Date: 2024-10-31
### Changes:
Expand Down
47 changes: 33 additions & 14 deletions metax/gui/main_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
from metax.taxafunc_ploter.volcano_plot_js import VolcanoPlotJS
from metax.taxafunc_ploter.volcano_plot import VolcanoPlot
from metax.taxafunc_ploter.tukey_plot import TukeyPlot
from metax.taxafunc_ploter.bar_plot_js import BarPlot_js
from metax.taxafunc_ploter.bar_plot_js import BarPlot
from metax.taxafunc_ploter.sankey_plot import SankeyPlot
from metax.taxafunc_ploter.network_plot import NetworkPlot
from metax.taxafunc_ploter.trends_plot import TrendsPlot
Expand Down Expand Up @@ -110,7 +110,7 @@
from ..taxafunc_ploter.volcano_plot_js import VolcanoPlotJS
from ..taxafunc_ploter.volcano_plot import VolcanoPlot
from ..taxafunc_ploter.tukey_plot import TukeyPlot
from ..taxafunc_ploter.bar_plot_js import BarPlot_js
from ..taxafunc_ploter.bar_plot_js import BarPlot
from ..taxafunc_ploter.sankey_plot import SankeyPlot
from ..taxafunc_ploter.network_plot import NetworkPlot
from ..taxafunc_ploter.trends_plot import TrendsPlot
Expand Down Expand Up @@ -733,6 +733,7 @@ def show_settings_window(self):
settings_widget.heatmap_params_dict_changed.connect(self.on_heatmap_params_changed)
settings_widget.tf_link_net_params_dict_changed.connect(self.on_tf_link_net_params_changed)
settings_widget.html_theme_changed.connect(self.on_html_theme_changed)
settings_widget.stat_mean_by_zero_dominant_changed.connect(self.on_stat_mean_by_zero_dominant_changed)
# Other settings
settings_widget.protein_infer_method_changed.connect(self.on_protein_infer_method_changed)

Expand Down Expand Up @@ -764,6 +765,15 @@ def on_tf_link_net_params_changed(self, params_dict):
def on_html_theme_changed(self, theme):
self.html_theme = theme
print(f"HTML theme changed to: {theme}")

def on_stat_mean_by_zero_dominant_changed(self, mode):
# chcek if self.tfa exists
if not hasattr(self, 'tfa'):
print("Please load the data first.")
return

self.tfa.stat_mean_by_zero_dominant = mode
print(f"Stat mean by zero dominant changed to: {mode}")

def on_protein_infer_method_changed(self, method):
#save to settings
Expand Down Expand Up @@ -3639,9 +3649,8 @@ def plot_basic_list(self, plot_type='heatmap'):
plot_percent = self.checkBox_basic_bar_plot_percent.isChecked()
sub_meta = self.comboBox_3dbar_sub_meta.currentText()
use_3d_for_sub_meta = self.checkBox_basic_bar_3d_for_sub_meta.isChecked()
js_bar = self.checkBox_basic_bar_interactive_js.isChecked()

width = width*100
height = height*100
df = df.loc[(df!=0).any(axis=1)]
if len(df) > 100:
reply = QMessageBox.question(self.MainWindow, 'Warning',
Expand All @@ -3650,14 +3659,23 @@ def plot_basic_list(self, plot_type='heatmap'):
if reply == QMessageBox.No:
return None
self.show_message(f'Plotting {plot_type}...')
pic = BarPlot_js(self.tfa, theme=self.html_theme).plot_intensity_bar(df = df, width=width, height=height,
title= '', rename_taxa=rename_taxa,
show_legend=show_legend, font_size=font_size,
rename_sample=rename_sample, plot_mean = plot_mean,
plot_percent = plot_percent, sub_meta = sub_meta,
show_all_labels = show_all_labels, use_3d = use_3d_for_sub_meta)

self.save_and_show_js_plot(pic, title)
if js_bar:
width = width*100
height = height*100
pic = BarPlot(self.tfa, theme=self.html_theme).plot_intensity_bar_js(df = df, width=width, height=height,
title= '', rename_taxa=rename_taxa,
show_legend=show_legend, font_size=font_size,
rename_sample=rename_sample, plot_mean = plot_mean,
plot_percent = plot_percent, sub_meta = sub_meta,
show_all_labels = show_all_labels, use_3d = use_3d_for_sub_meta)

self.save_and_show_js_plot(pic, title)
else:
ax = BarPlot(self.tfa, theme=self.html_theme).plot_intensity_bar_sns(df = df, width=width, height=height,
title= '', rename_taxa=rename_taxa,
show_legend=show_legend, font_size=font_size,
rename_sample=rename_sample, plot_mean = plot_mean,
plot_percent = plot_percent, sub_meta = sub_meta)

elif plot_type == 'get_table':
self.show_message('Getting table...')
Expand Down Expand Up @@ -5413,7 +5431,7 @@ def plot_network(self):
try:
self.show_message('Plotting network...')
list_only_no_link = self.checkBox_tf_link_net_plot_list_only_no_link.isChecked()
pic, network_df = NetworkPlot(
pic, network_df, attributes_df = NetworkPlot(
self.tfa,
show_labels=show_labels,
rename_taxa=rename_taxa,
Expand All @@ -5430,6 +5448,7 @@ def plot_network(self):
)
self.save_and_show_js_plot(pic, 'taxa-func link Network')
self.update_table_dict('taxa-func_network', network_df)
self.update_table_dict('taxa-func_network_attributes', attributes_df)

except Exception as e:
error_message = traceback.format_exc()
Expand Down Expand Up @@ -5682,7 +5701,7 @@ def plot_tflink_bar(self):
params['sub_meta'] = sub_meta

self.show_message('Plotting bar plot, please wait...')
pic = BarPlot_js(self.tfa, theme=self.html_theme).plot_intensity_bar(**params)
pic = BarPlot(self.tfa, theme=self.html_theme).plot_intensity_bar_js(**params)
self.save_and_show_js_plot(pic, 'Intensity Bar Plot')


Expand Down
72 changes: 43 additions & 29 deletions metax/gui/metax_gui/main_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1122</width>
<height>755</height>
<height>816</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -245,8 +245,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>528</width>
<height>534</height>
<width>391</width>
<height>80</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -1882,7 +1882,7 @@
<string>Show Labels</string>
</property>
<property name="checked">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>
Expand Down Expand Up @@ -2789,8 +2789,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>621</width>
<height>150</height>
<width>1016</width>
<height>184</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_50">
Expand Down Expand Up @@ -3004,22 +3004,6 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="checkBox_basic_bar_show_legend">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Show Legend</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="checkBox_basic_heatmap_sankey_title">
<property name="sizePolicy">
Expand Down Expand Up @@ -3280,6 +3264,36 @@
</property>
</widget>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_104">
<item>
<widget class="QCheckBox" name="checkBox_basic_bar_interactive_js">
<property name="text">
<string>Interactive Bar</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_basic_bar_show_legend">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Show Legend</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
Expand Down Expand Up @@ -3792,7 +3806,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1020</width>
<width>878</width>
<height>128</height>
</rect>
</property>
Expand Down Expand Up @@ -7467,8 +7481,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1016</width>
<height>105</height>
<width>620</width>
<height>65</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_57">
Expand Down Expand Up @@ -9288,8 +9302,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1016</width>
<height>141</height>
<width>383</width>
<height>68</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_66">
Expand Down Expand Up @@ -9785,8 +9799,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1044</width>
<height>493</height>
<width>313</width>
<height>41</height>
</rect>
</property>
<attribute name="label">
Expand Down
86 changes: 52 additions & 34 deletions metax/gui/metax_gui/setting_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@
<string>Plotting</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="2" column="0">
<widget class="QLabel" name="label_21">
<item row="5" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>HTML Global</string>
<string>Taxa-Functions Link Network</string>
</property>
</widget>
</item>
<item row="3" column="3">
<item row="4" column="3">
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QLabel" name="label_11">
Expand Down Expand Up @@ -325,32 +325,7 @@
</item>
</layout>
</item>
<item row="2" column="3">
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="label_22">
<property name="text">
<string>Theme</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox_html_theme">
<item>
<property name="text">
<string>white</string>
</property>
</item>
<item>
<property name="text">
<string>dark</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="4" column="3">
<item row="5" column="3">
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QLabel" name="label_5">
Expand Down Expand Up @@ -516,10 +491,10 @@
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<item row="3" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Taxa-Functions Link Network</string>
<string>HTML Global</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -699,20 +674,63 @@
</item>
</layout>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Network Global</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_27">
<property name="text">
<string>Plot Mean</string>
</property>
</widget>
</item>
<item row="3" column="3">
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="label_22">
<property name="text">
<string>Theme</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox_html_theme">
<item>
<property name="text">
<string>white</string>
</property>
</item>
<item>
<property name="text">
<string>dark</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>HeatMap</string>
</property>
</widget>
</item>
<item row="2" column="3">
<layout class="QGridLayout" name="gridLayout_12">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox_stat_mean_by_zero_dominant">
<property name="text">
<string>Calculate Non-Zero Mean (Return 0 if Zeros &gt; 50%) for Each Group</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_3">
Expand Down
Loading

0 comments on commit 18c068e

Please sign in to comment.