-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathazimuth-classification.html
286 lines (265 loc) · 29.5 KB
/
azimuth-classification.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Chapter 5 Azimuth classification | WG2: Cell-type classification</title>
<meta name="author" content="Jose Alquicira Hernandez and Lieke Michelsen">
<meta name="description" content="Cell type classification using the azimuth method can be performed using map_azimuth.R. Let’s create an output directory to store the results. mkdir step2_azimuth And check the input arguments...">
<meta name="generator" content="bookdown 0.24 with bs4_book()">
<meta property="og:title" content="Chapter 5 Azimuth classification | WG2: Cell-type classification">
<meta property="og:type" content="book">
<meta property="og:url" content="https://github.com/powellgenomicslab/WG2-pipeline-classification-docs/azimuth-classification.html">
<meta property="og:description" content="Cell type classification using the azimuth method can be performed using map_azimuth.R. Let’s create an output directory to store the results. mkdir step2_azimuth And check the input arguments...">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Chapter 5 Azimuth classification | WG2: Cell-type classification">
<meta name="twitter:description" content="Cell type classification using the azimuth method can be performed using map_azimuth.R. Let’s create an output directory to store the results. mkdir step2_azimuth And check the input arguments...">
<!-- JS --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://kit.fontawesome.com/6ecbd6c532.js" crossorigin="anonymous"></script><script src="libs/header-attrs-2.11/header-attrs.js"></script><script src="libs/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="libs/bootstrap-4.6.0/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-4.6.0/bootstrap.bundle.min.js"></script><script src="libs/bs3compat-0.3.1/transition.js"></script><script src="libs/bs3compat-0.3.1/tabs.js"></script><script src="libs/bs3compat-0.3.1/bs3compat.js"></script><link href="libs/bs4_book-1.0.0/bs4_book.css" rel="stylesheet">
<script src="libs/bs4_book-1.0.0/bs4_book.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/0.38.0/autocomplete.jquery.min.js" integrity="sha512-GU9ayf+66Xx2TmpxqJpliWbT5PiGYxpaG8rfnBEk1LL8l1KGkRShhngwdXK1UgqhAzWpZHSiYPc09/NwDQIGyg==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js" integrity="sha512-5CYOlHXGh6QpOFA/TeTylKLWfB3ftPsde7AnmhuitiTX4K5SqCLBeKro6sPS8ilsz1Q4NRx3v8Ko2IBiszzdww==" crossorigin="anonymous"></script><!-- CSS --><link rel="stylesheet" href="bs4_style.css">
</head>
<body data-spy="scroll" data-target="#toc">
<div class="container-fluid">
<div class="row">
<header class="col-sm-12 col-lg-3 sidebar sidebar-book"><a class="sr-only sr-only-focusable" href="#content">Skip to main content</a>
<div class="d-flex align-items-start justify-content-between">
<h1>
<a href="index.html" title="">WG2: Cell-type classification</a>
</h1>
<button class="btn btn-outline-primary d-lg-none ml-2 mt-1" type="button" data-toggle="collapse" data-target="#main-nav" aria-expanded="true" aria-controls="main-nav"><i class="fas fa-bars"></i><span class="sr-only">Show table of contents</span></button>
</div>
<div id="main-nav" class="collapse-lg">
<form role="search">
<input id="search" class="form-control" type="search" placeholder="Search" aria-label="Search">
</form>
<nav aria-label="Table of contents"><h2>Table of contents</h2>
<ul class="book-toc list-unstyled">
<li><a class="" href="index.html"><span class="header-section-number">1</span> About</a></li>
<li><a class="" href="general.html"><span class="header-section-number">2</span> General</a></li>
<li><a class="" href="getting-started.html"><span class="header-section-number">3</span> Getting started</a></li>
<li><a class="" href="split-data.html"><span class="header-section-number">4</span> Split data</a></li>
<li><a class="active" href="azimuth-classification.html"><span class="header-section-number">5</span> Azimuth classification</a></li>
<li><a class="" href="hierarchical-scpred-classification.html"><span class="header-section-number">6</span> Hierarchical scPred classification</a></li>
<li><a class="" href="merge-data.html"><span class="header-section-number">7</span> Merge data</a></li>
<li><a class="" href="compare-classifications.html"><span class="header-section-number">8</span> Compare classifications</a></li>
</ul>
<div class="book-extra">
<p><a id="book-repo" href="https://github.com/powellgenomicslab/WG2-pipeline-classification-docs">View book source <i class="fab fa-github"></i></a></p>
</div>
</nav>
</div>
</header><main class="col-sm-12 col-md-9 col-lg-7" id="content"><div id="azimuth-classification" class="section level1" number="5">
<h1>
<span class="header-section-number">5</span> Azimuth classification<a class="anchor" aria-label="anchor" href="#azimuth-classification"><i class="fas fa-link"></i></a>
</h1>
<p>Cell type classification using the <strong>azimuth</strong> method can be performed using
<code>map_azimuth.R</code>.</p>
<p>Let’s create an output directory to store the results.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb7-1"><a href="azimuth-classification.html#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="fu">mkdir</span> step2_azimuth</span></code></pre></div>
<p>And check the input arguments</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb8-1"><a href="azimuth-classification.html#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">singularity</span> exec <span class="at">-B</span> <span class="va">$PWD</span> cell_classification.sif <span class="dt">\ </span></span>
<span id="cb8-2"><a href="azimuth-classification.html#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">Rscript</span> /map_azimuth.R <span class="at">--help</span></span></code></pre></div>
<pre><code>Usage: map_azimuth.R [options]
Options:
--file=CHARACTER
RDS object file name
--batch=CHARACTER
Batch column. If provided, each group in from the batch columns is mapped to reference independently
--plan=CHARACTER
Strategy to resolve future [default= sequential]:
multisession
multicore
cluster
remote
transparent
--workers=NUMERIC
Number of workers used for parallelization
[default= 1]
--mem=NUMERIC
Maximum allowed total size (in GB) of global variables identified
[default= Inf]
--out=CHARACTER
Output file name [default= azimuth]
--path=CHARACTER
Output path to store results [default= .]
-h, --help
Show this help message and exit</code></pre>
<p>Further data splitting and classification can be performed within <code>map_azimuth.R</code>
however, we’ll classify cells for each of the partitions we already created.</p>
<blockquote>
<p>Although the <code>batch</code> parameter is provided as an option to perform cell type
classification within <code>map_azimuth.R</code>, we encourage users to previously split their data by batch using <code>split.R</code> and run sequential or parallel jobs for each batch as
shown below to reduce RAM memory usage and reduce computation time</p>
</blockquote>
<blockquote>
<p>If <code>batch</code> is used, the <code>future.globals.maxSize</code> parameter from the <code>future</code> package can be manually changed via the <code>--mem</code> argument when running <code>map_azimuth.R</code>. By default, this value is set to infinity to allow complete use of the allocated memory for each CPU. However, users may experience issues depending on the computing infrastructure. This value therefore can be changed in these cirmunstances. The <code>--mem</code> value must be in Gb.</p>
</blockquote>
<p>We can classify each batch within a loop using <code>map_azimuth.R</code> as follows:</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb10-1"><a href="azimuth-classification.html#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> i <span class="kw">in</span> <span class="va">$(</span><span class="fu">ls</span> step1_split<span class="va">)</span><span class="kw">;</span></span>
<span id="cb10-2"><a href="azimuth-classification.html#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="cf">do</span></span>
<span id="cb10-3"><a href="azimuth-classification.html#cb10-3" aria-hidden="true" tabindex="-1"></a> <span class="va">out</span><span class="op">=</span><span class="va">$(</span><span class="bu">echo</span> <span class="va">$i</span> <span class="kw">|</span> <span class="fu">awk</span> <span class="st">'gsub(".RDS", "")'</span><span class="va">)</span> <span class="co"># Use same base filename as output</span></span>
<span id="cb10-4"><a href="azimuth-classification.html#cb10-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">singularity</span> run <span class="at">-B</span> <span class="va">$PWD</span> cell_classification.sif <span class="dt">\ </span></span>
<span id="cb10-5"><a href="azimuth-classification.html#cb10-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">Rscript</span> /map_azimuth.R <span class="dt">\</span></span>
<span id="cb10-6"><a href="azimuth-classification.html#cb10-6" aria-hidden="true" tabindex="-1"></a> <span class="at">--file</span> step1_split/<span class="va">${i}</span> <span class="dt">\</span></span>
<span id="cb10-7"><a href="azimuth-classification.html#cb10-7" aria-hidden="true" tabindex="-1"></a> <span class="at">--path</span> step2_azimuth <span class="dt">\</span></span>
<span id="cb10-8"><a href="azimuth-classification.html#cb10-8" aria-hidden="true" tabindex="-1"></a> <span class="at">--out</span> <span class="va">${out}</span></span>
<span id="cb10-9"><a href="azimuth-classification.html#cb10-9" aria-hidden="true" tabindex="-1"></a><span class="cf">done</span></span></code></pre></div>
<p>In this example, the output is stored in <code>step2_azimuth</code> including each
Seurat object containing:</p>
<ul>
<li><p>Cell type classification (<code>predicted.celltype.l2</code>) + prediction scores
(<code>predicted.celltype.l2.scores</code>) stored in the metadata</p></li>
<li>
<p>Reference-based reductions:</p>
<ul>
<li>azimuth_spca: Supervised PCA</li>
<li>azimuth_umap: UMAP generated using the WNN graph</li>
</ul>
</li>
<li><p>A new assay called <code>predicted_ADT</code> containing imputed protein data based on
RNA</p></li>
</ul>
<p>Additionally, plots for the <code>azimuth_spca</code> and <code>azimuth_umap</code> reductions are included
as outputs for exploratory data analysis.</p>
<div class="figure">
<img src="_bookdown_files/spca.png" style="width:100.0%" alt=""><p class="caption">PCA embeddings projected onto the reference supervised PCA</p>
</div>
<div class="figure">
<img src="_bookdown_files/umap.png" style="width:100.0%" alt=""><p class="caption">Query dataset projected onto the reference UMAP</p>
</div>
<div id="parallelize-classification" class="section level2" number="5.1">
<h2>
<span class="header-section-number">5.1</span> Parallelize classification<a class="anchor" aria-label="anchor" href="#parallelize-classification"><i class="fas fa-link"></i></a>
</h2>
</div>
<div id="sge-example" class="section level2" number="5.2">
<h2>
<span class="header-section-number">5.2</span> SGE example<a class="anchor" aria-label="anchor" href="#sge-example"><i class="fas fa-link"></i></a>
</h2>
<p>The following array job code in SGE (Sun Grid Engine) can be used as a guide to
classify each pool in individual jobs. This code snippet was used to
classify multiple Seurat objects (75 pools) from the OneK1K dataset.</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb11-1"><a href="azimuth-classification.html#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="co">#$ -N clasify_cells</span></span>
<span id="cb11-2"><a href="azimuth-classification.html#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="co">#$ -q short.q</span></span>
<span id="cb11-3"><a href="azimuth-classification.html#cb11-3" aria-hidden="true" tabindex="-1"></a><span class="co">#$ -l mem_requested=50G</span></span>
<span id="cb11-4"><a href="azimuth-classification.html#cb11-4" aria-hidden="true" tabindex="-1"></a><span class="co">#$ -S /bin/bash</span></span>
<span id="cb11-5"><a href="azimuth-classification.html#cb11-5" aria-hidden="true" tabindex="-1"></a><span class="co">#$ -r yes</span></span>
<span id="cb11-6"><a href="azimuth-classification.html#cb11-6" aria-hidden="true" tabindex="-1"></a><span class="co">#$ -cwd </span></span>
<span id="cb11-7"><a href="azimuth-classification.html#cb11-7" aria-hidden="true" tabindex="-1"></a><span class="co">#$ -o results/2021-10-28_cell_type_annotation</span></span>
<span id="cb11-8"><a href="azimuth-classification.html#cb11-8" aria-hidden="true" tabindex="-1"></a><span class="co">#$ -e results/2021-10-28_cell_type_annotation</span></span>
<span id="cb11-9"><a href="azimuth-classification.html#cb11-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-10"><a href="azimuth-classification.html#cb11-10" aria-hidden="true" tabindex="-1"></a><span class="co"># mkdir results/2021-10-28_cell_type_annotation</span></span>
<span id="cb11-11"><a href="azimuth-classification.html#cb11-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-12"><a href="azimuth-classification.html#cb11-12" aria-hidden="true" tabindex="-1"></a><span class="bu">cd</span> <span class="va">$SGE_O_WORKDIR</span></span>
<span id="cb11-13"><a href="azimuth-classification.html#cb11-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-14"><a href="azimuth-classification.html#cb11-14" aria-hidden="true" tabindex="-1"></a><span class="co"># Set environmental variables</span></span>
<span id="cb11-15"><a href="azimuth-classification.html#cb11-15" aria-hidden="true" tabindex="-1"></a><span class="va">input</span><span class="op">=</span>results/2021-10-28_pools</span>
<span id="cb11-16"><a href="azimuth-classification.html#cb11-16" aria-hidden="true" tabindex="-1"></a><span class="va">output</span><span class="op">=</span>results/2021-10-28_cell_type_annotation</span>
<span id="cb11-17"><a href="azimuth-classification.html#cb11-17" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-18"><a href="azimuth-classification.html#cb11-18" aria-hidden="true" tabindex="-1"></a><span class="co"># Get job info</span></span>
<span id="cb11-19"><a href="azimuth-classification.html#cb11-19" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">"JOB: </span><span class="va">$JOB_ID</span><span class="st"> TASK: </span><span class="va">$SGE_TASK_ID</span><span class="st"> HOSTNAME: </span><span class="va">$HOSTNAME</span><span class="st">"</span></span>
<span id="cb11-20"><a href="azimuth-classification.html#cb11-20" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-21"><a href="azimuth-classification.html#cb11-21" aria-hidden="true" tabindex="-1"></a><span class="co"># Get basefile name</span></span>
<span id="cb11-22"><a href="azimuth-classification.html#cb11-22" aria-hidden="true" tabindex="-1"></a><span class="va">files</span><span class="op">=</span><span class="va">($(</span><span class="fu">ls</span> <span class="va">${input}</span> <span class="kw">|</span> <span class="fu">grep</span> <span class="st">".RDS"</span><span class="va">))</span></span>
<span id="cb11-23"><a href="azimuth-classification.html#cb11-23" aria-hidden="true" tabindex="-1"></a><span class="va">i</span><span class="op">=</span><span class="st">"</span><span class="va">$(($SGE_TASK_ID</span><span class="op">-</span><span class="dv">1</span><span class="va">))</span><span class="st">"</span></span>
<span id="cb11-24"><a href="azimuth-classification.html#cb11-24" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-25"><a href="azimuth-classification.html#cb11-25" aria-hidden="true" tabindex="-1"></a><span class="va">filename</span><span class="op">=</span><span class="va">${files</span><span class="op">[</span><span class="va">$i</span><span class="op">]</span><span class="va">}</span></span>
<span id="cb11-26"><a href="azimuth-classification.html#cb11-26" aria-hidden="true" tabindex="-1"></a><span class="va">filename</span><span class="op">=</span><span class="va">$(</span><span class="bu">echo</span> <span class="va">$filename</span> <span class="kw">|</span> <span class="fu">sed</span> <span class="st">'s/.RDS//'</span><span class="va">)</span></span>
<span id="cb11-27"><a href="azimuth-classification.html#cb11-27" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-28"><a href="azimuth-classification.html#cb11-28" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">"Classifying: </span><span class="va">$filename</span><span class="st">"</span></span>
<span id="cb11-29"><a href="azimuth-classification.html#cb11-29" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-30"><a href="azimuth-classification.html#cb11-30" aria-hidden="true" tabindex="-1"></a><span class="co"># Run main command</span></span>
<span id="cb11-31"><a href="azimuth-classification.html#cb11-31" aria-hidden="true" tabindex="-1"></a><span class="ex">singularity</span> exec <span class="at">-B</span> <span class="va">$SGE_O_WORKDIR</span> bin/cell_classification.sif <span class="dt">\</span></span>
<span id="cb11-32"><a href="azimuth-classification.html#cb11-32" aria-hidden="true" tabindex="-1"></a> Rscript /map_azimuth.R <span class="dt">\</span></span>
<span id="cb11-33"><a href="azimuth-classification.html#cb11-33" aria-hidden="true" tabindex="-1"></a> <span class="at">--file</span> <span class="va">${input}</span>/<span class="va">${filename}</span>.RDS <span class="dt">\</span></span>
<span id="cb11-34"><a href="azimuth-classification.html#cb11-34" aria-hidden="true" tabindex="-1"></a> <span class="at">--out</span> <span class="va">${filename}</span>_out <span class="dt">\</span></span>
<span id="cb11-35"><a href="azimuth-classification.html#cb11-35" aria-hidden="true" tabindex="-1"></a> <span class="at">--path</span> <span class="va">${output}</span></span></code></pre></div>
<p>If we save the previous code into a file (e.g. <code>run_azimuth.sh</code>), we can launch
an array job iterating for each pool name</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb12-1"><a href="azimuth-classification.html#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="ex">qsub</span> <span class="at">-t</span> 1-75 bin/run_azimuth.sh</span>
<span id="cb12-2"><a href="azimuth-classification.html#cb12-2" aria-hidden="true" tabindex="-1"></a><span class="co"># -t Vector of length equal to the number of pools (.RDS files)</span></span></code></pre></div>
</div>
<div id="slurm-example" class="section level2" number="5.3">
<h2>
<span class="header-section-number">5.3</span> SLURM example<a class="anchor" aria-label="anchor" href="#slurm-example"><i class="fas fa-link"></i></a>
</h2>
<p>Likewise, we can run the same code using a SLURM scheduler as follows:</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb13-1"><a href="azimuth-classification.html#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="co">#!/bin/bash</span></span>
<span id="cb13-2"><a href="azimuth-classification.html#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="co">#SBATCH -J azimuth</span></span>
<span id="cb13-3"><a href="azimuth-classification.html#cb13-3" aria-hidden="true" tabindex="-1"></a><span class="co">#SBATCH -N 1</span></span>
<span id="cb13-4"><a href="azimuth-classification.html#cb13-4" aria-hidden="true" tabindex="-1"></a><span class="co">#SBATCH -n 1</span></span>
<span id="cb13-5"><a href="azimuth-classification.html#cb13-5" aria-hidden="true" tabindex="-1"></a><span class="co">#SBATCH --time=0:30:00 </span></span>
<span id="cb13-6"><a href="azimuth-classification.html#cb13-6" aria-hidden="true" tabindex="-1"></a><span class="co">#SBATCH --mem=40GB</span></span>
<span id="cb13-7"><a href="azimuth-classification.html#cb13-7" aria-hidden="true" tabindex="-1"></a><span class="co">#SBATCH --error=job.%J.err</span></span>
<span id="cb13-8"><a href="azimuth-classification.html#cb13-8" aria-hidden="true" tabindex="-1"></a><span class="co">#SBATCH --output=job.%J.out</span></span>
<span id="cb13-9"><a href="azimuth-classification.html#cb13-9" aria-hidden="true" tabindex="-1"></a><span class="co">#SBATCH --mail-type=</span><span class="re">END</span><span class="co">,FAIL</span></span>
<span id="cb13-10"><a href="azimuth-classification.html#cb13-10" aria-hidden="true" tabindex="-1"></a><span class="co">#SBATCH --mail-user=l.c.m.michielsen@lumc.nl</span></span>
<span id="cb13-11"><a href="azimuth-classification.html#cb13-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-12"><a href="azimuth-classification.html#cb13-12" aria-hidden="true" tabindex="-1"></a><span class="co"># Clear the environment from any previously loaded modules</span></span>
<span id="cb13-13"><a href="azimuth-classification.html#cb13-13" aria-hidden="true" tabindex="-1"></a><span class="ex">module</span> purge </span>
<span id="cb13-14"><a href="azimuth-classification.html#cb13-14" aria-hidden="true" tabindex="-1"></a><span class="ex">module</span> add container/singularity/3.7.3/gcc.8.3.1</span>
<span id="cb13-15"><a href="azimuth-classification.html#cb13-15" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-16"><a href="azimuth-classification.html#cb13-16" aria-hidden="true" tabindex="-1"></a><span class="co"># Set environmental variables</span></span>
<span id="cb13-17"><a href="azimuth-classification.html#cb13-17" aria-hidden="true" tabindex="-1"></a><span class="va">input</span><span class="op">=</span>DataGroningen/step1_split</span>
<span id="cb13-18"><a href="azimuth-classification.html#cb13-18" aria-hidden="true" tabindex="-1"></a><span class="va">output</span><span class="op">=</span>DataGroningen/output_Azimuth</span>
<span id="cb13-19"><a href="azimuth-classification.html#cb13-19" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-20"><a href="azimuth-classification.html#cb13-20" aria-hidden="true" tabindex="-1"></a><span class="co"># Get job info</span></span>
<span id="cb13-21"><a href="azimuth-classification.html#cb13-21" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">"Starting at </span><span class="kw">`</span><span class="fu">date</span><span class="kw">`</span><span class="st">"</span></span>
<span id="cb13-22"><a href="azimuth-classification.html#cb13-22" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">"JOB: </span><span class="va">$SLURM_JOB_ID</span><span class="st"> TASK: </span><span class="va">$SLURM_ARRAY_TASK_ID</span><span class="st">"</span></span>
<span id="cb13-23"><a href="azimuth-classification.html#cb13-23" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-24"><a href="azimuth-classification.html#cb13-24" aria-hidden="true" tabindex="-1"></a><span class="co"># Get basefile name</span></span>
<span id="cb13-25"><a href="azimuth-classification.html#cb13-25" aria-hidden="true" tabindex="-1"></a><span class="va">files</span><span class="op">=</span><span class="va">($(</span><span class="fu">ls</span> <span class="va">${input}</span> <span class="kw">|</span> <span class="fu">grep</span> <span class="st">".RDS"</span><span class="va">))</span></span>
<span id="cb13-26"><a href="azimuth-classification.html#cb13-26" aria-hidden="true" tabindex="-1"></a><span class="va">i</span><span class="op">=</span><span class="st">"</span><span class="va">$SLURM_ARRAY_TASK_ID</span><span class="st">"</span></span>
<span id="cb13-27"><a href="azimuth-classification.html#cb13-27" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-28"><a href="azimuth-classification.html#cb13-28" aria-hidden="true" tabindex="-1"></a><span class="va">filename</span><span class="op">=</span><span class="va">${files</span><span class="op">[</span><span class="va">$i</span><span class="op">]</span><span class="va">}</span></span>
<span id="cb13-29"><a href="azimuth-classification.html#cb13-29" aria-hidden="true" tabindex="-1"></a><span class="va">filename</span><span class="op">=</span><span class="va">$(</span><span class="bu">echo</span> <span class="va">$filename</span> <span class="kw">|</span> <span class="fu">sed</span> <span class="st">'s/.RDS//'</span><span class="va">)</span></span>
<span id="cb13-30"><a href="azimuth-classification.html#cb13-30" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-31"><a href="azimuth-classification.html#cb13-31" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">"Classifying: </span><span class="va">$filename</span><span class="st">"</span></span>
<span id="cb13-32"><a href="azimuth-classification.html#cb13-32" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-33"><a href="azimuth-classification.html#cb13-33" aria-hidden="true" tabindex="-1"></a><span class="co"># Run main command</span></span>
<span id="cb13-34"><a href="azimuth-classification.html#cb13-34" aria-hidden="true" tabindex="-1"></a><span class="ex">singularity</span> exec <span class="at">-B</span> <span class="va">$PWD</span> cell_classification.sif <span class="dt">\</span></span>
<span id="cb13-35"><a href="azimuth-classification.html#cb13-35" aria-hidden="true" tabindex="-1"></a> Rscript /map_azimuth.R <span class="dt">\</span></span>
<span id="cb13-36"><a href="azimuth-classification.html#cb13-36" aria-hidden="true" tabindex="-1"></a> <span class="at">--file</span> <span class="va">${input}</span>/<span class="va">${filename}</span>.RDS <span class="dt">\</span></span>
<span id="cb13-37"><a href="azimuth-classification.html#cb13-37" aria-hidden="true" tabindex="-1"></a> <span class="at">--batch</span> lane <span class="dt">\</span></span>
<span id="cb13-38"><a href="azimuth-classification.html#cb13-38" aria-hidden="true" tabindex="-1"></a> <span class="at">--out</span> <span class="va">${filename}</span>_out <span class="dt">\</span></span>
<span id="cb13-39"><a href="azimuth-classification.html#cb13-39" aria-hidden="true" tabindex="-1"></a> <span class="at">--path</span> <span class="va">${output}</span></span></code></pre></div>
<p>If we save the previous code into a file (e.g. <code>run_azimuth.sbatch</code>), we can launch
an array job iterating for each batch</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb14-1"><a href="azimuth-classification.html#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="ex">sbatch</span> <span class="at">-a</span> 0-30 run_azimuth.sbatch</span>
<span id="cb14-2"><a href="azimuth-classification.html#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="co"># -a Vector of length equal to the number .RDS files</span></span></code></pre></div>
</div>
</div>
<div class="chapter-nav">
<div class="prev"><a href="split-data.html"><span class="header-section-number">4</span> Split data</a></div>
<div class="next"><a href="hierarchical-scpred-classification.html"><span class="header-section-number">6</span> Hierarchical scPred classification</a></div>
</div></main><div class="col-md-3 col-lg-2 d-none d-md-block sidebar sidebar-chapter">
<nav id="toc" data-toggle="toc" aria-label="On this page"><h2>On this page</h2>
<ul class="nav navbar-nav">
<li><a class="nav-link" href="#azimuth-classification"><span class="header-section-number">5</span> Azimuth classification</a></li>
<li><a class="nav-link" href="#parallelize-classification"><span class="header-section-number">5.1</span> Parallelize classification</a></li>
<li><a class="nav-link" href="#sge-example"><span class="header-section-number">5.2</span> SGE example</a></li>
<li><a class="nav-link" href="#slurm-example"><span class="header-section-number">5.3</span> SLURM example</a></li>
</ul>
<div class="book-extra">
<ul class="list-unstyled">
<li><a id="book-source" href="https://github.com/powellgenomicslab/WG2-pipeline-classification-docs/blob/master/05-azimuth.Rmd">View source <i class="fab fa-github"></i></a></li>
<li><a id="book-edit" href="https://github.com/powellgenomicslab/WG2-pipeline-classification-docs/edit/master/05-azimuth.Rmd">Edit this page <i class="fab fa-github"></i></a></li>
</ul>
</div>
</nav>
</div>
</div>
</div> <!-- .container -->
<footer class="bg-primary text-light mt-5"><div class="container"><div class="row">
<div class="col-12 col-md-6 mt-3">
<p>"<strong>WG2: Cell-type classification</strong>" was written by Jose Alquicira Hernandez and Lieke Michelsen. It was last built on 2022-06-14.</p>
</div>
<div class="col-12 col-md-6 mt-3">
<p>This book was built by the <a class="text-light" href="https://bookdown.org">bookdown</a> R package.</p>
</div>
</div></div>
</footer>
</body>
</html>