Package: synergyMixR 1.0.0

Yusuke Matsui

synergyMixR: Mixture-Based Muscle Synergy Analysis

Provides tools for analyzing muscle synergy using various statistical methods including MPCA and MFA. Enables researchers to identify distinct subgroups within populations that exhibit different muscle synergy patterns, rather than forcing all subjects into a single global model.

Authors:Yusuke Matsui [aut, cre]

synergyMixR_1.0.0.tar.gz
synergyMixR_1.0.0.zip(r-4.7-x86_64)synergyMixR_1.0.0.zip(r-4.7-arm64)synergyMixR_1.0.0.zip(r-4.6-x86_64)synergyMixR_1.0.0.zip(r-4.6-arm64)synergyMixR_1.0.0.zip(r-4.5-x86_64)
synergyMixR_1.0.0.tgz(r-4.6-x86_64)synergyMixR_1.0.0.tgz(r-4.6-arm64)synergyMixR_1.0.0.tgz(r-4.5-x86_64)synergyMixR_1.0.0.tgz(r-4.5-arm64)
synergyMixR_1.0.0.tar.gz(r-4.7-arm64)synergyMixR_1.0.0.tar.gz(r-4.7-x86_64)synergyMixR_1.0.0.tar.gz(r-4.6-arm64)synergyMixR_1.0.0.tar.gz(r-4.6-x86_64)
synergyMixR_1.0.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
synergyMixR/json (API)

# Install 'synergyMixR' in R:
install.packages('synergyMixR', repos = c('https://matsui-lab.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/matsui-lab/synergymixr/issues

Uses libs:
  • openblas– Optimized BLAS
  • c++– GNU Standard C++ Library v3
  • openmp– GCC OpenMP (GOMP) support library

On CRAN:

Conda:

openblascppopenmp

3.54 score 160 exports 24 dependencies

Last updated from:7178667190. Checks:15 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK180
linux-devel-x86_64OK221
source / vignettesOK276
linux-release-arm64OK183
linux-release-x86_64OK211
macos-release-arm64OK202
macos-release-x86_64OK451
macos-oldrel-arm64OK190
macos-oldrel-x86_64OK289
windows-devel-arm64OK509
windows-devel-x86_64OK253
windows-release-arm64OK453
windows-release-x86_64OK143
windows-oldrel-x86_64OK193
wasm-releaseOK190

Exports:%>%aggregate_partial_resultsalign_clusters_to_truthalign_factor_signs_mfaalign_factor_signs_mpcaassign_by_kmeansbandpass_filterbootstrap_loading_cicalc_reconstruction_error_mixtureFAcalc_reconstruction_error_mixturePCAcalc_reconstruction_error_singleFAcalc_reconstruction_error_singlePCAcalc_total_SSTcalibrate_modelcheck_future_availablecheck_pbs_job_statuscheck_SSE_diagnosticscompare_baselinescompare_static_vs_dynamiccompute_aricompute_ari_vaf_tablecompute_BICcompute_BIC_mfacompute_BIC_mpcacompute_bic_wrappercompute_calibrationcompute_cluster_sizescompute_cluster_sizes_mpcacompute_clusterwise_subspace_scorecompute_ececompute_entropycompute_factor_scorescompute_factor_scores_mfacompute_factor_scores_mpcacompute_factor_scores_mpca_singlecompute_factor_scores_optimizedcompute_global_vaf_mfacompute_global_vaf_mpcacompute_ICLcompute_ICL_mfacompute_ICL_mpcacompute_logLikcompute_logLik_mfacompute_logLik_mpcacompute_mvc_referencecompute_reconstruction_errorcompute_smoothness_penaltycompute_subspace_similaritycompute_VAFcompute_VAF_mfacompute_VAF_mpcacompute_vaf_wrappercompute_vss_criterioncount_completed_tasksemg_preset_configevaluate_model_selectionextract_cluster_labelsextract_envelopeextract_selection_summaryextract_subject_features_by_singlePCAfacet_mixsynergyfit_single_factor_analysisfit_single_pcafit_two_step_baselinegenerate_pbs_scriptgenerate_synergy_dataget_model_by_K_rget_model_by_K_r_mpcamake_table1make_table2mfa_em_fitmfa_em_fit_cpp_singleInitmixture_pca_em_fitmixture_pca_em_fit_cpp_singleInitnormalize_emgnotch_filterplot_activation_patternsplot_aligned_basis_heatmapsplot_all_factor_scores_mfaplot_all_factor_scores_mpcaplot_all_reconstructed_waveforms_mfaplot_all_reconstructed_waveforms_mpcaplot_basis_umapplot_bic_comparisonplot_bic_lineplot_calibrationplot_cluster_embeddingplot_cluster_synergy_loadings_mfaplot_cluster_synergy_loadings_mpcaplot_confusion_matrixplot_fig1_ARIplot_fig1_baseline_comparisonplot_fig2_BIC_heatmapplot_fig3_init_boxplotplot_fig4to6_reconstruction_vafplot_metric_vs_axisplot_neural_commandplot_noise_profilesplot_reconstructed_emgplot_sse_heatmapplot_sweep_summaryplot_synergy_basesplot_synergy_correlation_comparisonplot_synergy_summaryplot_waveform_comparison_mfaplot_waveform_comparison_mpcaplot_winrate_heatmapposthoc_mfa_evaluationposthoc_mpca_evaluationpreprocess_emgread_all_resultsread_and_visualize_allreconstruct_singleMPCArectifyremove_dc_offsetrotate_mfa_modelrotate_mpca_modelrun_k_selection_comparisonrun_param_sweeprun_param_sweep_baselinesrun_param_sweep_modelselrun_single_taskrun_single_task_baselinesrun_sweep_futurescale_color_mixsynergyscale_fill_mixsynergyscale_fill_mixsynergy_discretescale_fill_mixsynergy_divergingselect_K_bootstrap_stabilityselect_K_crossvalidationselect_K_rselect_optimal_K_r_mfaselect_optimal_K_r_mfa_twostageselect_optimal_K_r_mpcaselect_optimal_K_r_mpca_twostageselect_rselect_r_by_smoothness_mfaselect_r_by_smoothness_mpcaselect_r_by_vaf_mfaselect_r_by_vaf_mpcaselect_r_by_vss_mfaselect_r_by_vss_mpcaselect_r_clusterwise_mfaselect_r_clusterwise_mpcaselect_r_global_mfaselect_r_global_mpcaselect_r_mixtureselect_r_multicriteria_mfaselect_r_multicriteria_mpcasetup_future_backendshow_parallel_optionssimulate_dynamic_synergy_datastrip_attributessubmit_hpc_sweepsubmit_pbs_sweepsummarize_vaf_sse_mfatheme_mixsynergytheme_mixsynergy_heatmaptheme_sweepwait_for_pbs_job

Dependencies:clicpp11farverggplot2gluegtableisobandlabelinglifecyclemagrittrMASSmvtnormR6RColorBrewerRcppRcppArmadillorlangS7scalessignaltidyselectvctrsviridisLitewithr

Comprehensive Guide to K and r Model Selection
Introduction | Load Package and Example Data | Part 1: Two-Stage K,r Selection | Why Two-Stage? | Algorithm | Usage Example | For MPCA Models | Choosing r_fixed | Comparison: Two-Stage vs Grid Search | Part 2: Post-Hoc Evaluation | posthoc_mfa_evaluation() | Output Columns | Interpreting Cluster Sizes | get_model_by_K_r() | Comparing Multiple Candidates | Part 3: Integrated Workflow | Workflow Diagram | Complete Example | Decision Checklist | When to Reconsider | Summary | See Also | Session Info

Last update: 2026-02-21
Started: 2026-02-21

Metrics Reference: Selection Criteria for K and r
Introduction | Quick Reference Table | Detailed Metric Descriptions | Cross-Validation (CV) | Theoretical Background | Mathematical Formulation | Implementation | When to Use | Interpretation Guidelines | Variance Accounted For (VAF) | VAF Thresholds in Literature | Caution: VAF Alone is Insufficient | Bayesian Information Criterion (BIC) | BIC vs AIC | Sample Size Sensitivity | Smoothness Penalty | Interpretation | Typical Pattern | Muscle Synergy Context | Very Simple Structure (VSS) | Rotation Importance | Parallel Analysis (PA) | Algorithm | Characteristics | Metric Comparison and Selection Strategy | Single Metric Usage | Recommended Combinations | Conservative Selection (Avoid Overfitting) | Interpretability Focus | Balanced Approach (Recommended Default) | Decision Framework | Summary | Key Takeaways | Recommended Workflow | References | Session Info

Last update: 2026-02-21
Started: 2026-02-21

Mixture-Based Muscle Synergy Analysis (MFA & MPCA)
1. Background | 2. Method Overview and Effective Use Cases | 2.1 Mixture Factor Analysis (MFA) | 2.2 Mixture PCA (MPCA) | 3. Data (Input) Format | 4. Single Mixture Model Estimation | 4.1 Mixture Factor Analysis (MFA) | 4.2 Mixture PCA (MPCA) | 5. Parameter Meanings and Typical Settings | 6. Visualizing the Fitted Model | 6.1 MFA: Synergy Loadings & Factor Scores | 6.2 MPCA: Loadings & Factor Scores | 7. Optimal Parameter Search (K, r) | 7.1 MFA Grid Search | 7.2 MPCA Grid Search | 8. Refining the Chosen Model | 9. Closing Remarks

Last update: 2026-02-21
Started: 2026-02-21

Quickstart: Mixture-Based Muscle Synergy Analysis
Introduction | Load the Package | Step 1: Generate Synthetic Data | Step 2: Fit MFA Model | Step 3: Visualize Synergy Loadings | Additional Visualizations | Next Steps | Summary

Last update: 2026-02-21
Started: 2026-02-21

Simulation Study: Effect of Cluster Separation on Model Performance
1 Overview | 2 Simulation design | 3 Running the simulation | 4 Aggregating results | 5 Visualisation | 5.1 Clustering accuracy (ARI) | 5.2 Model fit (BIC & VAF) | 6 Session information

Last update: 2026-02-21
Started: 2026-02-21

Simulation Study: Single vs. Mixture Synergy Models
1. Introduction | 2. Simulation design | 3. Running the 10 replicates | 4. Summary statistics | 5. Visualising variability across replicates | 6. Session information

Last update: 2026-02-21
Started: 2026-02-21

Unified r-Selection Framework for Mixture Models
Introduction | Load the Package | Generate Example Data | Mode 1: Global-First Selection | When to Use Global-First Mode | Usage Example | Visualize Results | Mode 2: Clusterwise Selection | When to Use Clusterwise Mode | Aggregation Methods | Visualize Clusterwise Results | Mode 3: Hybrid Selection (Recommended) | When to Use Hybrid Mode | Special Aggregation: "global" | Visualize Hybrid Results | Comparison: MFA vs MPCA | Advanced: Direct Use of Clusterwise Functions | Best Practices and Recommendations | 1. Start with Hybrid Mode | 2. Use Appropriate rvec Range | 3. Interpret Multiple Criteria | 4. Validate with Visualization | 5. Consider Computational Cost | Troubleshooting | Issue: Different modes give very different r values | Issue: Selected r is at the boundary of rvec | Issue: Clusterwise mode gives NA or warnings | Multi-Criteria Selection | Understanding the Composite Score | Weight Configuration Guidelines | Understanding the Metrics | Cross-Validation (CV) | Variance Accounted For (VAF) | Smoothness Penalty | Very Simple Structure (VSS) | Parallel Analysis (PA) | Bayesian Information Criterion (BIC) | Summary | References | Session Info

Last update: 2026-02-21
Started: 2026-02-21

Readme and manuals

Help Manual

Help pageTopics
Aggregate Partial Results from PBS Jobsaggregate_partial_results
Align Cluster Labels to Ground Truth Using Hungarian Algorithmalign_clusters_to_truth
Align (Flip) Factor Signs in an MFA Modelalign_factor_signs_mfa
Align (Flip) Factor Signs in a Mixture PCA Modelalign_factor_signs_mpca
K-means-based cluster assignmentassign_by_kmeans
Bandpass Filter for EMG Signalsbandpass_filter
Bootstrap Confidence Intervals for Synergy Loadingsbootstrap_loading_ci
Compute SSE for a MixtureFA modelcalc_reconstruction_error_mixtureFA
Compute SSE for a MixturePCA modelcalc_reconstruction_error_mixturePCA
Compute Total Reconstruction SSE for Single FAcalc_reconstruction_error_singleFA
Compute Total Reconstruction SSE for Single PCAcalc_reconstruction_error_singlePCA
Compute the Total Sum of Squares (SST) for a List of Data Matricescalc_total_SST
Compute Calibration from Model Fitcalibrate_model
Check if Future Packages are Availablecheck_future_available
Check PBS Job Statuscheck_pbs_job_status
Check SSE Diagnostics for Mixture Modelscheck_SSE_diagnostics
Compare Analysis Methods on v2 Dynamic Synergy Datacompare_baselines
Compare Analysis Methods on Dynamic Synergy Data (v2)compare_static_vs_dynamic
Compute Adjusted Rand Index (ARI)compute_ari
Compile ARI and VAF into a Single Tablecompute_ari_vaf_table
Compute Bayesian Information Criterion (BIC)compute_BIC
Compute BIC for an MFA modelcompute_BIC_mfa
Compute BIC for a Mixture PCA Modelcompute_BIC_mpca
Compute BIC for a Fitted Modelcompute_bic_wrapper
Compute Calibration Statistics for Mixture Modelcompute_calibration
Compute Cluster Sizes from a Fitted MFA (or Mixture PCA) Modelcompute_cluster_sizes
Compute Cluster Sizes for Mixture PCAcompute_cluster_sizes_mpca
Compute Cluster-wise Subspace Recovery Scorecompute_clusterwise_subspace_score
Compute Expected Calibration Errorcompute_ece
Compute Classification Entropy from Responsibilitiescompute_entropy
Compute Factor Scores for a Single MFA Clustercompute_factor_scores
Compute Factor Scores for All Subjects in an MFA Modelcompute_factor_scores_mfa
Compute PC Factor Scores for All Subjects in a Mixture PCA Modelcompute_factor_scores_mpca
Compute Factor (PC) Scores for a Single Subject in a Mixture PCA Clustercompute_factor_scores_mpca_single
Compute Factor Scores for a Single Subject in MFAcompute_factor_scores_optimized
Compute Global VAF (1 - SSE/SST) for an MFA Modelcompute_global_vaf_mfa
Compute Global VAF (1 - SSE/SST) for Mixture PCAcompute_global_vaf_mpca
Compute ICL for a Mixture Model (Unified Interface)compute_ICL
Compute ICL for a Mixture Factor Analysis Modelcompute_ICL_mfa
Compute ICL for a Mixture PCA Modelcompute_ICL_mpca
Compute Log-Likelihood for Mixture Modelscompute_logLik
Compute the Mixture-Model Log-Likelihood for MFAcompute_logLik_mfa
Compute the Mixture-Model Log-Likelihood for Mixture PCAcompute_logLik_mpca
Compute MVC Reference Valuescompute_mvc_reference
Compute Reconstruction Errorcompute_reconstruction_error
Compute Smoothness Penalty for Factor Scorescompute_smoothness_penalty
Compute Subspace Similarity Between Two Basis Matricescompute_subspace_similarity
Compute Global Variance Accounted For (VAF)compute_VAF
Compute VAF for a Fitted MFA Modelcompute_VAF_mfa
Compute VAF for a Mixture PCA (PPCA) Modelcompute_VAF_mpca
Compute VAF (Variance Accounted For) for a Fitted Modelcompute_vaf_wrapper
Compute VSS (Very Simple Structure) Criterion for Factor Loadingscompute_vss_criterion
Count Completed PBS Taskscount_completed_tasks
EMG Preprocessing Preset Configurationsemg_preset_config
Evaluate Model Selection Resultsevaluate_model_selection
Extract Cluster Labels from a Fitted Modelextract_cluster_labels
Extract Envelope from EMG Signalextract_envelope
Extract Selection Summary as Data Frameextract_selection_summary
Extract subject-level features by single PCAextract_subject_features_by_singlePCA
Apply Consistent Faceting for Cluster and Factor Visualizationsfacet_mixsynergy
Fit a Single Factor Analysis (Ignoring Clusters)fit_single_factor_analysis
Fit a Single PCA (Ignoring Clusters)fit_single_pca
Two-step Baseline Algorithm for PCA/FAfit_two_step_baseline
Generate PBS Job Scriptgenerate_pbs_script
Generate v2 Dynamic Synergy Data for Model Selection Experimentsgenerate_synergy_data
Retrieve a Specific Model by (K, r) from a Grid Searchget_model_by_K_r
Retrieve a Mixture PCA Model by (K, r)get_model_by_K_r_mpca
Create a Static Table of Simulation Conditions (Table 1)make_table1
Summarize Results for a Subset (Table 2)make_table2
Fit a Mixture Factor Analysis Model (with optional multi-initialization)mfa_em_fit
Single-Run Mixture Factor Analysis with a Preset Initial Assignmentmfa_em_fit_cpp_singleInit
Fit a Mixture PCA Model (Using mpcaTimeseriesCpp) with optional multi-initializationmixture_pca_em_fit
Single-Run Mixture PCA with a Preset Initial Assignmentmixture_pca_em_fit_cpp_singleInit
Normalize EMG Signalnormalize_emg
Notch Filter for Power Line Noise Removalnotch_filter
Plot Activation Patternsplot_activation_patterns
Plot Aligned Basis Heatmapsplot_aligned_basis_heatmaps
Plot All Factor Scores (Z) for MFA, Faceted by Cluster and Factorplot_all_factor_scores_mfa
Plot All Factor Scores (Z) for MPCA, Faceted by Cluster and Factorplot_all_factor_scores_mpca
Plot Reconstructed Waveforms for All Clusters and Channels (MFA)plot_all_reconstructed_waveforms_mfa
Plot Reconstructed Waveforms for All Clusters and Channels (MPCA)plot_all_reconstructed_waveforms_mpca
Plot Basis UMAP Embeddingplot_basis_umap
Plot BIC Comparison for Parameter Sweepplot_bic_comparison
Line Plot of BIC vs. K or rplot_bic_line
Plot Calibration Curveplot_calibration
Plot Cluster Embeddingplot_cluster_embedding
Plot Cluster-Specific Synergy Coefficients (Factor Loadings) for MFAplot_cluster_synergy_loadings_mfa
Plot Cluster-Specific Synergy Coefficients (Factor Loadings) for MPCAplot_cluster_synergy_loadings_mpca
Plot Confusion Matrix for Cluster Assignmentsplot_confusion_matrix
Plot ARI vs. Separation/Noise (Figure 1)plot_fig1_ARI
Plot Baseline Comparison (ARI and VAF)plot_fig1_baseline_comparison
Plot BIC Heatmap for a Subset (Figure 2)plot_fig2_BIC_heatmap
Plot Boxplot of ARI for Multiple Initial Seeds (Figure 3)plot_fig3_init_boxplot
Plot Reconstruction Error and VAF (Figures 4-6)plot_fig4to6_reconstruction_vaf
Plot Metric vs Axis for Parameter Sweepplot_metric_vs_axis
Plot Neural Command Trajectoriesplot_neural_command
Plot Noise Profilesplot_noise_profiles
Plot Reconstructed EMG Signalsplot_reconstructed_emg
Plot SSE Heatmap Across Methods and Subjectsplot_sse_heatmap
Plot Summary Comparison for Parameter Sweepplot_sweep_summary
Plot Synergy Bases (Lambda Matrices)plot_synergy_bases
Plot Synergy Correlation Comparisonplot_synergy_correlation_comparison
Plot Synergy Summaryplot_synergy_summary
Plot Original vs. Reconstructed Waveform for an MFA Modelplot_waveform_comparison_mfa
Plot Original vs. Reconstructed Waveform for an MPCA Modelplot_waveform_comparison_mpca
Plot Win Rate Heatmap for Parameter Sweepplot_winrate_heatmap
Plot Method for mixture_r_selection Objectsplot.mixture_r_selection
Post-hoc Evaluation of MFA Grid Searchposthoc_mfa_evaluation
Post-hoc Evaluation of Mixture PCA Grid Searchposthoc_mpca_evaluation
EMG Preprocessing Pipelinepreprocess_emg
Print Summary of Bootstrap CI Resultsprint.bootstrap_ci
Print Summary of Calibration Resultsprint.calibration_result
Print Method for mixture_r_selection Objectsprint.mixture_r_selection
Print Method for preprocessed_emg Objectsprint.preprocessed_emg
Read All Results from .rds Filesread_all_results
Read All Results and Produce Tables/Figuresread_and_visualize_all
Reconstruct a single subject's data from a Mixture PCA modelreconstruct_singleMPCA
Rectify EMG Signalrectify
Remove DC Offset from EMG Signalremove_dc_offset
Post-hoc Rotation for an MFA Modelrotate_mfa_model
Post-hoc Rotation for a Mixture PCA Modelrotate_mpca_model
Run K Selection Method Comparison (v3)run_k_selection_comparison
Run Parameter Sweep Experimentrun_param_sweep
Run Parameter Sweep for Baseline Method Comparisons (v2)run_param_sweep_baselines
Run Parameter Sweep with Model Selectionrun_param_sweep_modelsel
Run a Single Task from Parameter Gridrun_single_task
Run Parameter Sweep Using Futurerun_sweep_future
Get Unified Color Scale for Discrete Categoriesscale_color_mixsynergy
Get Unified Viridis Color Scale for Continuous Valuesscale_fill_mixsynergy
Get Unified Fill Scale for Discrete Categoriesscale_fill_mixsynergy_discrete
Get Unified Viridis Color Scale for Diverging Valuesscale_fill_mixsynergy_diverging
Select K Using Bootstrap Stability Selectionselect_K_bootstrap_stability
Select K Using Cross-Validationselect_K_crossvalidation
Unified Model Selection for K and rselect_K_r
Search for the Best (K, r) for MFA via Grid Search (Using mfa_em_fit)select_optimal_K_r_mfa
Two-Stage Model Selection for MFA: Select K First, Then rselect_optimal_K_r_mfa_twostage
Search for the Best (K, r) for Mixture PCA via Grid Searchselect_optimal_K_r_mpca
Two-Stage Model Selection for MPCA: Select K First, Then rselect_optimal_K_r_mpca_twostage
Select Optimal r by Smoothness Penalty for MFAselect_r_by_smoothness_mfa
Select Optimal r by Smoothness Penalty for MPCAselect_r_by_smoothness_mpca
Select Minimum r Based on VAF Threshold for MFAselect_r_by_vaf_mfa
Select Minimum r Based on VAF Threshold for MPCAselect_r_by_vaf_mpca
Select Optimal r by VSS Criterion for MFAselect_r_by_vss_mfa
Select Optimal r by VSS Criterion for MPCAselect_r_by_vss_mpca
Select Optimal r Using Cluster-wise Evaluation for MFAselect_r_clusterwise_mfa
Select Optimal r Using Cluster-wise Evaluation for MPCAselect_r_clusterwise_mpca
Select Optimal r Using Global Model (FA or PPCA) with Cross-Validationselect_r_global_mfa
Select Optimal r Using Global Model (PPCA) with Cross-Validation for MPCAselect_r_global_mpca
Unified r Selection for Mixture Models (MFA/MPCA)select_r_mixture
Select Optimal r Using Multi-Criteria Approach for MFAselect_r_multicriteria_mfa
Select Optimal r Using Multi-Criteria Approach for MPCAselect_r_multicriteria_mpca
Setup Future Backend for HPCsetup_future_backend
Print Summary of Available Parallelization Optionsshow_parallel_options
Simulate Dynamic Synergy Data with Three Orthogonal Control Axessimulate_dynamic_synergy_data
Simulation Comparison Functionssimulation_comparison
Simulation Visualization Functionssimulation_visualization
Strip All Attributes Except Essential Onesstrip_attributes
Submit Parameter Sweep to HPC (Simple Interface)submit_hpc_sweep
Submit PBS Parameter Sweepsubmit_pbs_sweep
Summarize VAF and SSE for an MFA Modelsummarize_vaf_sse_mfa
Summary Method for mixture_r_selection Objectssummary.mixture_r_selection
Summary Method for preprocessed_emg Objectssummary.preprocessed_emg
Unified Theme and Style Definitions for synergyMixR Visualizationstheme_mixsynergy
Get Unified Heatmap Theme for synergyMixRtheme_mixsynergy_heatmap
Theme for Parameter Sweep Plotstheme_sweep
Visualization Functions for Two-Step Algorithm Diagnosticsvisualize_twostep_diagnostics
Wait for PBS Job Completionwait_for_pbs_job