This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
howto:bioinformatics [2025/05/01 23:20] nmfuphi |
howto:bioinformatics [2025/05/21 10:50] (current) nmfuphi [Singularity] |
||
|---|---|---|---|
| Line 195: | Line 195: | ||
| ===== Software Environments ===== | ===== Software Environments ===== | ||
| + | |||
| + | ==== Conda ==== | ||
| + | Many scientific software tools rely on specific versions of libraries, compilers, and dependencies that often conflict with each other or with system-wide installations. **Conda** is a powerful, language-agnostic environment and package manager that helps solve this problem by allowing users to manage **Python**, **R**, **C/C++**, **FORTRAN**, | ||
| + | |||
| + | === Shared Conda Environments === | ||
| + | |||
| + | For most use cases, especially in bioinformatics, | ||
| + | |||
| + | '/ | ||
| + | |||
| + | These environments are curated by CHPC staff to include commonly used tools in genomics, transcriptomics, | ||
| + | |||
| + | === Step-by-step usage === | ||
| + | |||
| + | === Step 1: Load required modules === | ||
| + | To access Conda functionality, | ||
| + | <code bash> | ||
| + | module load chpc/ | ||
| + | module load conda_init | ||
| + | </ | ||
| + | |||
| + | The second module updates your .bashrc file by adding necessary shell variables. | ||
| + | To apply these changes, you can either log out and log back in, or run: <code bash> | ||
| + | After this setup, you won’t need to load additional modules for your jobs—only the eval and conda activate steps are required. | ||
| + | |||
| + | === Step 2: Initialize Conda in your shell === | ||
| + | Activate Conda shell integration: | ||
| + | <code bash> | ||
| + | eval " | ||
| + | </ | ||
| + | |||
| + | This command sets up your shell environment to recognize Conda commands like `conda activate`. | ||
| + | |||
| + | === Step 3: List available environments === | ||
| + | <code bash> | ||
| + | conda info --envs | ||
| + | </ | ||
| + | |||
| + | This will display all available shared Conda environments and their paths. | ||
| + | |||
| + | === Step 4: Activate a shared environment === | ||
| + | <code bash> | ||
| + | conda activate nameOfTheEnv | ||
| + | </ | ||
| + | |||
| + | Replace '' | ||
| + | |||
| + | > **Tip:** If you're unsure which environment to use, contact CHPC support or explore the environment' | ||
| + | |||
| + | > **Note:** You do **not** need to install anything when using shared environments. | ||
| + | |||
| + | === Creating Private Conda Environments === | ||
| + | |||
| + | If you need software that is not included in the shared environments, | ||
| + | |||
| + | > **Important: | ||
| + | |||
| + | === Step-by-step setup === | ||
| + | ssh to username@scp.chpc.ac.za, | ||
| + | === Step 1: Load Conda === | ||
| + | <code bash> | ||
| + | module load chpc/ | ||
| + | module load conda_init | ||
| + | eval " | ||
| + | </ | ||
| + | |||
| + | === Step 2: Create a new environment === | ||
| + | <code bash> | ||
| + | conda create --prefix / | ||
| + | </ | ||
| + | |||
| + | This will create a Conda environment at the specified path with Python 3.10 installed. You can replace the Python version or leave it out if not needed. | ||
| + | |||
| + | === Step 3: Activate your environment === | ||
| + | <code bash> | ||
| + | conda activate / | ||
| + | </ | ||
| + | |||
| + | After activation, you can install any packages you need. | ||
| + | |||
| + | === Step 4: (Optional) Install Mamba for faster package management === | ||
| + | <code bash> | ||
| + | conda install mamba -n base -c conda-forge | ||
| + | </ | ||
| + | |||
| + | > **Tip:** Mamba is a drop-in replacement for Conda that uses a faster dependency solver written in C++. Once installed, you can use `mamba` instead of `conda` for installing packages: | ||
| + | <code bash> | ||
| + | mamba install numpy pandas | ||
| + | </ | ||
| + | |||
| + | This significantly speeds up installations and environment solves, especially when working with large scientific packages. | ||
| + | |||
| + | |||
| + | === Step 5: Install packages === | ||
| + | <code bash> | ||
| + | conda install numpy pandas matplotlib | ||
| + | </ | ||
| + | |||
| + | You can install packages one by one, or include them during environment creation: | ||
| + | <code bash> | ||
| + | conda create --prefix / | ||
| + | </ | ||
| + | |||
| + | === Step 6: Remove unused environments === | ||
| + | Old or unused environments can be removed to free up space: | ||
| + | <code bash> | ||
| + | conda remove --prefix / | ||
| + | </ | ||
| + | |||
| + | === Best Practices === | ||
| + | * ✅ Use **shared environments** whenever possible for consistency and faster setup. | ||
| + | * 📁 Create private environments **only in Lustre** directories, | ||
| + | * ⚠️ Do **not** use Conda in your '' | ||
| + | * 📌 Use the '' | ||
| + | * 🧼 Periodically clean up unused environments with `conda remove --all`. | ||
| + | * 🔁 Reuse environment definitions by exporting and sharing them with others or for reproducibility. | ||
| + | |||
| + | === Troubleshooting === | ||
| + | * ❓ **Conda not recognized? | ||
| + | * 🚫 **Permission denied?** You might be trying to write to a restricted directory like ''/ | ||
| + | * 🔄 **Environment behaving unexpectedly? | ||
| + | * 🧪 **Conflicts during install?** Use `conda clean --all` to clear caches and retry with a minimal environment. | ||
| ==== Singularity ==== | ==== Singularity ==== | ||
| Line 340: | Line 462: | ||
| #PBS -N singularity_job | #PBS -N singularity_job | ||
| #PBS -q normal | #PBS -q normal | ||
| - | #PBS -l select=1: | + | #PBS -l select=1: |
| #PBS -l walltime=12: | #PBS -l walltime=12: | ||
| #PBS -o singularity_output.log | #PBS -o singularity_output.log | ||
| Line 357: | Line 479: | ||
| </ | </ | ||
| + | ==== Nextflow ==== | ||
| - | **Need Help?** | + | Nextflow is a free and open-source workflow management system that enables the development and execution of data analysis pipelines. It simplifies complex computational workflows and ensures reproducibility, |
| + | [[https:// | ||
| - | Submit a ticket: | + | === Running Nextflow on the CHPC Cluster === |
| - | 👉 https:// | + | CHPC supports Nextflow workflows through Singularity containers. Since compute nodes have no internet access, all dependencies must be downloaded in advance on the login node. |
| - | **Include:** | + | === 1. Connect to the Login Node === |
| + | |||
| + | Log into the CHPC login node using your Lengau credentials: | ||
| + | |||
| + | <code bash> ssh username@scp.chpc.ac.za </ | ||
| + | |||
| + | Use this session to prepare your workflow and submit jobs. | ||
| + | |||
| + | === 2. Load the Nextflow Module === | ||
| + | |||
| + | Load the necessary environment modules: | ||
| + | |||
| + | <code bash> | ||
| + | module load chpc/ | ||
| + | </ | ||
| + | |||
| + | Note: Modules must be reloaded in every new session unless added to your ~/ | ||
| + | |||
| + | === 3. Pull Workflow and Dependencies === | ||
| + | |||
| + | Pull your workflow and dependencies on the login1 node: | ||
| + | |||
| + | Pull the workflow: | ||
| + | <code bash> nextflow pull nf-core/ | ||
| + | |||
| + | Run a test execution: | ||
| + | <code bash> nextflow run nf-core/ | ||
| + | |||
| + | This will: | ||
| + | |||
| + | Cache the workflow in ~/ | ||
| + | |||
| + | Download containers (if configured) | ||
| + | |||
| + | Retrieve auxiliary files and dependencies | ||
| + | |||
| + | === Cached Files and Workflow Structure === | ||
| + | |||
| + | Workflow code is stored in: | ||
| + | < | ||
| + | |||
| + | Container images are stored in: | ||
| + | < | ||
| + | |||
| + | **🗂 Finding the nextflow.config File** | ||
| + | |||
| + | After pulling a workflow, you’ll typically find the nextflow.config file in its root directory. | ||
| + | |||
| + | Example: | ||
| + | <code bash> | ||
| + | cd ~/ | ||
| + | ls | ||
| + | </ | ||
| + | |||
| + | Look for: | ||
| + | < | ||
| + | If missing, config files may reside in the conf/ directory or be fetched remotely. You can always override settings by creating your own nextflow.config. | ||
| + | |||
| + | 🚫 No Manual PBS Scripts Needed | ||
| + | Nextflow automatically generates and submits PBS scripts. You only define resources in nextflow.config. | ||
| + | |||
| + | === ⚙️ Configuration with nextflow.config === | ||
| + | |||
| + | == 🔧 1. Global Resource Settings == | ||
| + | |||
| + | Set default resource usage for all workflow processes: | ||
| + | |||
| + | <code nextflow> | ||
| + | executor = ' | ||
| + | |||
| + | withLabel: big_job { | ||
| + | queue = ' | ||
| + | cpus = 24 | ||
| + | memory = '120 GB' | ||
| + | time = ' | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | == 🏷️ 2. Custom Resource Labels == | ||
| + | |||
| + | Customize resources for specific process groups using labels: | ||
| + | |||
| + | <code nextflow> | ||
| + | process { | ||
| + | executor = ' | ||
| + | |||
| + | withLabel: big_job { | ||
| + | cpus = 16 | ||
| + | memory = '64 GB' | ||
| + | time = ' | ||
| + | queue = ' | ||
| + | } | ||
| + | |||
| + | withLabel: short_job { | ||
| + | cpus = 1 | ||
| + | memory = '1 GB' | ||
| + | time = ' | ||
| + | queue = ' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | Use the label in your pipeline: | ||
| + | <code nextflow> | ||
| + | process bigTask { | ||
| + | label ' | ||
| + | ... | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | == 📦 3. Singularity Integration == | ||
| + | |||
| + | Enable Singularity support: | ||
| + | |||
| + | <code nextflow> | ||
| + | singularity.autoMounts = true </ | ||
| + | |||
| + | Specify containers: | ||
| + | |||
| + | From Docker Hub: | ||
| + | <code nextflow> | ||
| + | process.container = ' | ||
| + | </ | ||
| + | From local image: | ||
| + | <code nextflow> | ||
| + | process.container = '/ | ||
| + | </ | ||
| + | |||
| + | Set cache directory to avoid re-downloads: | ||
| + | |||
| + | <code nextflow> | ||
| + | == 🖥️ 4. PBS Executor Settings == | ||
| + | |||
| + | Customize PBS job submission: | ||
| + | |||
| + | |||
| + | <code nextflow> | ||
| + | executor { | ||
| + | name = ' | ||
| + | queueSize = 20 | ||
| + | submitOptions = '-V -m abe -M your@email.com' | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | == 📂 5. Using Profiles == | ||
| + | |||
| + | Profiles let you switch configurations easily: | ||
| + | |||
| + | <code nextflow> | ||
| + | standard { | ||
| + | process.executor = ' | ||
| + | process.queue = ' | ||
| + | } | ||
| + | |||
| + | local { | ||
| + | process.executor = ' | ||
| + | docker.enabled = false | ||
| + | } | ||
| + | |||
| + | cluster_singularity { | ||
| + | process.executor = ' | ||
| + | singularity.enabled = true | ||
| + | process.container = ' | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | Run a profile: | ||
| + | |||
| + | <code bash> nextflow run main.nf -profile cluster_singularity </ | ||
| + | |||
| + | == 🚫 Offline Mode == | ||
| + | |||
| + | Run jobs on compute nodes without internet access: | ||
| + | |||
| + | <code bash> nextflow run ~/ | ||
| + | -profile singularity -offline </ | ||
| + | ⚠️ Always include -offline on compute nodes to prevent online fetching. | ||
| + | |||
| + | === 🧭 Debugging and Logs === | ||
| + | |||
| + | Each Nextflow process generates a unique work directory (work/ | ||
| + | |||
| + | .command.run — generated PBS job script | ||
| + | |||
| + | .command.sh — wrapped shell script | ||
| + | |||
| + | .command.log — job output | ||
| + | |||
| + | .exitcode — exit status | ||
| + | |||
| + | To inspect a failed job: | ||
| + | |||
| + | <code bash> cd work/ | ||
| + | less .command.log </ | ||
| + | |||
| + | === ✅ Summary === | ||
| + | |||
| + | nextflow.config centralizes all pipeline settings. | ||
| + | |||
| + | No need to write PBS scripts manually. | ||
| + | |||
| + | Resources, container usage, and submission options are all configurable. | ||
| + | |||
| + | Profiles improve portability and reproducibility. | ||
| + | |||
| + | Offline mode is essential for CHPC compute node compatibility. | ||
| + | |||
| + | 🧠 Tip: For workflows requiring reference data, bind directories just like with containers: | ||
| + | |||
| + | <code bash> nextflow run / | ||
| + | --input / | ||
| + | --genomeDir / | ||
| + | </ | ||
| + | |||
| + | 🧹 Clean Up: | ||
| + | Nextflow stores all its cache files in your home directory, so it's important to clean up these files once you're finished using a workflow to avoid running out of space. | ||
| + | <code bash> | ||
| + | rm -rf ~/ | ||
| + | rm -rf ~/ | ||
| + | rm -rf ~/ | ||
| + | </ | ||
| - | The commands | + | === Need Help? === |
| + | If you encounter issues or need a specific tool installed contact the CHPC support team at: | ||
| + | * 📧 help@chpc.ac.za | ||
| + | * https:// | ||
| + | Include your job script | ||
| ===== Basic examples ===== | ===== Basic examples ===== | ||