<p>The <a href="https://rdrr.io/bioc/scran/man/quickCluster.html" rel="nofollow noreferrer"><code>scran::quickCluster</code> method</a> has a <code>BPPARAM</code> (i.e., <code>BiocParallelParam</code>), so if one provides something like</p>

<pre><code>clusters &lt;- quickCluster(sce, BPPARAM=BiocParallel::MulticoreParam())
</code></pre>

<p>it will use all available cores (a specific number of cores can also be given). See <a href="https://bioconductor.org/packages/devel/bioc/vignettes/BiocParallel/inst/doc/Introduction_To_BiocParallel.pdf" rel="nofollow noreferrer">the intro doc to <code>BiocParallel</code></a> for info on other options.</p>

CC BY-SA 4.0
2020-01-20T21:18:30.180Z
2020-01-20T21:18:30.180Z
merv
<p>I need to implement a parallel version of an R script because on one core it takes forever to execute. The function that takes the most of time is <code>scran::quickCluster()</code> applied to an integer sparse matrix (<code>UMI_count</code>) that is <code>26000x66000</code>. The code is presented below:</p>

<pre><code>library(scran)
library(scater)
sce &lt;- newSCESet(countData=UMI_count)
clusters &lt;- quickCluster(sce)
sce &lt;- computeSumFactors(sce, cluster=clusters)
</code></pre>

<p>I did not find much on parallel versions of <code>quickCluster()</code> function, so will it actually execute in parallel if I set the number of cores to more than one? I am trying to do normalization of heterogeneous dataset with multiple cell types, that is why I am using <a href="https://bioconductor.org/packages/release/bioc/vignettes/scran/inst/doc/scran.html" rel="nofollow noreferrer"><code>quickCluster()</code></a>.</p>

<p>And I just need to speed it up to be able to compute it.</p>

CC BY-SA 3.0
2018-01-04T15:30:29.563Z
Do you really have to use a sparse matrix? A matrix of that size with 64-bit integers is still <20GB and not have any of the annoyances of a sparse matrix.
Devon Ryan
CC BY-SA 3.0
2018-01-04T17:04:20.833Z
But will it speed up quickCluster() function in any way? I can convert it to regular matrix on the cluster (that gives up to 120Gb of RAM).
Nikita Vlasenko
CC BY-SA 3.0
2018-01-04T18:36:54.117Z
I suspect it will, it's generally easier to work with normal matrices.
Devon Ryan
<r><scran>
Normalization using parallel R script
# Normalization using parallel R script

(Asked by: username_0 on 2018-01-03)

I need to implement a parallel version of an R script because on one core it takes forever to execute. The function that takes the most of time is scran::quickCluster() applied to an integer sparse matrix (UMI_count) that is 26000x66000. The code is presented below:
library(scran)
library(scater)
sce <- newSCESet(countData=UMI_count)
clusters <- quickCluster(sce)
sce <- computeSumFactors(sce, cluster=clusters)

I did not find much on parallel versions of quickCluster() function, so will it actually execute in parallel if I set the number of cores to more than one? I am trying to do normalization of heterogeneous dataset with multiple cell types, that is why I am using quickCluster().
And I just need to speed it up to be able to compute it.

**Tags:** r, scran
> **Comments:**
> **username_1**: Do you really have to use a sparse matrix? A matrix of that size with 64-bit integers is still <20GB and not have any of the annoyances of a sparse matrix.  
> **username_0**: But will it speed up quickCluster() function in any way? I can convert it to regular matrix on the cluster (that gives up to 120Gb of RAM).  
> **username_1**: I suspect it will, it's generally easier to work with normal matrices.  

---

## 1 answers

### Answer by username_2 on 2020-01-20. Score: 2

The scran::quickCluster method has a BPPARAM (i.e., BiocParallelParam), so if one provides something like
clusters <- quickCluster(sce, BPPARAM=BiocParallel::MulticoreParam())

it will use all available cores (a specific number of cores can also be given). See the intro doc to BiocParallel for info on other options.


---

