> For the complete documentation index, see [llms.txt](https://stereotoolss-organization.gitbook.io/saw-user-manual-v8.2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stereotoolss-organization.gitbook.io/saw-user-manual-v8.2/advanced/parallel-computing.md).

# Parallel computing

## Parallel alignment of FASTQs

Read alignment and annotation are typically the most resource-intensive steps during the analysis process. Consequently, parallel processing of transcriptome alignment is especially crucial. The decision to enable parallel computing depends on **the available memory and the number of threads designated for the analysis**, whether it is in local mode or cluster mode.

{% hint style="info" %}
The number of parallel tasks is determined by **the smaller value** of either **\[Maximum free memory/memory required for an alignment subtask]** or **\[Setting threads/threads required for an alignment subtask]**.
{% endhint %}

### Resource settings

For instance, if set 150 GB of memory and 24 threads to start `SAW count` run like:

<pre class="language-sh"><code class="lang-sh">#analysis script
saw count \
...
--id=FASTQ_parallel_alignment \
<strong>--memory=150 \
</strong><strong>--threads-num=24 \
</strong>...
</code></pre>

and generate a specific [resource configuration file](/saw-user-manual-v8.2/advanced/cluster-mode.md#resource-configuration) or check the `/saw-8.2.X/config/resources.yaml`

<pre class="language-sh"><code class="lang-sh">#resource configuration yaml
version: "1.0"

global:
  scheduler: "sge"
  default_setting:
    max_retries: 0

schedulers: 
  sge:
    queue: " "
    
rules:
...
  alignment:  #read alignment
<strong>    threads: 16
</strong>    mem_gb: null  ##assume the memory consumption of a subtask is 60GB
    retry_factor: 1.5
...
</code></pre>

{% hint style="success" %}
The memory required for the read alignment of a pair of FASTQ does not need to be specified. The program will automatically calculate and utilize the number of CID sites in Stereo-seq chip mask.
{% endhint %}

Assume that the memory required for a pair of FASTQ alignments, namely a read alignment subtask, is 60 GB. Therefore, a minimum of \[150 GB / 60 GB] and \[24 / 16] will be utilized for parallel processing. Clearly, this analysis task can only **be executed serially** under the aforementioned settings.

The most straightforward way is to modify the resource settings:

<pre class="language-sh"><code class="lang-sh">#analysis script
saw count \
...
--id=FASTQ_parallel_alignment \
--memory=150 \  #memory is enough
<strong>--threads-num=32 \  #give more threads, 32/16=2
</strong>...
</code></pre>

or

<pre class="language-sh"><code class="lang-sh">#resource configuration yaml
version: "1.0"

global:
  scheduler: "sge"
  default_setting:
    max_retries: 0

schedulers: 
  sge:
    queue: " "
    
rules:
...
  alignment:  #read alignment
<strong>    threads: 12   #reduce the number of threads for a single task, 24/12=2
</strong>    mem_gb: null  ##assume the memory consumption of a subtask is 60GB
    retry_factor: 1.5
...
</code></pre>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://stereotoolss-organization.gitbook.io/saw-user-manual-v8.2/advanced/parallel-computing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
