Icon

05. Workflow Control - solution

Workflow Control Solution

Solution for "Workflow Control" exercise for advanced Life Science User Training - Handle and write groups of data to separate sheets in an Excel file - Read and concatenate many sheets using a loop - Activate a workflow branch based on a user selection




Activity I: Group Looping - Read the file: CHEMBLID228_SERT_ligands.table - Group over all the AssayIDs with a group loop - Write each AssayID to a separate sheet in an Excel file Activity II: Reading Many Sheets - Use Read Excel Sheet Names to list all sheet names in an Excel file - Iterate over that list of sheets with a Table Row to Variable Loop, and aggregate them into a single KNIME table Activity III: If Switch Extend the workflow below with a switch to select the kind of visualisation. - Use a Single Selection Configuration node to let a user choose the values "Parallel Coordinates Plot" or "Scatter Plot", use the flow variable "port index" as output port - Use a CASE Switch Start node to create either a parallel coordinate plot or a scatter plot depending on the input. - Use Column Rename node to rename the plot selection column in both branches "Selection" - Combine the two paths with a CASE Switch End node and use a Row Filter node to filter only the selected compounds Step 1Use the Table Reader node to load theChEMBLID228_SERT_ligands.table Step 2Use the Group Loop Startnode to group and iterate overeach assay_chmebl_id Step 3Use the Excel Writer node to write eachtAssayID data table to a separate sheet onExcel file. Make sure to select "append" if filealready exists. The sheet name should be theAssayID for the current iteration (Hint: Pass thecurrent AssayID as a sheet name in the FlowVariable tab) Step 4Use the Variable Loop End node to end theloop. Step 1Use the Read Excel SheetNames node to get a list of allsheet in the file "data/temp/assays.xlsx". Step 2Use the Table Row to VariableLoop Start node to iterate over allsheets in the list Step 3Use the Excel Reader node andconnect the Flow Variable portfrom the Table Row to VariableLoop Start. Use the flow variablecreated by the Table Row toVariable Loop node to control thesetting sheet_name in the FlowVariable tab Step 4Use the Loop End node to endthe loop. Pay attention: thecombined data from all loops isavailable in the output port of thenode. Step 1Use the CASE Switch Startnode and select as input porttype "Data". In theconfiguration dialog control thePortIndex by the Flow Variable"plot-type (index)" from theSingle Selection Configurationnode. Step 2Use the CASE SwitchEnd node to end theswitch case. do one iterationper AssayIDCollect variableand end loopWrite compounds from current iterationinto an Excel SheetList all sheet names from an Excel fileRead sheetLoop oversheet names(1 per iteration)CHEMBLID228_SERT_ligands.tableCHEMBLID228_SERT_ligands.tableCombineinto oneCombine all sheetsinto single table Group Loop Start RDKit DescriptorCalculation ParallelCoordinates Plot Scatter Plot Single SelectionConfiguration Column Rename Column Rename Row Filter Variable Loop End Excel Writer Read ExcelSheet Names Excel Reader Table Row ToVariable Loop Start Table Reader Table Reader CASE Switch Start CASE Switch End Loop End Activity I: Group Looping - Read the file: CHEMBLID228_SERT_ligands.table - Group over all the AssayIDs with a group loop - Write each AssayID to a separate sheet in an Excel file Activity II: Reading Many Sheets - Use Read Excel Sheet Names to list all sheet names in an Excel file - Iterate over that list of sheets with a Table Row to Variable Loop, and aggregate them into a single KNIME table Activity III: If Switch Extend the workflow below with a switch to select the kind of visualisation. - Use a Single Selection Configuration node to let a user choose the values "Parallel Coordinates Plot" or "Scatter Plot", use the flow variable "port index" as output port - Use a CASE Switch Start node to create either a parallel coordinate plot or a scatter plot depending on the input. - Use Column Rename node to rename the plot selection column in both branches "Selection" - Combine the two paths with a CASE Switch End node and use a Row Filter node to filter only the selected compounds Step 1Use the Table Reader node to load theChEMBLID228_SERT_ligands.table Step 2Use the Group Loop Startnode to group and iterate overeach assay_chmebl_id Step 3Use the Excel Writer node to write eachtAssayID data table to a separate sheet onExcel file. Make sure to select "append" if filealready exists. The sheet name should be theAssayID for the current iteration (Hint: Pass thecurrent AssayID as a sheet name in the FlowVariable tab) Step 4Use the Variable Loop End node to end theloop. Step 1Use the Read Excel SheetNames node to get a list of allsheet in the file "data/temp/assays.xlsx". Step 2Use the Table Row to VariableLoop Start node to iterate over allsheets in the list Step 3Use the Excel Reader node andconnect the Flow Variable portfrom the Table Row to VariableLoop Start. Use the flow variablecreated by the Table Row toVariable Loop node to control thesetting sheet_name in the FlowVariable tab Step 4Use the Loop End node to endthe loop. Pay attention: thecombined data from all loops isavailable in the output port of thenode. Step 1Use the CASE Switch Startnode and select as input porttype "Data". In theconfiguration dialog control thePortIndex by the Flow Variable"plot-type (index)" from theSingle Selection Configurationnode. Step 2Use the CASE SwitchEnd node to end theswitch case. do one iterationper AssayIDCollect variableand end loopWrite compounds from current iterationinto an Excel SheetList all sheet names from an Excel fileRead sheetLoop oversheet names(1 per iteration)CHEMBLID228_SERT_ligands.tableCHEMBLID228_SERT_ligands.tableCombineinto oneCombine all sheetsinto single table Group Loop Start RDKit DescriptorCalculation ParallelCoordinates Plot Scatter Plot Single SelectionConfiguration Column Rename Column Rename Row Filter Variable Loop End Excel Writer Read ExcelSheet Names Excel Reader Table Row ToVariable Loop Start Table Reader Table Reader CASE Switch Start CASE Switch End Loop End

Nodes

Extensions

Links