Skip to content

Commit

Permalink
- Fix: 1. Fixed the group order was not correct in the title of the v…
Browse files Browse the repository at this point in the history
…olcano plot. 2. col scale bug when plot the basic heatmap.

- Change: 1. Enable alpha/beta divversity for all type of tables. 2. Only asiign peptide to one protein rather than sahre the intensity when sum peptide to protein by razor method.
  • Loading branch information
byemaxx committed Aug 12, 2024
1 parent 4322dee commit 3cccd4e
Show file tree
Hide file tree
Showing 13 changed files with 336 additions and 65 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.110.0
## Date: 2024-08-12
### Changes:
- Fix: 1. Fixed the group order was not correct in the title of the volcano plot. 2. col scale bug when plot the basic heatmap.
- Change: 1. Enable alpha/beta divversity for all type of tables. 2. Only asiign peptide to one protein rather than sahre the intensity when sum peptide to protein by razor method.


# Version: 1.109.12
## Date: 2024-08-10
### Changes:
Expand Down
22 changes: 14 additions & 8 deletions metax/gui/main_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,11 @@ def get_list_by_df_type(self, df_type:str, remove_no_linked:bool=False, silent:b
return res_list

def change_event_checkBox_basic_plot_table(self):
taxa_only_button_list = [self.pushButton_plot_alpha_div, self.pushButton_plot_beta_div,
self.pushButton_plot_sunburst, self.pushButton_plot_basic_treemap]
taxa_only_button_list = [
# self.pushButton_plot_alpha_div,
# self.pushButton_plot_beta_div,
self.pushButton_plot_sunburst,
self.pushButton_plot_basic_treemap]

taxa_func_button_list = [self.pushButton_plot_basic_sankey]

Expand Down Expand Up @@ -2984,6 +2987,8 @@ def enable_multi_button(self, state=True):
self.pushButton_trends_clean_list,
self.comboBox_trends_table,
self.pushButton_plot_pca_js,
self.pushButton_plot_alpha_div,
self.pushButton_plot_beta_div,
self.pushButton_trends_add_a_list,
self.pushButton_co_expr_add_a_list,
self.pushButton_basic_heatmap_add_a_list,
Expand Down Expand Up @@ -4217,8 +4222,9 @@ def get_title_by_table_name(self, table_name):
width=width, height=height, font_size=font_size,
plot_all_samples=plot_all_samples, theme=theme,
sub_meta = sub_meta, show_fliers = show_fliers,
legend_col_num=legend_col_num, rename_sample = rename_sample)
self.update_table_dict('alpha_diversity', aplha_diversity_df)
legend_col_num=legend_col_num, rename_sample = rename_sample,
df_type=table_name, title_name=title_name)
self.update_table_dict(f'alpha_diversity({title_name})', aplha_diversity_df)
elif method == "beta_div":
self.show_message('Beta diversity is running, please wait...')
metric = self.comboBox_beta_div_method.currentText()
Expand All @@ -4227,8 +4233,8 @@ def get_title_by_table_name(self, table_name):
rename_sample = rename_sample,
show_label = show_label, adjust_label = adjust_label,
theme=theme,sub_meta = sub_meta, legend_col_num=legend_col_num,
dot_size = dot_size)
self.update_table_dict('beta_diversity_distance_matrix', beta_diversity_distance_matrix)
dot_size = dot_size, df_type=table_name, title_name=title_name)
self.update_table_dict(f'beta_diversity_distance_matrix({title_name})', beta_diversity_distance_matrix)


elif method == 'sunburst':
Expand Down Expand Up @@ -4926,7 +4932,7 @@ def plot_deseq2_volcano(self):
height = self.spinBox_fc_plot_height.value()
group1 = self.comboBox_deseq2_group1.currentText()
group2 = self.comboBox_deseq2_group2.currentText()
title_name = f'{group1} vs {group2} of {table_name.split("(")[1].split(")")[0]}'
title_name = f'{group2} vs {group1} of {table_name.split("(")[1].split(")")[0]}'
font_size = self.spinBox_deseq2_font_size.value()
dot_size = self.spinBox_deseq2_dot_size.value()
plot_js = self.checkBox_deseq2_js_volcano.isChecked()
Expand Down Expand Up @@ -5085,7 +5091,7 @@ def deseq2_plot_sankey(self):
return None
try:
df = self.table_dict[table_name]
title_name = f'{group1} vs {group2} of {table_name.split("(")[1].split(")")[0]}'
title_name = f'{group2} vs {group1} of {table_name.split("(")[1].split(")")[0]}'

pic = SankeyPlot(self.tfa, theme=self.html_theme).plot_fc_sankey(df, width=width, height=height, pvalue=pvalue, p_type = p_type,
log2fc_min=log2fc_min, log2fc_max=log2fc_max, title =title_name, font_size=font_size)
Expand Down
34 changes: 17 additions & 17 deletions metax/gui/metax_gui/main_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<enum>Qt::LeftToRight</enum>
</property>
<property name="currentIndex">
<number>4</number>
<number>3</number>
</property>
<property name="documentMode">
<bool>false</bool>
Expand Down Expand Up @@ -245,8 +245,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>528</width>
<height>573</height>
<width>391</width>
<height>80</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -1400,7 +1400,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1016</width>
<width>660</width>
<height>232</height>
</rect>
</property>
Expand Down Expand Up @@ -2672,7 +2672,7 @@
<x>0</x>
<y>0</y>
<width>1016</width>
<height>162</height>
<height>158</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_50">
Expand Down Expand Up @@ -2808,7 +2808,7 @@
</item>
<item>
<property name="text">
<string>column</string>
<string>col</string>
</property>
</item>
<item>
Expand Down Expand Up @@ -3674,7 +3674,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1003</width>
<width>1020</width>
<height>126</height>
</rect>
</property>
Expand Down Expand Up @@ -5543,7 +5543,7 @@
<x>0</x>
<y>0</y>
<width>996</width>
<height>146</height>
<height>140</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_68">
Expand Down Expand Up @@ -6093,8 +6093,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1016</width>
<height>181</height>
<width>493</width>
<height>128</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_49">
Expand Down Expand Up @@ -7323,8 +7323,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1016</width>
<height>144</height>
<width>538</width>
<height>63</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_57">
Expand Down Expand Up @@ -8171,8 +8171,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1016</width>
<height>185</height>
<width>775</width>
<height>102</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_69">
Expand Down Expand Up @@ -9091,8 +9091,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1016</width>
<height>168</height>
<width>383</width>
<height>68</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_66">
Expand Down Expand Up @@ -10086,7 +10086,7 @@
<x>0</x>
<y>0</y>
<width>1122</width>
<height>21</height>
<height>23</height>
</rect>
</property>
<widget class="QMenu" name="menuTools">
Expand Down
26 changes: 13 additions & 13 deletions metax/gui/metax_gui/ui_main_window.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'c:\Users\Qing\OneDrive - University of Ottawa\code\TaxaFunc\MetaX\metax\gui\metax_gui\main_window.ui'
# Form implementation generated from reading ui file 'c:\Users\max\OneDrive - University of Ottawa\code\TaxaFunc\MetaX\metax\gui\metax_gui\main_window.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
Expand Down Expand Up @@ -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, 528, 573))
self.page_2.setGeometry(QtCore.QRect(0, 0, 391, 80))
self.page_2.setObjectName("page_2")
self.gridLayout_27 = QtWidgets.QGridLayout(self.page_2)
self.gridLayout_27.setObjectName("gridLayout_27")
Expand Down Expand Up @@ -706,7 +706,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, 1016, 232))
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 660, 232))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.gridLayout_34 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents)
self.gridLayout_34.setObjectName("gridLayout_34")
Expand Down Expand Up @@ -1370,7 +1370,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, 1016, 162))
self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 1016, 158))
self.scrollAreaWidgetContents_2.setObjectName("scrollAreaWidgetContents_2")
self.gridLayout_50 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_2)
self.gridLayout_50.setObjectName("gridLayout_50")
Expand Down Expand Up @@ -1919,7 +1919,7 @@ def setupUi(self, metaX_main):
self.scrollArea_cross_heatmap_settings.setWidgetResizable(True)
self.scrollArea_cross_heatmap_settings.setObjectName("scrollArea_cross_heatmap_settings")
self.scrollAreaWidgetContents_3 = QtWidgets.QWidget()
self.scrollAreaWidgetContents_3.setGeometry(QtCore.QRect(0, 0, 1003, 126))
self.scrollAreaWidgetContents_3.setGeometry(QtCore.QRect(0, 0, 1020, 126))
self.scrollAreaWidgetContents_3.setObjectName("scrollAreaWidgetContents_3")
self.gridLayout_38 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_3)
self.gridLayout_38.setObjectName("gridLayout_38")
Expand Down Expand Up @@ -2844,7 +2844,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, 996, 146))
self.scrollAreaWidgetContents_4.setGeometry(QtCore.QRect(0, 0, 996, 140))
self.scrollAreaWidgetContents_4.setObjectName("scrollAreaWidgetContents_4")
self.gridLayout_68 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_4)
self.gridLayout_68.setObjectName("gridLayout_68")
Expand Down Expand Up @@ -3145,7 +3145,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, 1016, 181))
self.scrollAreaWidgetContents_5.setGeometry(QtCore.QRect(0, 0, 493, 128))
self.scrollAreaWidgetContents_5.setObjectName("scrollAreaWidgetContents_5")
self.gridLayout_49 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_5)
self.gridLayout_49.setObjectName("gridLayout_49")
Expand Down Expand Up @@ -3790,7 +3790,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, 1016, 144))
self.scrollAreaWidgetContents_6.setGeometry(QtCore.QRect(0, 0, 538, 63))
self.scrollAreaWidgetContents_6.setObjectName("scrollAreaWidgetContents_6")
self.gridLayout_57 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_6)
self.gridLayout_57.setObjectName("gridLayout_57")
Expand Down Expand Up @@ -4261,7 +4261,7 @@ def setupUi(self, metaX_main):
self.scrollArea_6.setWidgetResizable(True)
self.scrollArea_6.setObjectName("scrollArea_6")
self.scrollAreaWidgetContents_7 = QtWidgets.QWidget()
self.scrollAreaWidgetContents_7.setGeometry(QtCore.QRect(0, 0, 1016, 185))
self.scrollAreaWidgetContents_7.setGeometry(QtCore.QRect(0, 0, 775, 102))
self.scrollAreaWidgetContents_7.setObjectName("scrollAreaWidgetContents_7")
self.gridLayout_69 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_7)
self.gridLayout_69.setObjectName("gridLayout_69")
Expand Down Expand Up @@ -4765,7 +4765,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, 1016, 168))
self.scrollAreaWidgetContents_8.setGeometry(QtCore.QRect(0, 0, 383, 68))
self.scrollAreaWidgetContents_8.setObjectName("scrollAreaWidgetContents_8")
self.gridLayout_66 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_8)
self.gridLayout_66.setObjectName("gridLayout_66")
Expand Down Expand Up @@ -5276,7 +5276,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, 1122, 21))
self.menuBar.setGeometry(QtCore.QRect(0, 0, 1122, 23))
self.menuBar.setObjectName("menuBar")
self.menuTools = QtWidgets.QMenu(self.menuBar)
self.menuTools.setObjectName("menuTools")
Expand Down Expand Up @@ -5336,7 +5336,7 @@ def setupUi(self, metaX_main):

self.retranslateUi(metaX_main)
self.stackedWidget.setCurrentIndex(0)
self.tabWidget_TaxaFuncAnalyzer.setCurrentIndex(4)
self.tabWidget_TaxaFuncAnalyzer.setCurrentIndex(3)
self.toolBox_2.setCurrentIndex(0)
self.tabWidget_4.setCurrentIndex(1)
self.tabWidget_3.setCurrentIndex(3)
Expand Down Expand Up @@ -5616,7 +5616,7 @@ def retranslateUi(self, metaX_main):
self.label_186.setText(_translate("metaX_main", "Sankey"))
self.label_31.setText(_translate("metaX_main", "Scale"))
self.comboBox_basic_hetatmap_scale.setItemText(0, _translate("metaX_main", "row"))
self.comboBox_basic_hetatmap_scale.setItemText(1, _translate("metaX_main", "column"))
self.comboBox_basic_hetatmap_scale.setItemText(1, _translate("metaX_main", "col"))
self.comboBox_basic_hetatmap_scale.setItemText(2, _translate("metaX_main", "all"))
self.comboBox_basic_hetatmap_scale.setItemText(3, _translate("metaX_main", "None"))
self.label_13.setText(_translate("metaX_main", "Theme"))
Expand Down
16 changes: 11 additions & 5 deletions metax/peptide_annotator/convert_id_to_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,18 @@ def lookup_and_join(ec_nums, column_name):
print("Add EC columns to df successfully!")
return df

def add_pathway_name_to_df(df: pd.DataFrame) -> pd.DataFrame:
def query_kegg(id_str, pathway_dict):
def add_pathway_name_to_df(df: pd.DataFrame, kppe_id:bool = False) -> pd.DataFrame:
def query_kegg(id_str, pathway_dict, kppe_id=False):
id_list = id_str.split(',')
if id_list[0] == 'not_found':
return 'not_found'
pathway_list = []
for id in id_list:
if id in pathway_dict:
pathway_list.append(pathway_dict[id])
if kppe_id:
pathway_list.append(f'{id}:{pathway_dict[id]}')
else:
pathway_list.append(pathway_dict[id])
# remove duplicates
pathway_list = list(dict.fromkeys(pathway_list))
if len(pathway_list) == 0:
Expand All @@ -199,9 +202,12 @@ def query_kegg(id_str, pathway_dict):
if 'KEGG_Pathway' not in df.columns:
print('KEGG_Pathway column does not exist!, return the original dataframe')
return df

#! fill the missing pathway names if necessary
# df['KEGG_Pathway'] = df['KEGG_Pathway'].fillna('not_found')

pathway_dict = get_pathway_dict()
df.loc[:, 'KEGG_Pathway_name'] = df['KEGG_Pathway'].apply(lambda x: query_kegg(x, pathway_dict))
df.loc[:, 'KEGG_Pathway_name'] = df['KEGG_Pathway'].apply(lambda x: query_kegg(x, pathway_dict, kppe_id))
df.loc[:, 'KEGG_Pathway_name_prop'] = df['KEGG_Pathway_prop']
print("Add KEGG_Pathway_name to df successfully!")
return df
Expand Down Expand Up @@ -250,7 +256,7 @@ def query_ko(id_str, ko_dict):
# if __name__ == '__main__':
# df_path = "MetaX/data/example_data/Example_OTF.tsv"
# df = pd.read_csv(df_path, sep='\t')
# df = add_pathway_name_to_df(df)
# df = add_pathway_name_to_df(df, kppe_id=True)
# df = add_ec_name_to_df(df)
# df = add_ko_name_to_df(df)
# df.to_csv("11.tsv", sep='\t', index=False)
1 change: 1 addition & 0 deletions metax/taxafunc_analyzer/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ def get_df(self, table_name:str = 'taxa'):
"proteins": "protein_df",

}
table_name = table_name.lower()
dft = getattr(self, name_dict[table_name])
# remove peptide_num column if exists
if "peptide_num" in dft.columns:
Expand Down
Loading

0 comments on commit 3cccd4e

Please sign in to comment.