diff --git a/Docs/ChangeLog.md b/Docs/ChangeLog.md index 9fdf39e..9268d2a 100644 --- a/Docs/ChangeLog.md +++ b/Docs/ChangeLog.md @@ -1,3 +1,9 @@ +# Version: 1.107.3 +## Date: 2024-06-16 +### Changes: +- Change: Co-expression Network plot: hide the dots if no edge connected to it. + + # Version: 1.107.2 ## Date: 2024-06-16 ### Changes: diff --git a/Docs/MetaX_Cookbook.assets/co_network_pic.png b/Docs/MetaX_Cookbook.assets/co_network_pic.png index 53eb138..c979318 100644 Binary files a/Docs/MetaX_Cookbook.assets/co_network_pic.png and b/Docs/MetaX_Cookbook.assets/co_network_pic.png differ diff --git a/Docs/MetaX_Cookbook.md b/Docs/MetaX_Cookbook.md index 2b909f4..341293e 100644 --- a/Docs/MetaX_Cookbook.md +++ b/Docs/MetaX_Cookbook.md @@ -29,115 +29,110 @@ Visit **Github** to get more information: main_window -- Click 'Tools Menu' to switch different tool +- Click 'Tools Menu' to switch **different modules** tools_menu -# Module 1. Database Builder +
-**NOTE:** the result of **MetaLab v2.3** MaxQuant workflow do not need Build Database. However, we do not recommend the result files from this version of MetaLab as input to MetaX, and large amounts of Peptide may be discarded. +# Preparing Your Data +## Module 1. Database Builder +**Note:** The results from **MetaLab v2.3** MaxQuant workflow do not require database building. However, we do not recommend using these results as input to MetaX, as many peptides may be discarded. -- You have to build the database for **the first time** using Database Builder. +- Build the database for the **first time** using the Database Builder. - **(Option 1) Build Database By MGnify Data** + **Option 1: Build Database Using MGnify Data** - Make sure to download the correct database type corresponding to your data + Ensure you download the correct database type corresponding to your data. - - -dbbuilder - -**(Option 2) Build Database By Own Data** + ![dbbuilder](./MetaX_Cookbook.assets/dbbuilder.png) -+ (1). **Annotation Table:** a TSV table(separated by a tab), and make sure the first column is protein name joined Genome by "_", e.g. "Genome1_protein1" and other columns are annotation information. + **Option 2: Build Database Using Own Data** -dbbuilder_own + 1. **Annotation Table:** A TSV table (tab-separated), with the first column as protein name joined with Genome by "_", e.g., "Genome1_protein1", and other columns containing annotation information. -- (2). **Taxa Table:** a TSV table(separated by a tab), and make sure the first column is Genome name,e.g. "Genome1" and the second column is taxa. - - **Example Annotation Table:** + ![dbbuilder_own](./MetaX_Cookbook.assets/dbbuilder_own.png) - | Query | Preferred_name | EC | KEGG_ko | - | ------------------- | -------------- | ----------------- | ------------------- | - | MGYG000000001_00696 | mfd | - | ko:K03723 | - | MGYG000000001_02838 | hxlR | - | - | - | MGYG000000001_01674 | ispG | 1.17.7.1,1.17.7.3 | ko:K03526 | - | MGYG000000001_02710 | glsA | 3.5.1.2 | ko:K01425 | - | MGYG000000001_01356 | mutS2 | - | ko:K07456 | - | MGYG000000001_02630 | - | - | - | - | MGYG000000001_02418 | ackA | 2.7.2.1 | ko:K00925 | - | MGYG000000001_00728 | atpA | 3.6.3.14 | ko:K02111 | - | MGYG000000001_00695 | pth | 3.1.1.29 | ko:K01056 | - | MGYG000000001_02907 | - | - | ko:K03086 | - | MGYG000000001_02592 | rplC | - | ko:K02906 | - | MGYG000000001_00137 | - | - | ko:K03480,ko:K03488 | + 2. **Taxa Table:** A TSV table (tab-separated), with the first column as Genome name, e.g., "Genome1", and the second column as taxa. - - **Example Taxa Table:** + **Example Annotation Table:** - | Genome | Lineage | - | ------------- | ------------------------------------------------------------ | - | MGYG000000001 | d_Bacteria;p_Firmicutes_A;c_Clostridia;o_Peptostreptococcales;f_Peptostreptococcaceae;g_GCA-900066495;s_GCA-900066495 sp902362365 | - | MGYG000000002 | d_Bacteria;p_Firmicutes_A;c_Clostridia;o_Lachnospirales;f_Lachnospiraceae;g_Blautia_A;s_Blautia_A faecis | - | MGYG000000003 | d_Bacteria;p_Bacteroidota;c_Bacteroidia;o_Bacteroidales;f_Rikenellaceae;g_Alistipes;s_Alistipes shahii | - | MGYG000000004 | d_Bacteria;p_Firmicutes_A;c_Clostridia;o_Oscillospirales;f_Ruminococcaceae;g_Anaerotruncus;s_Anaerotruncus colihominis | - | MGYG000000005 | d_Bacteria;p_Firmicutes_A;c_Clostridia;o_Peptostreptococcales;f_Peptostreptococcaceae;g_Terrisporobacter;s_Terrisporobacter glycolicus_A | - | MGYG000000006 | d_Bacteria;p_Firmicutes;c_Bacilli;o_Staphylococcales;f_Staphylococcaceae;g_Staphylococcus;s_Staphylococcus xylosus | - | MGYG000000007 | d_Bacteria;p_Firmicutes;c_Bacilli;o_Lactobacillales;f_Lactobacillaceae;g_Lactobacillus;s_Lactobacillus intestinalis | - | MGYG000000008 | d_Bacteria;p_Firmicutes;c_Bacilli;o_Lactobacillales;f_Lactobacillaceae;g_Lactobacillus;s_Lactobacillus johnsonii | - | MGYG000000009 | d_Bacteria;p_Firmicutes;c_Bacilli;o_Lactobacillales;f_Lactobacillaceae;g_Ligilactobacillus;s_Ligilactobacillus murinus | + | Query | Preferred_name | EC | KEGG_ko | + | ------------------- | -------------- | ----------------- | ------------------- | + | MGYG000000001_00696 | mfd | - | ko:K03723 | + | MGYG000000001_02838 | hxlR | - | - | + | MGYG000000001_01674 | ispG | 1.17.7.1,1.17.7.3 | ko:K03526 | + | MGYG000000001_02710 | glsA | 3.5.1.2 | ko:K01425 | + | MGYG000000001_01356 | mutS2 | - | ko:K07456 | + | MGYG000000001_02630 | - | - | - | + | MGYG000000001_02418 | ackA | 2.7.2.1 | ko:K00925 | + | MGYG000000001_00728 | atpA | 3.6.3.14 | ko:K02111 | + | MGYG000000001_00695 | pth | 3.1.1.29 | ko:K01056 | + | MGYG000000001_02907 | - | - | ko:K03086 | + | MGYG000000001_02592 | rplC | - | ko:K02906 | + | MGYG000000001_00137 | - | - | ko:K03480,ko:K03488 | -# Module 2. Database Updater + **Example Taxa Table:** -- Update the built database, and extend more annotations. + | Genome | Lineage | + | ------------- | ------------------------------------------------------------ | + | MGYG000000001 | d_Bacteria;p_Firmicutes_A;c_Clostridia;o_Peptostreptococcales;f_Peptostreptococcaceae;g_GCA-900066495;s_GCA-900066495 sp902362365 | + | MGYG000000002 | d_Bacteria;p_Firmicutes_A;c_Clostridia;o_Lachnospirales;f_Lachnospiraceae;g_Blautia_A;s_Blautia_A faecis | + | MGYG000000003 | d_Bacteria;p_Bacteroidota;c_Bacteroidia;o_Bacteroidales;f_Rikenellaceae;g_Alistipes;s_Alistipes shahii | + | MGYG000000004 | d_Bacteria;p_Firmicutes_A;c_Clostridia;o_Oscillospirales;f_Ruminococcaceae;g_Anaerotruncus;s_Anaerotruncus colihominis | + | MGYG000000005 | d_Bacteria;p_Firmicutes_A;c_Clostridia;o_Peptostreptococcales;f_Peptostreptococcaceae;g_Terrisporobacter;s_Terrisporobacter glycolicus_A | + | MGYG000000006 | d_Bacteria;p_Firmicutes;c_Bacilli;o_Staphylococcales;f_Staphylococcaceae;g_Staphylococcus;s_Staphylococcus xylosus | + | MGYG000000007 | d_Bacteria;p_Firmicutes;c_Bacilli;o_Lactobacillales;f_Lactobacillaceae;g_Lactobacillus;s_Lactobacillus intestinalis | + | MGYG000000008 | d_Bacteria;p_Firmicutes;c_Bacilli;o_Lactobacillales;f_Lactobacillaceae;g_Lactobacillus;s_Lactobacillus johnsonii | + | MGYG000000009 | d_Bacteria;p_Firmicutes;c_Bacilli;o_Lactobacillales;f_Lactobacillaceae;g_Ligilactobacillus;s_Ligilactobacillus murinus | -db_updater +## Module 2. Database Updater -+ **(Option 1) By built-in mode:** +The **Database Updater** allows updating the database built by the **Database Builder** or adding more annotations. This step is **optional**. - - there are some extended db we recommend, eg. - - - [dbCAN_seq] (https://bcb.unl.edu/dbCAN_seq ) - - +- Update the built database and extend annotations. -- **(Option 2) By TSV table** + ![db_updater](./MetaX_Cookbook.assets/db_updater.png) - - Extend the database by adding a new database to the database table. + **Option 1: Built-in Mode** - - Make sure the column separator is a tab. + We recommend some extended databases, such as [dbCAN_seq](https://bcb.unl.edu/dbCAN_seq). - - Make sure the first column is the Protein name and the other columns are function annotation + **Option 2: TSV Table** - | Protein ID | COG | KEGG | ... | - | ------------------- | ---------- | ---------- | ---- | - | MGYG000000001_02630 | Function 1 | Function 1 | ... | - | MGYG000000001_01475 | Function 2 | Function 1 | ... | - | MGYG000000001_01539 | Function 3 | Function 1 | ... | + Extend the database by adding a new database to the database table. Ensure the column separator is a tab and the first column is the Protein name, with other columns containing function annotations. + **Example:** + | Protein ID | COG | KEGG | ... | + | ------------------- | ---------- | ---------- | ---- | + | MGYG000000001_02630 | Function 1 | Function 1 | ... | + | MGYG000000001_01475 | Function 2 | Function 1 | ... | + | MGYG000000001_01539 | Function 3 | Function 1 | ... | -# Module 3. Peptide Annotator +## Module 3. Peptide Annotator -## 1. Result From MAG Workflow +### 1. Results from MAG Workflow +The peptide results use Metagenome-assembled genomes (MAGs) as the reference database for protein searches, e.g., MetaLab-MAG and other databases like MGnify. +- Annotate the peptide to Operational Taxa-Functions (OTF) Table before analysis using the Peptide Annotator. -The peptide result form Metagenome-assembled *genomes* (*MAGs*) as the reference database for proteins search, e.g. MetaLab-MAG, and other database like MGnify. + ![peptide2taxafunc](./MetaX_Cookbook.assets/peptide2taxafunc.png) -- Annotate the peptide to TaxaFunc before analyzing by **Peptide Annotator** + **Required:** - peptide2taxafunc - - You have to provide: - - - **Database**: The database created by **Database Builder** + - **Database**: The database created by Database Builder - **Peptide Table**: - - *Option 1*. From MetaLab-MAG results (final_peptides.tsv) + - *Option 1*: From MetaLab-MAG results (final_peptides.tsv) + + - *Option 2*: Create it manually, with the first column as the ID (e.g., peptide sequence) and the second column as the proteins ID of MGnify (e.g., MGYG000003683_00301; MGYG000001490_01143) or your database, and other columns as the intensity of each sample. - - *Option 2*. You can also create it by yourself, make sure the first column is the ID(e.g. peptide sequence) and the second column is the proteins ID of MGnify (e.g. MGYG000003683_00301; MGYG000001490_01143) or your Database, and other columns are the intensity of each sample) + **Example:** | Sequence | Proteins | Intensity_V1_01 | Intensity_V1_02 | Intensity_V1_03 | Intensity_V1_04 | | ----------------------------------- | ------------------------------------------------------------ | --------------- | --------------- | --------------- | --------------- | @@ -147,109 +142,100 @@ The peptide result form Metagenome-assembled *genomes* (*MAGs*) as the reference | (Acetyl)LLTGLPDAYGR | MGYG000001757_01206;MGYG000004547_02135;MGYG000001283_00124;MGYG000004758_00803;MGYG000002486_00845;MGYG000000271_01269 | 0 | 307519 | 0 | 0 | | (Acetyl)MDFTLDKK | MGYG000000076_01275;MGYG000003694_00879;MGYG000000312_02425;MGYG000000271_02102;MGYG000004271_00233;MGYG000002517_00542;MGYG000000489_01025 | 306231 | 0 | 0 | 1214497 | - - **Output Save Path**: the location to save the result table - - - **LCA Threshold**: Find the LCA with the proportion threshold for each peptide. The default is 1.00 (100%) - - LCA_prop + - **Output Save Path**: The location to save the result table. + - **LCA Threshold**: Find the LCA with the proportion threshold for each peptide. The default is 1.00 (100%). + ![LCA_prop](./MetaX_Cookbook.assets/LCA_prop.png) -## 2. Results from MaxQuant Workflow +### 2. Results from MaxQuant Workflow -The peptide result from **MetaLab 2.3** MaxQuant workflow +The peptide results from **MetaLab 2.3** MaxQuant workflow. - Select the **MetaLab** result folder, which contains the **maxquant_search** folder. - - ![peptide2taxafunc_tab2_1](MetaX_Cookbook.assets\peptide2taxafunc_tab2_1.png) + ![peptide2taxafunc_tab2_1](MetaX_Cookbook.assets/peptide2taxafunc_tab2_1.png) -- Then the **Peptide Annotator** will automatically find the **peptides_report.txt**, **BuiltIn.pepTaxa.csv** and **functions.tsv** in the **maxquant_search** folder. Or you can select the files manually. +- The **Peptide Annotator** will automatically find the **peptides_report.txt**, **BuiltIn.pepTaxa.csv**, and **functions.tsv** in the **maxquant_search** folder. Alternatively, you can select the files manually. + - Select **OTFs Save To** to set the location to save the result table. + ![peptide2taxafunc_tab2_2](MetaX_Cookbook.assets/peptide2taxafunc_tab2_2.png) - - Select the **OTFs Save To** to set the location to save the result table. - - ![peptide2taxafunc_tab2_2](MetaX_Cookbook.assets\peptide2taxafunc_tab2_2.png) +
+# Exploring Data with MetaX -# Module 4. OTF Analyzer +## Module 4. OTF Analyzer -When we get the **Operational Taxa-Functions (OTF) Table** after using the **Peptide Annotator**, we can use the **OTF Analyzer** to do downstream analysis. +After obtaining the **Operational Taxa-Functions (OTF) Table** using the **Peptide Annotator**, you can perform downstream analysis with the **OTF Analyzer**. -## 1. Data Preparing +## 1. Data Preparation -**OTFs (Taxa-Functions) Table:** Get from Peptide Annotator module +**OTFs (Operational Taxa-Functions) Table:** Obtained from the Peptide Annotator module. -**Meta Table:** The first column is sample names, and the other columns are different groups. *It would generate automatically meta info if the meta table were not provided (1. all samples are in the same group; 2. each sample is a group).* +**Meta Table:** The first column is sample names, and the other columns represent different groups. If no meta table is provided, meta info will be generated automatically: (1) all samples are in the same group; (2) each sample is a separate group. -- Example Meta Table: +**Example Meta Table:** - | samples | Individuals | Treatment | Sweetener | - | -------- | ----------- | --------- | --------- | - | sample_1 | V1 | Treatment | XYL | - | sample_2 | V1 | Treatment | XYL | - | sample_3 | V1 | Treatment | XYL | - | sample_4 | V1 | Control | PBS | - | sample_5 | V1 | Control | PBS | - | sample_6 | V1 | Control | PBS | +| samples | Individuals | Treatment | Sweetener | +| -------- | ----------- | --------- | --------- | +| sample_1 | V1 | Treatment | XYL | +| sample_2 | V1 | Treatment | XYL | +| sample_3 | V1 | Treatment | XYL | +| sample_4 | V1 | Control | PBS | +| sample_5 | V1 | Control | PBS | +| sample_6 | V1 | Control | PBS | +You can load example data by **clicking the button**. - - - -There, we can simply load the example data by **clicking the button**. - -load_example +![load_example](./MetaX_Cookbook.assets/load_example.png) Then, click **Go** to start the analysis. ## 2. Data Overview -Data Overview includes some basic information about your data, such as the number of taxa, functions and proportions. - -We can set the threshold of linked peptides and the differences between them to plot the figure. - -data_overview +The Data Overview provides basic information about your data, such as the number of taxa, functions, and proportions. -We Can Select different functions to plot the proportion distribution. +- Set the threshold for linked peptides and the differences between them to plot figures. -data_overview_func - - - -We can also filter some samples for downstream analysis. - -data_overview_filter +![data_overview](./MetaX_Cookbook.assets/data_overview.png) +- Select different functions to plot the proportion distribution. +![data_overview_func](./MetaX_Cookbook.assets/data_overview_func.png) +- Filter out samples for downstream analysis. +![data_overview_filter](./MetaX_Cookbook.assets/data_overview_filter.png) ## 3. Set TaxaFunc -set_multi_table - -### Data selection +![set_multi_table](./MetaX_Cookbook.assets/set_multi_table.png) -- **Function:** select a function for downstream analysis ( **None** in the list means that we do not select any function, only focus on peptides and Taxa). +### Data Selection -- **Function Filter Threshold:** If a specific function within a protein group of a peptide comprises the highest proportion of function, it will be considered as the representative function for that peptide. By default, the threshold for this proportion is set at 1.00 (100%). +- **Function:** Select a function for downstream analysis (**None** in the list means no function is selected, focusing only on peptides and taxa). -FUNC_prop +- **Function Filter Threshold:** If a specific function within a protein group of a peptide has the highest proportion, it will be considered the representative function for that peptide. The default threshold is 1.00 (100%). +![FUNC_prop](./MetaX_Cookbook.assets/FUNC_prop.png) +- **Taxa Level:** Select a taxa level for downstream analysis (**Life** in the list means no filtering by any taxa, the follow analysis focus on functions). -- **Taxa Level:** select a taxa level for downstream analysis(**Life** in the list means we do not filter by any taxa). +### Sum Proteins Intensity -### Sum Proteins Intensity +Click **Create Proteins Intensity Table** to sum peptides to proteins if the Protein column is in the original table. -We can click **Create Proteins Intensity Table** to sum the peptide to the proteins if the Protein col is in the original table. +- **Occam's Razor and Anti-Razor:** Methods available for inferring shared peptides. + 1. Build the rank of proteins. + 2. Choose the protein with a higher rank for the shared peptide. -- Occuam's Razor and Anti-Razor are methods both available for the inferring shared peptide. 1. build the Rank of proteins. 2. choose the protein with a higher rank for the shared peptide. -- 4 methods to build the **Protein Rank**. - - unique_counts: use the counts of proteins inferred by unique peptide - - all_count: use the counts of all proteins - - unique_intensity: use the intensity of proteins inferred by unique peptide - - shared_intensity: use the intensity divided by shared times of peptide for each protein +- **Methods to Build Protein Rank:** + - unique_counts: Use the counts of proteins inferred by unique peptides. + - all_count: Use the counts of all proteins. + - unique_intensity: Use the intensity of proteins inferred by unique peptides. + - shared_intensity: Use the intensity divided by the number of shared peptides for each protein. ### Data preprocessing @@ -631,7 +617,7 @@ We can select **meta** **groups** or **samples** (default a - Network Plot - The Red dots are focus items - - The depth of green represents the correlation value + - The depth of color and the width of edges represent the correlation value - The size of the dot indicates the number of connections co_network_pic diff --git a/utils/GUI.py b/utils/GUI.py index 7b8bdf9..3ef8444 100644 --- a/utils/GUI.py +++ b/utils/GUI.py @@ -651,9 +651,6 @@ def show_settings_window(self): layout.addWidget(settings_widget) self.settings_dialog.setLayout(layout) - - # set not pin to top - self.settings_dialog.setWindowFlags(self.settings_dialog.windowFlags() & ~Qt.WindowStaysOnTopHint) self.settings_dialog.show() diff --git a/utils/MetaX_GUI/MainWindow.ui b/utils/MetaX_GUI/MainWindow.ui index 44f8edc..5ca83d9 100644 --- a/utils/MetaX_GUI/MainWindow.ui +++ b/utils/MetaX_GUI/MainWindow.ui @@ -46,7 +46,7 @@ Qt::LeftToRight - 0 + 5 @@ -239,8 +239,8 @@ 0 0 - 391 - 80 + 496 + 373 @@ -5296,7 +5296,7 @@ - false + true Rename Taxa @@ -7076,7 +7076,7 @@ - false + true Raname Taxa @@ -8185,12 +8185,12 @@ setEnabled(bool) - 647 - 152 + 139 + 132 - 811 - 153 + 139 + 132 @@ -8201,12 +8201,12 @@ setEnabled(bool) - 647 - 152 + 139 + 132 - 975 - 153 + 139 + 132 @@ -8249,12 +8249,12 @@ setEnabled(bool) - 179 - 175 + 137 + 114 - 254 - 177 + 137 + 114 @@ -8265,12 +8265,12 @@ setEnabled(bool) - 179 - 175 + 137 + 114 - 329 - 177 + 137 + 114 @@ -8281,12 +8281,12 @@ setEnabled(bool) - 136 - 149 + 147 + 114 - 230 - 151 + 159 + 114 @@ -8297,12 +8297,12 @@ setEnabled(bool) - 136 - 149 + 147 + 114 - 311 - 151 + 159 + 114 @@ -8345,12 +8345,12 @@ setEnabled(bool) - 537 - 240 + 137 + 109 - 724 - 241 + 137 + 109 @@ -8361,12 +8361,12 @@ setEnabled(bool) - 537 - 240 + 137 + 109 - 912 - 241 + 137 + 109 @@ -8377,12 +8377,12 @@ setEnabled(bool) - 244 - 149 + 149 + 113 - 320 - 151 + 149 + 113 @@ -8393,12 +8393,12 @@ setEnabled(bool) - 244 - 149 + 149 + 113 - 395 - 151 + 149 + 113 @@ -8409,12 +8409,12 @@ setEnabled(bool) - 199 - 191 + 137 + 110 - 296 - 193 + 137 + 110 @@ -8425,12 +8425,12 @@ setEnabled(bool) - 199 - 191 + 137 + 110 - 392 - 193 + 137 + 110 @@ -8505,12 +8505,12 @@ setEnabled(bool) - 827 - 322 + 137 + 116 - 974 - 322 + 137 + 116 @@ -8521,12 +8521,12 @@ setEnabled(bool) - 827 - 322 + 137 + 116 - 230 - 524 + 137 + 122 @@ -8537,12 +8537,12 @@ setEnabled(bool) - 743 - 315 + 137 + 116 - 359 - 314 + 137 + 116 @@ -8553,12 +8553,12 @@ setEnabled(bool) - 860 - 404 + 917 + 336 - 932 - 352 + 1012 + 313 @@ -8569,44 +8569,12 @@ setEnabled(bool) - 832 - 276 - - - 906 - 305 - - - - - checkBox_tf_link_net_show_label - clicked(bool) - checkBox_tf_link_net_rename_taxa - setEnabled(bool) - - - 825 - 280 - - - 903 - 286 - - - - - checkBox_co_expr_show_label - clicked(bool) - checkBox_co_expr_rename_taxa - setEnabled(bool) - - - 893 - 400 + 203 + 123 - 894 - 420 + 203 + 127 diff --git a/utils/MetaX_GUI/Ui_MainWindow.py b/utils/MetaX_GUI/Ui_MainWindow.py index cb04641..64124e4 100644 --- a/utils/MetaX_GUI/Ui_MainWindow.py +++ b/utils/MetaX_GUI/Ui_MainWindow.py @@ -145,7 +145,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, 391, 80)) + self.page_2.setGeometry(QtCore.QRect(0, 0, 496, 373)) self.page_2.setObjectName("page_2") self.gridLayout_27 = QtWidgets.QGridLayout(self.page_2) self.gridLayout_27.setObjectName("gridLayout_27") @@ -2778,7 +2778,7 @@ def setupUi(self, metaX_main): self.checkBox_co_expr_show_label.setObjectName("checkBox_co_expr_show_label") self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.checkBox_co_expr_show_label) self.checkBox_co_expr_rename_taxa = QtWidgets.QCheckBox(self.tab_5) - self.checkBox_co_expr_rename_taxa.setEnabled(False) + self.checkBox_co_expr_rename_taxa.setEnabled(True) self.checkBox_co_expr_rename_taxa.setObjectName("checkBox_co_expr_rename_taxa") self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_co_expr_rename_taxa) self.verticalLayout_3.addLayout(self.formLayout) @@ -3720,7 +3720,7 @@ def setupUi(self, metaX_main): self.checkBox_tf_link_net_show_label.setObjectName("checkBox_tf_link_net_show_label") self.horizontalLayout_57.addWidget(self.checkBox_tf_link_net_show_label) self.checkBox_tf_link_net_rename_taxa = QtWidgets.QCheckBox(self.tab_9) - self.checkBox_tf_link_net_rename_taxa.setEnabled(False) + self.checkBox_tf_link_net_rename_taxa.setEnabled(True) self.checkBox_tf_link_net_rename_taxa.setObjectName("checkBox_tf_link_net_rename_taxa") self.horizontalLayout_57.addWidget(self.checkBox_tf_link_net_rename_taxa) self.gridLayout_6.addLayout(self.horizontalLayout_57, 10, 3, 1, 1) @@ -4266,7 +4266,7 @@ def setupUi(self, metaX_main): self.retranslateUi(metaX_main) self.stackedWidget.setCurrentIndex(0) - self.tabWidget_TaxaFuncAnalyzer.setCurrentIndex(0) + self.tabWidget_TaxaFuncAnalyzer.setCurrentIndex(5) self.toolBox_2.setCurrentIndex(0) self.tabWidget_4.setCurrentIndex(1) self.tabWidget_3.setCurrentIndex(0) @@ -4302,8 +4302,6 @@ def setupUi(self, metaX_main): self.checkBox_pca_if_show_lable.clicked['bool'].connect(self.doubleSpinBox_basic_pca_label_font_transparency.setEnabled) # type: ignore self.checkBox_co_expr_show_label.clicked['bool'].connect(self.spinBox_co_expr_font_size.setEnabled) # type: ignore self.checkBox_tf_link_net_show_label.clicked['bool'].connect(self.spinBox_network_font_size.setEnabled) # type: ignore - self.checkBox_tf_link_net_show_label.clicked['bool'].connect(self.checkBox_tf_link_net_rename_taxa.setEnabled) # type: ignore - self.checkBox_co_expr_show_label.clicked['bool'].connect(self.checkBox_co_expr_rename_taxa.setEnabled) # type: ignore QtCore.QMetaObject.connectSlotsByName(metaX_main) metaX_main.setTabOrder(self.comboBox_taxa_level_to_stast, self.toolButton_meta_table_help) metaX_main.setTabOrder(self.toolButton_meta_table_help, self.comboBox_function_to_stast) diff --git a/utils/TaxaFuncPloter/network_plot.py b/utils/TaxaFuncPloter/network_plot.py index 12506fa..d5cf435 100644 --- a/utils/TaxaFuncPloter/network_plot.py +++ b/utils/TaxaFuncPloter/network_plot.py @@ -271,20 +271,20 @@ def plot_tflink_network(self, sample_list:list = None, width:int = 12, height:in def plot_co_expression_network(self, df_type:str= 'taxa', corr_method:str = 'pearson', - corr_threshold:float=0.5, sample_list:list = None, - width:int = 12, height:int = 8, focus_list:list = [], plot_list_only:bool = False, - ): + corr_threshold:float=0.5, sample_list:list = None, + width:int = 12, height:int = 8, focus_list:list = [], plot_list_only:bool = False, + ): from matplotlib import colormaps #check sample_list length if len(sample_list) < 2: raise ValueError(f"sample_list should have at least 2 samples, but got {len(sample_list)}") df_dict = {'taxa': self.tfa.taxa_df, - 'functions': self.tfa.func_df, - 'taxa-functions': self.tfa.taxa_func_df, - 'peptides': self.tfa.peptide_df, - 'proteins': self.tfa.protein_df, - 'custom': self.tfa.custom_df} + 'functions': self.tfa.func_df, + 'taxa-functions': self.tfa.taxa_func_df, + 'peptides': self.tfa.peptide_df, + 'proteins': self.tfa.protein_df, + 'custom': self.tfa.custom_df} df = df_dict[df_type].copy() if self.rename_taxa: @@ -314,7 +314,7 @@ def plot_co_expression_network(self, df_type:str= 'taxa', corr_method:str = 'pea min_node_size = node_sizes.min() categories = [{"name": "Focused", "itemStyle": {"normal": {"color": self.co_network_focus_color}}}, - {"name": "Normal", "itemStyle": {"normal": {"color": self.co_network_normal_color}}}] + {"name": "Normal", "itemStyle": {"normal": {"color": self.co_network_normal_color}}}] linked_nodes = set() if focus_list: @@ -327,9 +327,28 @@ def plot_co_expression_network(self, df_type:str= 'taxa', corr_method:str = 'pea if node_i in focus_list or node_j in focus_list: linked_nodes.add(node_i) linked_nodes.add(node_j) - + + connected_nodes = set() + links = [] + # calculate the correlation between each pair of nodes, and create a link if the correlation is above a threshold + # the color of the link is determined by the correlation value + for i in range(len(correlation_matrix)): + for j in range(i+1, len(correlation_matrix)): + correlation = correlation_matrix.iloc[i, j] + # create a link if the correlation is above a threshold + if correlation > corr_threshold: + color = colormaps.get_cmap('viridis')(1 - (correlation - corr_threshold) / corr_threshold) + color = '#%02x%02x%02x' % (int(color[0]*255), int(color[1]*255), int(color[2]*255)) + line_width = (correlation - corr_threshold) / (1 - corr_threshold) * self.line_width * 2 + links.append({"source": correlation_matrix.columns[i], "target": correlation_matrix.columns[j], "value": correlation, "lineStyle": {"color": color, "width": line_width}}) + connected_nodes.add(correlation_matrix.columns[i]) + connected_nodes.add(correlation_matrix.columns[j]) + nodes = [] for item in correlation_matrix.columns: + if item not in connected_nodes and item not in focus_list: + continue # Skip the node if it is not connected and not in focus list + if focus_list and len(focus_list) > 0: if plot_list_only and item not in focus_list and item not in linked_nodes: continue # skip the node if it's not in the focus list and not linked to any node in the focus list @@ -356,20 +375,6 @@ def plot_co_expression_network(self, df_type:str= 'taxa', corr_method:str = 'pea "category": category }) - links = [] - # calculate the correlation between each pair of nodes, and create a link if the correlation is above a threshold - # the color of the link is determined by the correlation value - for i in range(len(correlation_matrix)): - for j in range(i+1, len(correlation_matrix)): - correlation = correlation_matrix.iloc[i, j] - # create a link if the correlation is above a threshold - if correlation > corr_threshold: - color = colormaps.get_cmap('viridis')(1 - (correlation - corr_threshold) / corr_threshold) - color = '#%02x%02x%02x' % (int(color[0]*255), int(color[1]*255), int(color[2]*255)) - line_width = (correlation - corr_threshold) / (1 - corr_threshold) * self.line_width * 2 - links.append({"source": correlation_matrix.columns[i], "target": correlation_matrix.columns[j], "value": correlation, "lineStyle": {"color": color, "width": line_width}}) - - pic = ( Graph( init_opts=opts.InitOpts( @@ -433,7 +438,8 @@ def plot_co_expression_network(self, df_type:str= 'taxa', corr_method:str = 'pea ) ) return pic - + + # NetworkPlot(sw).plot_co_expression_network(df_type='func', corr_threshold=0.8, sample_list=sw.get_sample_list_in_a_group('V1') , focus_list=["'glutamate synthase"]).render_notebook() diff --git a/utils/version.py b/utils/version.py index 55702a1..ef87f28 100644 --- a/utils/version.py +++ b/utils/version.py @@ -1,2 +1,2 @@ -__version__ = '1.107.2' +__version__ = '1.107.3' API_version = '1' \ No newline at end of file