The following shell script is submitted to a high-performance computing (HPC) cluster as a SLURM job array to process each of the samples in parallel.
The script pulls a cellranger_manifest.txt file from data directory with at two columns: sample_id and cellranger_output path for each sample as follow
sample_1
path/to/sample_1/fastq
sample_2
path/to/sample_2/fastq
sample_3
path/to/sample_3/fastq
Code
#!/bin/bash#SBATCH --account=#SBATCH --job-name='cellranger_hg38_%a'#SBATCH --output=logs/cellranger_hg38_%a.log#SBATCH --partition=standard#SBATCH --mem=128G#SBATCH --cpus-per-task=16#SBATCH --time=48:00:00#SBATCH --array=1-7mkdir-p logs# Import modulesml cellranger/7.1.0# Setting up variablessamples_manifest=../data/cellranger_manifest.txtref=../data/references/refdata-gex-GRCh38-2020-AoutputDir=../outputs/alignmentmkdir-p$outputDir# Extracting sample for the current job current_sample_name=$(cat$samples_manifest|cut-f1|sed-n${SLURM_ARRAY_TASK_ID}p)current_sample_path=$(cat$samples_manifest|cut-f2|sed-n${SLURM_ARRAY_TASK_ID}p)echo"Analyzing Sample $current_sample_name"echo-e"Fastq path $current_sample_path"# Running cellrangercellranger count --id=${current_sample_name}\--transcriptome=$ref\--fastqs=$current_sample_path\--sample=$current_sample_name\--localcores=16mv${current_sample_name}$outputDir