workflow.html 98.8 KB
Newer Older
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
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Workflow example • GRN</title>
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="../bootstrap-toc.css">
<script src="../bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous">
<!-- clipboard.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><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script><meta property="og:title" content="Workflow example">
<meta property="og:description" content="GRN">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]--><!-- Global site tag (gtag.js) - Google Analytics --><script async src="https://www.googletagmanager.com/gtag/js?id=G-530L9SXFM1"></script><script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-530L9SXFM1');
</script>
</head>
<body data-spy="scroll" data-target="#toc">
    <div class="container template-article">
      <header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <span class="navbar-brand">
        <a class="navbar-link" href="../index.html">GRN</a>
Christian Arnold's avatar
Christian Arnold committed
40
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.10.1</span>
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
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
<li>
  <a href="../index.html"></a>
</li>
<li>
  <a href="../articles/quickStart.html">Getting Started</a>
</li>
<li class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
    Vignettes
     
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu" role="menu">
<li>
      <a href="../articles/quickStart.html">Getting Started</a>
    </li>
    <li>
      <a href="../articles/Introduction.html">Introduction</a>
    </li>
    <li>
      <a href="../articles/workflow.html">Workflow example</a>
    </li>
  </ul>
</li>
<li>
  <a href="../reference/index.html">Reference</a>
</li>
<li>
  <a href="../news/index.html">Changelog &amp; News</a>
</li>
      </ul>
<ul class="nav navbar-nav navbar-right"></ul>
</div>
<!--/.nav-collapse -->
  </div>
<!--/.container -->
</div>
<!--/.navbar -->

      

      </header><script src="workflow_files/header-attrs-2.7/header-attrs.js"></script><div class="row">
  <div class="col-md-9 contents">
    <div class="page-header toc-ignore">
      <h1 data-toc-skip>Workflow example</h1>
                        <h4 class="author">Christian Arnold, Judith Zaugg</h4>
            
Christian Arnold's avatar
Christian Arnold committed
93
            <h4 class="date">1 June 2021</h4>
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
      
      
      <div class="hidden name"><code>workflow.Rmd</code></div>

    </div>

    
        <div class="abstract">
      <p class="abstract">Abstract</p>
      <p>This workflow vignette shows how to use the <em>GRN</em> package in a real-world example. For this purpose, you will use the <em>GRNData</em> package for a more complex analysis to illustrate most of the features from <em>GRN</em>. Importantly, you will also learn in detail how to work with a <em>GRN</em> object and what its main functions and properties are. The vignette will be continuously updated whenever new functionality becomes available or when we receive user feedback.</p>
    </div>
    
<div id="example-workflow" class="section level1">
<h1 class="hasAnchor">
<a href="#example-workflow" class="anchor"></a>Example Workflow</h1>
<p><a name="section1"></a></p>
<p>In the following example, you will use data from the <em>GRNData</em> package to construct a GRN from TODO</p>
<p>First, let’s load the required libraries <em>GRN</em> and <em>GRNData</em>. The <em>tidyverse</em> package is already loaded and attached when loading the <em>GRN</em> package, but we nevertheless load it here explicitly to highlight that we’ll use various <em>tidyverse</em> functions for data import.</p>
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
113
114
<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="http://tidyverse.tidyverse.org">tidyverse</a></span><span class="op">)</span></code></pre></div>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
115
<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va">GRNData</span><span class="op">)</span>
116
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://grp-zaugg.embl-community.io/grn">GRN</a></span><span class="op">)</span></code></pre></div>
Christian Arnold's avatar
Christian Arnold committed
117
118
119
120
<pre><code>## 
## Welcome to the GRN package and thank you for using our software. This is GRN version 0.10.1.
## See the vignettes (type browseVignettes("GRN") or the help pages for how to use it for your analyses.
## All project-related information and ways to contact us can be found here: https://grp-zaugg.embl-community.io/grn</code></pre>
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<div id="general-notes" class="section level2">
<h2 class="hasAnchor">
<a href="#general-notes" class="anchor"></a>General notes</h2>
<p>Each of the <em>GRN</em> functions we mention here in this Vignette comes with sensible default parameters that we found to work well for most of the datasets we tested it with so far. However, <strong>always check the validity and usefulness of the parameters before starting an analysis</strong> to avoid unreasonable results.</p>
</div>
<div id="reading-the-data-required-for-the-grn-package" class="section level2">
<h2 class="hasAnchor">
<a href="#reading-the-data-required-for-the-grn-package" class="anchor"></a>Reading the data required for the <em>GRN</em> package</h2>
<p>To set up a <em>GRN</em> analysis, we first need to read in some data into <em>R</em>. The following data can be used for the <em>GRN</em> package:</p>
<ul>
<li>open chromatin / peak data (from either ATAC-Seq, DNAse-Seq or ChIP-Seq data, for example), hereafter simply referred to as <em>peaks</em>
</li>
<li>RNA-Seq data (gene expression counts for genes across samples)</li>
</ul>
<p>The following data can be used optionally but are not required:</p>
<ul>
<li>sample metadata (e.g., sex, gender, age, sequencing batch, etc)</li>
<li>TAD domains (bed file)</li>
</ul>
<p>So, let’s import the peak and RNA-seq data as a data frame as well as some sample metadata. This can be done in any way you want as long as you end up with the right format.</p>
Christian Arnold's avatar
Christian Arnold committed
141
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
142
143
144
145
146
<code class="sourceCode R"><span class="op">(</span><span class="va">files</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.files.html">list.files</a></span><span class="op">(</span>pattern <span class="op">=</span> <span class="st">"*"</span>, <span class="fu"><a href="https://rdrr.io/r/base/system.file.html">system.file</a></span><span class="op">(</span><span class="st">"extdata"</span>, package <span class="op">=</span> <span class="st">"GRNData"</span><span class="op">)</span>, full.names <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span><span class="op">)</span></code></pre></div>
<pre><code>## [1] "/media/carnold/DATADRIVE1/R/x86_64-pc-linux-gnu-library/3.6/GRNData/extdata/countsATAC.75k.tsv.gz"   
## [2] "/media/carnold/DATADRIVE1/R/x86_64-pc-linux-gnu-library/3.6/GRNData/extdata/countsRNA.sampled.tsv.gz"
## [3] "/media/carnold/DATADRIVE1/R/x86_64-pc-linux-gnu-library/3.6/GRNData/extdata/metadata.sampled.tsv"    
## [4] "/media/carnold/DATADRIVE1/R/x86_64-pc-linux-gnu-library/3.6/GRNData/extdata/TFBS_selected"</code></pre>
Christian Arnold's avatar
Christian Arnold committed
147
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
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
<code class="sourceCode R"><span class="va">file_peaks</span> <span class="op">=</span> <span class="va">files</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/grep.html">grep</a></span><span class="op">(</span><span class="st">"countsATAC.75k.tsv.gz"</span>, <span class="va">files</span><span class="op">)</span><span class="op">]</span>
<span class="va">file_RNA</span> <span class="op">=</span> <span class="va">files</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/grep.html">grep</a></span><span class="op">(</span><span class="st">"countsRNA.sampled.tsv.gz"</span>, <span class="va">files</span><span class="op">)</span><span class="op">]</span>
<span class="va">file_sampleMetadata</span> <span class="op">=</span> <span class="va">files</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/grep.html">grep</a></span><span class="op">(</span><span class="st">"metadata.sampled.tsv"</span>, <span class="va">files</span><span class="op">)</span><span class="op">]</span>
<span class="va">folder_TFBS_first50</span> <span class="op">=</span> <span class="va">files</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/grep.html">grep</a></span><span class="op">(</span><span class="st">"TFBS_selected"</span>, <span class="va">files</span><span class="op">)</span><span class="op">]</span>

<span class="va">countsRNA.df</span> <span class="op">=</span> <span class="fu">read_tsv</span><span class="op">(</span><span class="va">file_RNA</span>, col_types <span class="op">=</span> <span class="fu">cols</span><span class="op">(</span><span class="op">)</span><span class="op">)</span>
<span class="va">countsPeaks.df</span> <span class="op">=</span> <span class="fu">read_tsv</span><span class="op">(</span><span class="va">file_peaks</span>, col_types <span class="op">=</span> <span class="fu">cols</span><span class="op">(</span><span class="op">)</span><span class="op">)</span>
<span class="va">sampleMetadata.df</span> <span class="op">=</span> <span class="fu">read_tsv</span><span class="op">(</span><span class="va">file_sampleMetadata</span>, col_types <span class="op">=</span> <span class="fu">cols</span><span class="op">(</span><span class="op">)</span><span class="op">)</span>

<span class="co"># Let's check how the data looks like</span>
<span class="va">countsRNA.df</span></code></pre></div>
<pre><code>## # A tibble: 35,033 x 30
##    ENSEMBL babk_D bima_D cicb_D coyi_D diku_D eipl_D eiwy_D eofe_D fafq_D febc_D
##    &lt;chr&gt;    &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;
##  1 ENSG00…  48933  48737  60581  93101  84980  91536  85728  35483  69674  58890
##  2 ENSG00…  49916  44086  50706  55893  57239  76418  75934  27926  57526  50491
##  3 ENSG00… 281733 211703 269460 239116 284509 389989 351867 164615 257471 304203
##  4 ENSG00…  98943  77503  92402  80927  96690 138149 115875  64368  91627 100039
##  5 ENSG00…  14749  15571  16540  16383  16886  21892  18045  10026  14663  15830
##  6 ENSG00…  64459  63734  71317  69612  72097 100487  78536  38572  65446  76910
##  7 ENSG00…  57449  55736  70798  66334  66424  91801  94729  40413  56916  66382
##  8 ENSG00…  15451  15570  15534  15945  10583  22601  16086   9275  16092  15291
##  9 ENSG00…  18717  18757  20051  18066  19648  28572  25240  11258  17739  20347
## 10 ENSG00… 168054 147822 178164 154220 168837 244731 215862  89368 158845 180734
## # … with 35,023 more rows, and 19 more variables: fikt_D &lt;dbl&gt;, guss_D &lt;dbl&gt;,
## #   hayt_D &lt;dbl&gt;, hehd_D &lt;dbl&gt;, heja_D &lt;dbl&gt;, hiaf_D &lt;dbl&gt;, iill_D &lt;dbl&gt;,
## #   kuxp_D &lt;dbl&gt;, nukw_D &lt;dbl&gt;, oapg_D &lt;dbl&gt;, oevr_D &lt;dbl&gt;, pamv_D &lt;dbl&gt;,
## #   pelm_D &lt;dbl&gt;, podx_D &lt;dbl&gt;, qolg_D &lt;dbl&gt;, sojd_D &lt;dbl&gt;, vass_D &lt;dbl&gt;,
## #   xugn_D &lt;dbl&gt;, zaui_D &lt;dbl&gt;</code></pre>
Christian Arnold's avatar
Christian Arnold committed
177
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<code class="sourceCode R"><span class="va">countsPeaks.df</span></code></pre></div>
<pre><code>## # A tibble: 75,000 x 32
##    peakID babk_D bima_D cicb_D coyi_D diku_D eipl_D eiwy_D eofe_D fafq_D febc_D
##    &lt;chr&gt;   &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;
##  1 chr14…      2      5      5      3      1      4      1      5      0     13
##  2 chrX:…      3      7     10      5      4      6      3     18      4     22
##  3 chr15…      5     28     38     11     20     19      7     53      5     22
##  4 chr10…      0     12      7      2      5      8      0     11      1     11
##  5 chr12…      5     14     18      5      3     13      5     15      2     25
##  6 chr1:…     12     21     36      6     20     29     12     44      2    105
##  7 chr16…      3     17     16      9      8     16      6     28      3     33
##  8 chr17…      4     11      6      3      0      3      2      9      1     14
##  9 chr13…     10     34     44     12     31     29      9     22      5     82
## 10 chr1:…     21    113     46     28     44     57     47    146     12     91
## # … with 74,990 more rows, and 21 more variables: fikt_D &lt;dbl&gt;, guss_D &lt;dbl&gt;,
## #   hayt_D &lt;dbl&gt;, hehd_D &lt;dbl&gt;, heja_D &lt;dbl&gt;, hiaf_D &lt;dbl&gt;, iill_D &lt;dbl&gt;,
## #   kuxp_D &lt;dbl&gt;, nukw_D &lt;dbl&gt;, oapg_D &lt;dbl&gt;, oevr_D &lt;dbl&gt;, pamv_D &lt;dbl&gt;,
## #   pelm_D &lt;dbl&gt;, podx_D &lt;dbl&gt;, qolg_D &lt;dbl&gt;, sojd_D &lt;dbl&gt;, vass_D &lt;dbl&gt;,
## #   xugn_D &lt;dbl&gt;, zaui_D &lt;dbl&gt;, uaqe_D &lt;dbl&gt;, qaqx_D &lt;dbl&gt;</code></pre>
Christian Arnold's avatar
Christian Arnold committed
197
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<code class="sourceCode R"><span class="va">sampleMetadata.df</span></code></pre></div>
<pre><code>## # A tibble: 31 x 16
##    sample_id assigned assigned_frac atac_date  clone condition diff_start donor
##    &lt;chr&gt;        &lt;dbl&gt;         &lt;dbl&gt; &lt;date&gt;     &lt;dbl&gt; &lt;chr&gt;     &lt;date&gt;     &lt;chr&gt;
##  1 babk_D     5507093         0.211 2015-12-04     2 IFNg_SL1… 2015-10-12 babk 
##  2 bima_D    23275756         0.677 2014-12-12     1 IFNg_SL1… 2014-11-07 bima 
##  3 cicb_D    19751751         0.580 2015-04-24     3 IFNg_SL1… 2015-03-30 cicb 
##  4 coyi_D     6733642         0.312 2015-11-05     3 IFNg_SL1… 2015-09-30 coyi 
##  5 diku_D     7010213         0.195 2015-11-13     1 IFNg_SL1… 2015-10-15 diku 
##  6 eipl_D    16923025         0.520 2015-08-04     1 IFNg_SL1… 2015-06-30 eipl 
##  7 eiwy_D     9807860         0.404 2015-12-02     1 IFNg_SL1… 2015-10-23 eiwy 
##  8 eofe_D    25687477         0.646 2014-12-12     1 IFNg_SL1… 2014-11-01 eofe 
##  9 fafq_D     4600004         0.415 2015-10-14     1 IFNg_SL1… 2015-09-16 fafq 
## 10 febc_D    31712153         0.430 2015-08-04     2 IFNg_SL1… 2015-07-06 febc 
## # … with 21 more rows, and 8 more variables: EB_formation &lt;date&gt;,
## #   macrophage_diff_days &lt;dbl&gt;, medium_changes &lt;dbl&gt;, mt_frac &lt;dbl&gt;,
## #   percent_duplication &lt;dbl&gt;, received_as &lt;chr&gt;, sex &lt;chr&gt;,
## #   short_long_ratio &lt;dbl&gt;</code></pre>
Christian Arnold's avatar
Christian Arnold committed
216
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
217
218
219
220
221
222
223
224
225
226
227
228
<code class="sourceCode R"><span class="co"># Save the name of the respective ID columns</span>
<span class="va">idColumn_peaks</span> <span class="op">=</span> <span class="st">"peakID"</span>
<span class="va">idColumn_RNA</span> <span class="op">=</span> <span class="st">"ENSEMBL"</span></code></pre></div>
<p>While we recommend raw counts for both peaks and RNA-Seq as input and offer several normalization choices in the pipeline, it is also possible to provide pre-normalized data. Note that the normalization method may have a large influence on the resulting <em>GRN</em> network, so make sure the choice of normalization is reasonable. For more details, see the next sections.</p>
<p>As you can see, both peaks and RNA-Seq counts must have exactly one ID column, with all other columns being numeric. For peaks, this column may be called <em>peakID</em>, for example, but the exact name is not important and can be specified as a parameter later when adding the data to the object. The same applies for the RNA-Seq data, whereas a sensible choice here is <em>ensemblID</em>, for example.</p>
<p>For the peak ID column, the required format is “chr:start-end”, with <em>chr</em> denoting the chromosome, followed by “:”, and then <em>start</em>, “-”, and <em>end</em> for the peak start and end, respectively. As the coordinates for the peaks are needed in the pipeline, the format must be exactly as stated here.</p>
<p>You may notice that the peaks and RNA-seq data have different samples being included, and not all are overlapping. This is not a problem and as long as <em>some</em> samples are found in both of them, the <em>GRN</em> pipeline can work with it. Note that only the shared sampels between both data modalities are kept, however, so make sure that the sample names match between them and share as many samples as possible.</p>
</div>
<div id="initialize-a-grn-object" class="section level2">
<h2 class="hasAnchor">
<a href="#initialize-a-grn-object" class="anchor"></a>Initialize a <em>GRN</em> object</h2>
<p>We got all the data in the right format, we can start with our <em>GRN</em> analysis now! We start by specifying some parameters such as the genome assembly version the data have been produced with, as well as some optional object metadata that helps us to distinguish this <em>GRN</em> object from others.</p>
Christian Arnold's avatar
Christian Arnold committed
229
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
230
231
232
233
234
235
236
237
238
239
240
241
242
<code class="sourceCode R"><span class="co">######################### INITIALIZE GRN OBJECT #</span>

<span class="co"># Genome assembly shortcut. Either hg19, hg38 or mm10. Both peaks and RNA data</span>
<span class="co"># must have the same genome assembly</span>
<span class="va">genomeAssembly</span> <span class="op">=</span> <span class="st">"hg38"</span>

<span class="co"># Optional and arbitrary list with information and metadata that is stored within</span>
<span class="co"># the GRN object</span>
<span class="va">objectMetadata.l</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span>name <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/paste.html">paste0</a></span><span class="op">(</span><span class="st">"Macrophages_infected_primed"</span><span class="op">)</span>, file_peaks <span class="op">=</span> <span class="va">file_peaks</span>, 
    file_rna <span class="op">=</span> <span class="va">file_RNA</span>, file_sampleMetadata <span class="op">=</span> <span class="va">file_sampleMetadata</span>, genomeAssembly <span class="op">=</span> <span class="va">genomeAssembly</span><span class="op">)</span>

<span class="va">dir_output</span> <span class="op">=</span> <span class="st">"output"</span>

243
<span class="va">GRN</span> <span class="op">=</span> <span class="fu">GRN</span><span class="fu">::</span><span class="fu"><a href="../reference/initializeGRN.html">initializeGRN</a></span><span class="op">(</span>objectMetadata <span class="op">=</span> <span class="va">objectMetadata.l</span>, outputFolder <span class="op">=</span> <span class="va">dir_output</span>, 
244
    genomeAssembly <span class="op">=</span> <span class="va">genomeAssembly</span><span class="op">)</span></code></pre></div>
Christian Arnold's avatar
Christian Arnold committed
245
246
<pre><code>## INFO [2021-06-01 13:57:14] Empty GRN object created successfully. Type the object name (e.g., GRN) to retrieve summary information about it at any time.</code></pre>
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
247
<code class="sourceCode R"><span class="va">GRN</span></code></pre></div>
Christian Arnold's avatar
Christian Arnold committed
248
<pre><code>## Object of class: GRN  ( version 0.10.1 )
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
## Data summary:
##  Number of peaks: No peak data found.
##  Number of genes: No RNA-seq data found.
## Parameters:
## Provided metadata:
##   name :  Macrophages_infected_primed 
##   file_peaks :  /media/carnold/DATADRIVE1/R/x86_64-pc-linux-gnu-library/3.6/GRNData/extdata/countsATAC.75k.tsv.gz 
##   file_rna :  /media/carnold/DATADRIVE1/R/x86_64-pc-linux-gnu-library/3.6/GRNData/extdata/countsRNA.sampled.tsv.gz 
##   file_sampleMetadata :  /media/carnold/DATADRIVE1/R/x86_64-pc-linux-gnu-library/3.6/GRNData/extdata/metadata.sampled.tsv 
##   genomeAssembly :  hg38 
## Connections:
##  Number of genes (filtered, all):  NA ,  NA</code></pre>
<p>Initializing a <em>GRN</em> object is trivial: All we need to specify is an output folder (this is where all the pipeline output is automatically being saved unless specified otherwise) and the genome assembly shortcut of the data. We currently support <em>hg19</em>, <em>hg38</em>, and <em>mm10</em>. Please contact us if you need additional genomes. The <em>metadata</em> argument is recommended but optional and may contain an arbitrarily complex named list that is stored as additional metadata for the <em>GRN</em> object. Here, we decided to specify a name for the <em>GRN</em> as well as the original paths for all 3 input files and the genome assembly.</p>
<p>For more parameter details, see the R help (<code><a href="../reference/initializeGRN.html">?initializeGRN</a></code>).</p>
<p>At any time point, we can simply “print” a GRN object by typing its name and a summary of the content is printed to the console.</p>
</div>
<div id="add-data" class="section level2">
<h2 class="hasAnchor">
<a href="#add-data" class="anchor"></a>Add data</h2>
<p>We are now ready to fill our empty object with data! After preparing the data beforehand, we can now use the data import function <em>addData</em> to import both peaks and RNA-seq data to the <em>GRN</em> object. In addition to the count tables, we explicitly specify the name of the ID columns. As mentioned before, the sample metadata is optional but recommended if available.</p>
<p>An important consideration is data normalization for RNA and ATAC. We currently support three choices of normalization: <em>quantile</em>, <em>DESeq_sizeFactor</em> and <em>none</em> and refer to the R help for more details (<code><a href="../reference/addData.html">?addData</a></code>). The default for RNA-Seq is a quantile normalization, while for the open chromatin peak data, it is <em>DESeq_sizeFactor</em> (i.e., a “regular” DESeq size factor normalization). Importantly, <em>DESeq_sizeFactor</em> requires raw data, while <em>quantile</em> does not necessarily. We nevertheless recommend raw data as input, although it is also possible to provide pre-normalized data as input and then topping this up with another normalization method or “none”.</p>
Christian Arnold's avatar
Christian Arnold committed
270
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
271
272
273
<code class="sourceCode R"><span class="va">GRN</span> <span class="op">=</span> <span class="fu">GRN</span><span class="fu">::</span><span class="fu"><a href="../reference/addData.html">addData</a></span><span class="op">(</span><span class="va">GRN</span>, <span class="va">countsPeaks.df</span>, normalization_peaks <span class="op">=</span> <span class="st">"DESeq_sizeFactor"</span>, 
    idColumn_peaks <span class="op">=</span> <span class="va">idColumn_peaks</span>, <span class="va">countsRNA.df</span>, normalization_rna <span class="op">=</span> <span class="st">"quantile"</span>, 
    idColumn_RNA <span class="op">=</span> <span class="va">idColumn_RNA</span>, sampleMetadata <span class="op">=</span> <span class="va">sampleMetadata.df</span>, forceRerun <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
Christian Arnold's avatar
Christian Arnold committed
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<pre><code>## INFO [2021-06-01 13:57:15] Normalize counts. Method: DESeq_sizeFactor, ID column: peakID
## INFO [2021-06-01 13:57:20]  Finished successfully. Execution time: 5.4 secs
## INFO [2021-06-01 13:57:20] Normalize counts. Method: quantile, ID column: ENSEMBL
## INFO [2021-06-01 13:57:20]  Finished successfully. Execution time: 0.4 secs
## INFO [2021-06-01 13:57:20] Subset RNA and peaks and keep only shared samples
## INFO [2021-06-01 13:57:20]  Number of samples for RNA before filtering: 29
## INFO [2021-06-01 13:57:20]  Number of samples for peaks before filtering: 31
## INFO [2021-06-01 13:57:20]  29 samples (babk_D,bima_D,cicb_D,coyi_D,diku_D,eipl_D,eiwy_D,eofe_D,fafq_D,febc_D,fikt_D,guss_D,hayt_D,hehd_D,heja_D,hiaf_D,iill_D,kuxp_D,nukw_D,oapg_D,oevr_D,pamv_D,pelm_D,podx_D,qolg_D,sojd_D,vass_D,xugn_D,zaui_D) are shared between the peaks and RNA-Seq data
## WARN [2021-06-01 13:57:20] The following samples from the peaks will be ignored for the classification due to missing overlap with RNA-Seq: uaqe_D,qaqx_D
## INFO [2021-06-01 13:57:20]  Number of samples for RNA after filtering: 29
## INFO [2021-06-01 13:57:20]  Number of samples for peaks data after filtering: 29
## INFO [2021-06-01 13:57:20]  Finished successfully. Execution time: 0.1 secs
## INFO [2021-06-01 13:57:20] Produce 1 permutations of RNA-counts
## INFO [2021-06-01 13:57:20] Shuffling columns 1 times
## INFO [2021-06-01 13:57:20]  Finished successfully. Execution time: 0 secs
## INFO [2021-06-01 13:57:25] Check for overlapping peaks...</code></pre>
290
291
292
293
294
<p>We can see from the output the details for the used normalization method, and the number of samples that are kept in the <em>GRN</em> object. Here, all 29 samples from the RNA data are kept because they are also found in the peak data, while only 29 out of 31 samples from the peak data are also found in the RNA data, resulting in 29 shared samples overall. The RNA counts are also permuted, which will be the basis for all analysis and plots in subsequent steps that repeat the analysis for permuted data in addition to the real, non-permuted data.</p>
</div>
<div id="quality-control-1-pca-plots" class="section level2">
<h2 class="hasAnchor">
<a href="#quality-control-1-pca-plots" class="anchor"></a>Quality control 1: PCA plots</h2>
295
<p>It is time for our first QC plots! Now that we added peak and RNA data to the object, let’s check with a <em>Principal Component Analysis</em> (PCA) for both peak and RNA-seq data as well as the original input and the normalized data (unless normalization has been set to none, in which case they are identical to the original data) where the variation in the data comes from. If sample metadata has been provided in the <em>addData</em> function (something we strongly recommend), they are automatically added to the PCA plots by coloring the PCA results according to the provided metadata, so that potential batch effects can be examined and identified. For more details, see the R help (<code><a href="../reference/plotPCA_all.html">?plotPCA_all</a></code>).</p>
296
<p>Note that while this step is recommended to do, it is fully optional from a workflow point of view.</p>
Christian Arnold's avatar
Christian Arnold committed
297
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
298
<code class="sourceCode R"><span class="va">GRN</span> <span class="op">=</span> <span class="fu">GRN</span><span class="fu">::</span><span class="fu"><a href="../reference/plotPCA_all.html">plotPCA_all</a></span><span class="op">(</span><span class="va">GRN</span>, type <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"rna"</span>, <span class="st">"peaks"</span><span class="op">)</span>, forceRerun <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
Christian Arnold's avatar
Christian Arnold committed
299
<pre><code>## INFO [2021-06-01 13:57:27] 
300
## Plotting PCA and metadata correlation of raw RNA data for all shared samples to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/PCA_sharedSamples_RNA.raw.pdf... This may take a few minutes
Christian Arnold's avatar
Christian Arnold committed
301
302
303
304
305
306
## INFO [2021-06-01 13:57:29] Prepare PCA. Count transformation: vst
## INFO [2021-06-01 13:57:29]  Writing to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/PCA_sharedSamples_RNA.raw.pdf</code></pre>
<pre><code>## INFO [2021-06-01 13:57:32] Performing and summarizing PCs across metadata for top 500 features</code></pre>
<pre><code>## INFO [2021-06-01 13:57:37] Performing and summarizing PCs across metadata for top 1000 features</code></pre>
<pre><code>## INFO [2021-06-01 13:57:41] Performing and summarizing PCs across metadata for top 5000 features</code></pre>
<pre><code>## INFO [2021-06-01 13:57:46] 
307
## Plotting PCA and metadata correlation of normalized RNA data for all shared samples to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/PCA_sharedSamples_RNA.normalized.pdf... This may take a few minutes
Christian Arnold's avatar
Christian Arnold committed
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
## INFO [2021-06-01 13:57:46] Prepare PCA. Count transformation: none
## INFO [2021-06-01 13:57:46]  Writing to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/PCA_sharedSamples_RNA.normalized.pdf</code></pre>
<pre><code>## INFO [2021-06-01 13:57:47] Performing and summarizing PCs across metadata for top 500 features</code></pre>
<pre><code>## INFO [2021-06-01 13:57:51] Performing and summarizing PCs across metadata for top 1000 features</code></pre>
<pre><code>## INFO [2021-06-01 13:57:55] Performing and summarizing PCs across metadata for top 5000 features</code></pre>
<pre><code>## INFO [2021-06-01 13:58:00] Plotting PCA and metadata correlation of raw peaks data for all shared samples to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/PCA_sharedSamples_peaks.raw.pdf... This may take a few minutes
## INFO [2021-06-01 13:58:01] Prepare PCA. Count transformation: vst
## INFO [2021-06-01 13:58:01]  Writing to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/PCA_sharedSamples_peaks.raw.pdf</code></pre>
<pre><code>## INFO [2021-06-01 13:58:05] Performing and summarizing PCs across metadata for top 500 features</code></pre>
<pre><code>## INFO [2021-06-01 13:58:09] Performing and summarizing PCs across metadata for top 1000 features</code></pre>
<pre><code>## INFO [2021-06-01 13:58:14] Performing and summarizing PCs across metadata for top 5000 features</code></pre>
<pre><code>## INFO [2021-06-01 13:58:18] Plotting PCA and metadata correlation of normalized peaks data for all shared samples to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/PCA_sharedSamples_peaks.normalized.pdf... This may take a few minutes
## INFO [2021-06-01 13:58:18] Prepare PCA. Count transformation: none
## INFO [2021-06-01 13:58:18]  Writing to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/PCA_sharedSamples_peaks.normalized.pdf</code></pre>
<pre><code>## INFO [2021-06-01 13:58:21] Performing and summarizing PCs across metadata for top 500 features</code></pre>
<pre><code>## INFO [2021-06-01 13:58:25] Performing and summarizing PCs across metadata for top 1000 features</code></pre>
<pre><code>## INFO [2021-06-01 13:58:29] Performing and summarizing PCs across metadata for top 5000 features</code></pre>
325
<p>We can see from the output that four PDF files have been produced, each of which plots the PCA results for the most variable 500, 1000, and 5000 features, respectively. For reasons of brevity and organization, we describe their interpretation and meaning in detail in the Introductory vignette and not here, however (click here for guidance and example plots).</p>
326
327
328
329
330
331
</div>
<div id="add-tfs-and-tfbs-and-overlap-with-peaks" class="section level2">
<h2 class="hasAnchor">
<a href="#add-tfs-and-tfbs-and-overlap-with-peaks" class="anchor"></a>Add TFs and TFBS and overlap with peaks</h2>
<p>Now it is time to add data for TFs and predicted TF binding sites (TFBS)! Our <em>GRN</em> package requires pre-computed TFBS that need to be in a specific format (see the Introductory Vignette for details). In brief, a 6-column bed file must be present for each TF, with a specific file name that starts with the name of the TF, an arbitrary and optional suffix (here: "_TFBS") and a particular file ending (supported are <em>bed</em> or <em>bed.gz</em>; here, we specify the latter). All these files must be located in a particular folder that the <em>addTFBS</em> functions then searches in order to identify those files that match the specified patterns. We provide example TFBS for the 3 genome assemblies we support, see the comment below and the Introductory Vignette for details.</p>
<p>For more parameter details, see the R help (<code><a href="../reference/addTFBS.html">?addTFBS</a></code> and <code><a href="../reference/overlapPeaksAndTFBS.html">?overlapPeaksAndTFBS</a></code>).</p>
Christian Arnold's avatar
Christian Arnold committed
332
<div class="sourceCode" id="cb36"><pre class="downlit sourceCode r">
333
334
335
336
337
338
339
340
341
<code class="sourceCode R"><span class="co"># Should the pipeline be run for only a subset of TFs or all? The special keyword</span>
<span class="co"># 'all' will use all TF that are found in the TFBS folder; however, if only a</span>
<span class="co"># subset should be considered, specify the subset here with c() and the TF names,</span>
<span class="co"># as shown below</span>

<span class="co"># The TFBS predictions are expected as *.bed files as well as a translation table</span>
<span class="co"># with the name translationTable.csv We provide all files here:</span>
<span class="co"># https://www.embl.de/download/zaugg/GRN/hg19_hg38_mm10_PWMScan.zip (7.5 GB)</span>

342
<span class="va">GRN</span> <span class="op">=</span> <span class="fu">GRN</span><span class="fu">::</span><span class="fu"><a href="../reference/addTFBS.html">addTFBS</a></span><span class="op">(</span><span class="va">GRN</span>, motifFolder <span class="op">=</span> <span class="va">folder_TFBS_first50</span>, TFs <span class="op">=</span> <span class="st">"all"</span>, filesTFBSPattern <span class="op">=</span> <span class="st">"_TFBS"</span>, 
343
    fileEnding <span class="op">=</span> <span class="st">".bed.gz"</span>, forceRerun <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
Christian Arnold's avatar
Christian Arnold committed
344
345
346
347
348
349
350
<pre><code>## INFO [2021-06-01 13:58:32] Checking database folder for matching files: /media/carnold/DATADRIVE1/R/x86_64-pc-linux-gnu-library/3.6/GRNData/extdata/TFBS_selected
## INFO [2021-06-01 13:58:32] Found 75 matching TFs: AIRE.0.C, ANDR.0.A, ANDR.1.A, ANDR.2.A, AP2A.0.A, AP2B.0.B, ARI3A.0.D, ARNT2.0.D, ASCL1.0.A, ASCL2.0.D, ATF2.1.B, ATOH1.0.B, BACH1.0.A, BATF3.0.B, BC11A.0.A, BCL6.0.A, BHA15.0.B, BHE41.0.D, BPTF.0.D, BRAC.0.A, BRCA1.0.D, CDX1.0.C, CDX2.0.A, CEBPA.0.A, CENPB.0.D, CLOCK.0.C, COE1.0.A, COT1.0.C, COT1.1.C, COT2.0.A, COT2.1.A, CTCF.0.A, CTCFL.0.A, CUX2.0.D, DLX1.0.D, DLX2.0.D, DLX4.0.D, DLX6.0.D, DMBX1.0.D, DMRT1.0.D, E2F1.0.A, E2F3.0.A, E2F4.0.A, E2F6.0.A, E2F7.0.B, EGR1.0.A, EGR2.0.A, EGR2.1.A, EHF.0.B, ELF1.0.A, ELF3.0.A, ELK3.0.D, ERR1.0.A, ESR1.0.A, ESR1.1.A, ESR2.0.A, ESR2.1.A, ETS1.0.A, ETS2.0.B, ETV2.0.B, ETV4.0.B, ETV5.0.C, EVI1.0.B, FEZF1.0.C, FLI1.1.A, FOXA3.0.B, FOXB1.0.D, FOXC2.0.D, FOXD2.0.D, FOXD3.0.D, FOXF1.0.D, FOXO4.0.C, FOXP1.0.A, FOXP3.0.D, FUBP1.0.D
## INFO [2021-06-01 13:58:32] Use all TF from the database folder /media/carnold/DATADRIVE1/R/x86_64-pc-linux-gnu-library/3.6/GRNData/extdata/TFBS_selected
## INFO [2021-06-01 13:58:32] Reading file /media/carnold/DATADRIVE1/R/x86_64-pc-linux-gnu-library/3.6/GRNData/extdata/TFBS_selected/translationTable.csv
## INFO [2021-06-01 13:58:32]  Finished successfully. Execution time: 0 secs
## INFO [2021-06-01 13:58:32] Running the pipeline for 75 TF in total.</code></pre>
<div class="sourceCode" id="cb38"><pre class="downlit sourceCode r">
351
<code class="sourceCode R"><span class="va">GRN</span> <span class="op">=</span> <span class="fu">GRN</span><span class="fu">::</span><span class="fu"><a href="../reference/overlapPeaksAndTFBS.html">overlapPeaksAndTFBS</a></span><span class="op">(</span><span class="va">GRN</span>, nCores <span class="op">=</span> <span class="fl">2</span>, forceRerun <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
Christian Arnold's avatar
Christian Arnold committed
352
353
<pre><code>## INFO [2021-06-01 13:58:32] Overlap peaks and TFBS using 2 cores. This may take a few minutes...
## INFO [2021-06-01 13:59:35]  Finished execution using 2 cores. TOTAL RUNNING TIME: 1 mins</code></pre>
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
<p>We see from the output that 75 TFs have been found in the specified input folder, and the number of TFBS that overlap our peaks for each of them. We now successfully added our TFs and TFBS to the <em>GRN</em> object.</p>
</div>
<div id="filter-data-optional" class="section level2">
<h2 class="hasAnchor">
<a href="#filter-data-optional" class="anchor"></a>Filter data (optional)</h2>
<p>Optionally, we can filter both peaks and RNA-Seq data according to various criteria.</p>
<p>For the open chromatin peaks, we currently support three filters:</p>
<ol style="list-style-type: decimal">
<li>Filter by their normalized mean read counts (<em>minNormalizedMean_peaks</em>, default 5)</li>
<li>Filter by their size / width (in bp) and discarding peaks that exceed a particular threshold (<em>maxSize_peaks</em>, default: 10000 bp)</li>
<li>Filter by chromosome (only keep chromosomes that are provided as input to the function, <em>chrToKeep_peaks</em>)</li>
</ol>
<p>For RNA-seq, we currently support the analogous filter as for open chromatin for normalized mean counts as explained above (<em>minNormalizedMeanRNA</em>).</p>
<p>The default values are usually suitable for bulk data and should result in the removal of very few peaks / genes; however, for single-cell data, lowering them may more reasonable. The output will print clearly how many peaks and genes have been filtered, so you can rerun the function with different values if needed.</p>
<p>For more parameter details, see the R help (<code><a href="../reference/filterData.html">?filterData</a></code>).</p>
Christian Arnold's avatar
Christian Arnold committed
369
<div class="sourceCode" id="cb40"><pre class="downlit sourceCode r">
370
371
<code class="sourceCode R"><span class="co"># Chromosomes to keep for peaks. This should be a vector of chromosome names</span>
<span class="va">chrToKeep_peaks</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/paste.html">paste0</a></span><span class="op">(</span><span class="st">"chr"</span>, <span class="fl">1</span><span class="op">:</span><span class="fl">22</span><span class="op">)</span>, <span class="st">"chrX"</span>, <span class="st">"chrY"</span><span class="op">)</span>
372
373
<span class="va">GRN</span> <span class="op">=</span> <span class="fu">GRN</span><span class="fu">::</span><span class="fu"><a href="../reference/filterData.html">filterData</a></span><span class="op">(</span><span class="va">GRN</span>, minNormalizedMean_peaks <span class="op">=</span> <span class="fl">5</span>, minNormalizedMeanRNA <span class="op">=</span> <span class="fl">1</span>, 
    chrToKeep_peaks <span class="op">=</span> <span class="va">chrToKeep_peaks</span>, maxSize_peaks <span class="op">=</span> <span class="fl">10000</span>, forceRerun <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
Christian Arnold's avatar
Christian Arnold committed
374
375
376
377
378
379
380
381
382
383
384
385
386
<pre><code>## INFO [2021-06-01 13:59:35] Filter peaks with a mean across samples of smaller than 5
## INFO [2021-06-01 13:59:35] Removed 10992 peaks out of 75000 because they had a row mean smaller than 5.
## INFO [2021-06-01 13:59:35]  Finished successfully. Execution time: 0.1 secs
## INFO [2021-06-01 13:59:35] Filter and sort peaks and remain only those on the following chromosomes: chr1,chr2,chr3,chr4,chr5,chr6,chr7,chr8,chr9,chr10,chr11,chr12,chr13,chr14,chr15,chr16,chr17,chr18,chr19,chr20,chr21,chr22,chrX,chrY
## INFO [2021-06-01 13:59:35] Filter and sort peaks by size and remain only those smaller than : 10000
## INFO [2021-06-01 13:59:35]  Number of peaks before filtering: 75000
## INFO [2021-06-01 13:59:35]  Number of peaks after filtering : 75000
## INFO [2021-06-01 13:59:36]  Finished successfully. Execution time: 0.3 secs
## INFO [2021-06-01 13:59:36] Collectively, filter 10992 out of 75000 peaks.
## INFO [2021-06-01 13:59:36] Number of remaining peaks: 64008
## INFO [2021-06-01 13:59:36] Filtering normalized RNA-seq counts
## INFO [2021-06-01 13:59:36]  Number of rows in total: 35033
## INFO [2021-06-01 13:59:36]  Flagged 16211 rows because the row mean was smaller than 1</code></pre>
387
<p>We can see from the output that no peaks have been filtered due to their size and almost 11,000 have been filtered due to their small mean read counts, which collectively leaves around 64,000 peaks out of 75,000 originally. For the RNA data, almost half of the data has been filtered (16,211 out of around 35,000 genes).</p>
388
389
390
391
392
393
394
395
396
397
398
399
400
401
</div>
<div id="add-tf-peak-connections" class="section level2">
<h2 class="hasAnchor">
<a href="#add-tf-peak-connections" class="anchor"></a>Add TF-peak connections</h2>
<p>We now have all necessary data in the object to start constructing our network. As explained in the Introduction vignette, we currently support two types of links for our <em>GRN</em> approach:</p>
<ol style="list-style-type: decimal">
<li>TF - peak</li>
<li>peak - gene</li>
</ol>
<p>Let’s start with TF-peak links! By default, we use Pearson to calculate the correlations between TF expression and peak accessibility, but Spearman may sometimes be a better alternative, especially if the diagnostic plots show that the background is not looking as expected.</p>
<p>In addition to creating TF-peak links based on TF expression, we can also correlate a measure that we call <em>TF activity</em> with peak accessibility instead. If the function argument <em>add_TFActivity</em> is set to <em>TRUE</em>, TF-peaks links will be calculated <em>also</em> for TF activity and not only TF expression. Then, the following arguments become also relevant and are ignored otherwise: <em>normalization_TFActivity</em> and <em>remove_negCor_TFActivity</em>. See the Introduction vignette for methodological details.</p>
<p>Lastly, we offer a so called GC-correction that uses a GC-matching background to compare it with the foreground instead of using the full background as comparison. We are still investigating the plausibility and effects of this and therefore mark this feature as experimental as of now.</p>
<p>This function may run a while, and each time-consuming step has a built-in progress bar so the remaining time can be estimated. Note that the TF-peak links are constructed for both the original, non-permuted data (in the corresponding output plots that are produced, this is labeled as <em>original</em>) and permuted data (<em>permuted</em>).</p>
<p>For more parameter options and parameter details, see the R help (<code><a href="../reference/addConnections_TF_peak.html">?addConnections_TF_peak</a></code>).</p>
Christian Arnold's avatar
Christian Arnold committed
402
<div class="sourceCode" id="cb42"><pre class="downlit sourceCode r">
403
<code class="sourceCode R"><span class="va">GRN</span> <span class="op">=</span> <span class="fu">GRN</span><span class="fu">::</span><span class="fu"><a href="../reference/addConnections_TF_peak.html">addConnections_TF_peak</a></span><span class="op">(</span><span class="va">GRN</span>, plotDiagnosticPlots <span class="op">=</span> <span class="cn">TRUE</span>, corMethod <span class="op">=</span> <span class="st">"pearson"</span>, 
404
    forceRerun <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
Christian Arnold's avatar
Christian Arnold committed
405
<pre><code>## INFO [2021-06-01 13:59:36] 
406
407
## Real data
## 
Christian Arnold's avatar
Christian Arnold committed
408
409
410
411
412
413
414
415
416
417
418
419
## INFO [2021-06-01 13:59:36] Calculate TF-peak links for connection type expression
## INFO [2021-06-01 13:59:36]  Correlate expression values and peak counts
## INFO [2021-06-01 13:59:36]   Retain 59 rows from TF/gene data out of 18822 (filter non-TF genes and TF genes with 0 counts throughout and keep only unique ENSEMBL IDs).
## INFO [2021-06-01 13:59:36]   Correlate TF/gene data for 59 unique TF genes and peak counts for 64008 peaks.
## INFO [2021-06-01 13:59:36]   Note: For subsequent steps, the same gene may be associated with multiple TF, depending on the translation table.
## INFO [2021-06-01 13:59:37]   Finished successfully. Execution time: 0.4 secs
## INFO [2021-06-01 13:59:37]  Run FDR calculations for 65 TFs for which TFBS predictions and RNA-Seq data for the corresponding gene are available.
## INFO [2021-06-01 13:59:37]   Skip the following 10 TF due to missing data for RNA-Seq: ATOH1.0.B,CDX1.0.C,CTCFL.0.A,DLX6.0.D,DMRT1.0.D,EHF.0.B,ESR2.0.A,ESR2.1.A,FOXA3.0.B,FOXB1.0.D
## INFO [2021-06-01 13:59:37]   Compute FDR for each TF. This may take a while...
## INFO [2021-06-01 13:59:45]   Finished successfully. Execution time: 9.1 secs
## INFO [2021-06-01 13:59:45]  Finished successfully. Execution time: 9.3 secs
## INFO [2021-06-01 13:59:45] 
420
421
## Permuted data
## 
Christian Arnold's avatar
Christian Arnold committed
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
## INFO [2021-06-01 13:59:46] Shuffling rows per column
## INFO [2021-06-01 13:59:46]  Finished successfully. Execution time: 0.5 secs
## INFO [2021-06-01 13:59:46] Calculate TF-peak links for connection type expression
## INFO [2021-06-01 13:59:46]  Correlate expression values and peak counts
## INFO [2021-06-01 13:59:46]   Retain 59 rows from TF/gene data out of 18822 (filter non-TF genes and TF genes with 0 counts throughout and keep only unique ENSEMBL IDs).
## INFO [2021-06-01 13:59:46]   Correlate TF/gene data for 59 unique TF genes and peak counts for 64008 peaks.
## INFO [2021-06-01 13:59:46]   Note: For subsequent steps, the same gene may be associated with multiple TF, depending on the translation table.
## INFO [2021-06-01 13:59:47]   Finished successfully. Execution time: 1.2 secs
## INFO [2021-06-01 13:59:47]  Run FDR calculations for 65 TFs for which TFBS predictions and RNA-Seq data for the corresponding gene are available.
## INFO [2021-06-01 13:59:47]   Skip the following 10 TF due to missing data for RNA-Seq: ATOH1.0.B,CDX1.0.C,CTCFL.0.A,DLX6.0.D,DMRT1.0.D,EHF.0.B,ESR2.0.A,ESR2.1.A,FOXA3.0.B,FOXB1.0.D
## INFO [2021-06-01 13:59:47]   Compute FDR for each TF. This may take a while...
## INFO [2021-06-01 13:59:55]   Finished successfully. Execution time: 9.2 secs
## INFO [2021-06-01 13:59:55]  Finished successfully. Execution time: 9.9 secs
## INFO [2021-06-01 13:59:55] Plotting FDR curves for each TF to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/TF_peak.fdrCurves_original.pdf
## INFO [2021-06-01 13:59:55]  Including a total of 65 TF. Preparing plots...
## INFO [2021-06-01 13:59:58]  Finished generating plots, start plotting to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/TF_peak.fdrCurves_original.pdf. This may take a few minutes.</code></pre>
<pre><code>## INFO [2021-06-01 14:00:27] Finished writing plots to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/TF_peak.fdrCurves_original.pdf
## INFO [2021-06-01 14:00:27]  Finished successfully. Execution time: 31.4 secs
## INFO [2021-06-01 14:00:27] Plotting FDR curves for each TF to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/TF_peak.fdrCurves_permuted.pdf
## INFO [2021-06-01 14:00:27]  Including a total of 65 TF. Preparing plots...
## INFO [2021-06-01 14:00:29]  Finished generating plots, start plotting to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/TF_peak.fdrCurves_permuted.pdf. This may take a few minutes.</code></pre>
<pre><code>## INFO [2021-06-01 14:00:58] Finished writing plots to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/TF_peak.fdrCurves_permuted.pdf
## INFO [2021-06-01 14:00:58]  Finished successfully. Execution time: 31 secs</code></pre>
445
446
447
448
449
450
<p>From the output, we see that a total of 65 TFs have RNA-seq data available and consequently will be included and correlated with the peak accessibility. The created PDF files are mentioned in the output and these we’ll take a look at now!</p>
</div>
<div id="quality-control-2-diagnostic-plots-for-tf-peak-connections" class="section level2">
<h2 class="hasAnchor">
<a href="#quality-control-2-diagnostic-plots-for-tf-peak-connections" class="anchor"></a>Quality control 2: Diagnostic plots for TF-peak connections</h2>
<p>After adding the TF-peak links to our <em>GRN</em> object, let’s look at some diagnostic plots. The <em>plots</em> folder within the specified output folder when initializing the <em>GRN</em> object should now contain two new files that are named <em>TF_peak.fdrCurves_original.pdf</em> and <em>TF_peak.fdrCurves_permuted.pdf</em>. For reasons of brevity and organization, we describe their interpretation and meaning in detail in the Introductory vignette and not here, however.</p>
451
452
453
454
455
456
457
458
<!-- Here is what the plot for the original data for the TF *SP1.0.A* looks like: -->
<!-- <div align="center"> -->
<!-- <figure> -->
<!-- <img src="figs/TF-peak_diagnosticPlots1.png" height="600px"/> -->
<!-- <figcaption><i>Figure 3 - Diagnostic plots for TF-peak links for a particular TF, *SP1.0.A*.</i></figcaption> -->
<!-- </figure> -->
<!-- </div> -->
<!-- We can see that the TF-peak FDR is below 0.2 for positive correlation bins in the positive direction only (upper plot), while for the negative direction (lower plot), it is always above 0.4, regardless of the correlation bin. Here, correlation bin refers to the correlation of a particular SP1.0.A - peak pair that has been discretized accordingly (i.e., a correlation of 0.07 would go into (0.05-0.10] correlation bin)). Usually, depending on the mode of action of a TF, either one of the two directions may show a low FDR, but rarely both. Thus, positively correlated SP1.0.A - peak pairs seem to be significant and will be retained for the final *GRN* network. As an exercise, check how this plot looks like for the permuted data! Would you expect lower or higher FDRs? -->
459
460
461
462
463
464
</div>
<div id="run-the-ar-classification-and-qc-optional" class="section level2">
<h2 class="hasAnchor">
<a href="#run-the-ar-classification-and-qc-optional" class="anchor"></a>Run the AR classification and QC (optional)</h2>
<p>Transcription factors (TFs) regulate many cellular processes and can therefore serve as readouts of the signaling and regulatory state. Yet for many TFs, the mode of action—repressing or activating transcription of target genes—is unclear. In analogy to our <em>diffTF</em> approach that we recently published to calculate differential TF activity,the classification of TFs into putative transcriptional activators or repressors can also be done from within the <em>GRN</em> framework in an identical fashion.</p>
<p><strong>Note that this step is fully optional and can be skipped. The output of the <em>AR_classification_wrapper</em> function is not used for subsequent steps.</strong>. To keep the memory footprint of the <em>GRN</em> object low, we recommend to set <code>deleteIntermediateData = TRUE</code>.</p>
Christian Arnold's avatar
Christian Arnold committed
465
<div class="sourceCode" id="cb46"><pre class="downlit sourceCode r">
466
467
468
<code class="sourceCode R"><span class="va">GRN</span> <span class="op">=</span> <span class="fu">GRN</span><span class="fu">::</span><span class="fu"><a href="../reference/AR_classification_wrapper.html">AR_classification_wrapper</a></span><span class="op">(</span><span class="va">GRN</span>, significanceThreshold_Wilcoxon <span class="op">=</span> <span class="fl">0.05</span>, 
    plot_minNoTFBS_heatmap <span class="op">=</span> <span class="fl">100</span>, plotDiagnosticPlots <span class="op">=</span> <span class="cn">TRUE</span>, deleteIntermediateData <span class="op">=</span> <span class="cn">TRUE</span>, 
    forceRerun <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
Christian Arnold's avatar
Christian Arnold committed
469
<pre><code>## INFO [2021-06-01 14:00:58]  Connection type expression
470
## 
Christian Arnold's avatar
Christian Arnold committed
471
## INFO [2021-06-01 14:00:58]  Real data
472
## 
Christian Arnold's avatar
Christian Arnold committed
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
## INFO [2021-06-01 14:00:58]  Correlate expression values and peak counts
## INFO [2021-06-01 14:00:58]  Retain 59 rows from TF/gene data out of 18822 (filter non-TF genes and TF genes with 0 counts throughout and keep only unique ENSEMBL IDs).
## INFO [2021-06-01 14:00:58]  Correlate TF/gene data for 59 unique TF genes and peak counts for 64008 peaks.
## INFO [2021-06-01 14:00:58]  Note: For subsequent steps, the same gene may be associated with multiple TF, depending on the translation table.
## INFO [2021-06-01 14:00:58]  Finished successfully. Execution time: 0.4 secs
## INFO [2021-06-01 14:00:58] Compute foreground and background as well as their median values per TF
## INFO [2021-06-01 14:01:01]  Finished successfully. Execution time: 2.5 secs
## INFO [2021-06-01 14:01:01] Calculate classification thresholds for repressors / activators
## INFO [2021-06-01 14:01:01]  Stringency 0.1: -0.0305 / 0.0157
## INFO [2021-06-01 14:01:01]  Stringency 0.05: -0.0439 / 0.0195
## INFO [2021-06-01 14:01:01]  Stringency 0.01: -0.0537 / 0.024
## INFO [2021-06-01 14:01:02]  Stringency 0.001: -0.0564 / 0.0281
## INFO [2021-06-01 14:01:02]  Finished successfully. Execution time: 0.9 secs
## INFO [2021-06-01 14:01:02] Finalize classification
## INFO [2021-06-01 14:01:02]  Perform Wilcoxon test for each TF. This may take a few minutes.
## INFO [2021-06-01 14:01:13]   Stringency 0.1
## INFO [2021-06-01 14:01:13]    Change the following TFs to 'undetermined' as they were classified as activator/repressor before but the Wilcoxon test was not significant: AIRE.0.C,ASCL2.0.D,CUX2.0.D
## INFO [2021-06-01 14:01:13]   Stringency 0.05
## INFO [2021-06-01 14:01:13]    Change the following TFs to 'undetermined' as they were classified as activator/repressor before but the Wilcoxon test was not significant: AIRE.0.C
## INFO [2021-06-01 14:01:13]   Stringency 0.01
## INFO [2021-06-01 14:01:13]    Change the following TFs to 'undetermined' as they were classified as activator/repressor before but the Wilcoxon test was not significant: AIRE.0.C
## INFO [2021-06-01 14:01:13]   Stringency 0.001
## INFO [2021-06-01 14:01:13]    Change the following TFs to 'undetermined' as they were classified as activator/repressor before but the Wilcoxon test was not significant: AIRE.0.C
## INFO [2021-06-01 14:01:13]  Summary of classification:
## INFO [2021-06-01 14:01:13]   Column classification_q0.1_final
## INFO [2021-06-01 14:01:13]    activator: 25,    undetermined: 17,    repressor: 23,    not-expressed: 10
## INFO [2021-06-01 14:01:13]   Column classification_q0.05_final
## INFO [2021-06-01 14:01:13]    activator: 24,    undetermined: 21,    repressor: 20,    not-expressed: 10
## INFO [2021-06-01 14:01:13]   Column classification_q0.01_final
## INFO [2021-06-01 14:01:13]    activator: 21,    undetermined: 28,    repressor: 16,    not-expressed: 10
## INFO [2021-06-01 14:01:13]   Column classification_q0.001_final
## INFO [2021-06-01 14:01:13]    activator: 19,    undetermined: 30,    repressor: 16,    not-expressed: 10
## INFO [2021-06-01 14:01:13]  Finished successfully. Execution time: 11.6 secs
## INFO [2021-06-01 14:01:13] Plotting density plots with foreground and background for each TF to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/TF_classification_densityPlotsForegroundBackground_expression_original.pdf</code></pre>
<pre><code>## INFO [2021-06-01 14:01:15]  Finished successfully. Execution time: 1.7 secs
## INFO [2021-06-01 14:01:15] Plotting AR summary plot to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/TF_classification_stringencyThresholds_expression_original.pdf</code></pre>
<pre><code>## INFO [2021-06-01 14:01:15]  Finished successfully. Execution time: 0 secs
## INFO [2021-06-01 14:01:15] Plotting AR heatmap to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/TF_classification_summaryHeatmap_expression_original.pdf</code></pre>
<pre><code>## INFO [2021-06-01 14:01:16]  Finished successfully. Execution time: 0.8 secs
## INFO [2021-06-01 14:01:16]  Permuted data
513
## 
Christian Arnold's avatar
Christian Arnold committed
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
## INFO [2021-06-01 14:01:16]  Correlate expression values and peak counts
## INFO [2021-06-01 14:01:16]  Retain 59 rows from TF/gene data out of 18822 (filter non-TF genes and TF genes with 0 counts throughout and keep only unique ENSEMBL IDs).
## INFO [2021-06-01 14:01:16]  Correlate TF/gene data for 59 unique TF genes and peak counts for 64008 peaks.
## INFO [2021-06-01 14:01:16]  Note: For subsequent steps, the same gene may be associated with multiple TF, depending on the translation table.
## INFO [2021-06-01 14:01:16]  Finished successfully. Execution time: 0.4 secs
## INFO [2021-06-01 14:01:16] Shuffling rows per column
## INFO [2021-06-01 14:01:17]  Finished successfully. Execution time: 0.4 secs
## INFO [2021-06-01 14:01:17] Compute foreground and background as well as their median values per TF
## INFO [2021-06-01 14:01:18]  Finished successfully. Execution time: 1.4 secs
## INFO [2021-06-01 14:01:18] Calculate classification thresholds for repressors / activators
## INFO [2021-06-01 14:01:19]  Stringency 0.1: -0.0248 / 0.008
## INFO [2021-06-01 14:01:19]  Stringency 0.05: -0.0361 / 0.0093
## INFO [2021-06-01 14:01:20]  Stringency 0.01: -0.0453 / 0.0142
## INFO [2021-06-01 14:01:20]  Stringency 0.001: -0.0495 / 0.0156
## INFO [2021-06-01 14:01:20]  Finished successfully. Execution time: 1.4 secs
## INFO [2021-06-01 14:01:20] Finalize classification
## INFO [2021-06-01 14:01:20]  Perform Wilcoxon test for each TF. This may take a few minutes.
## INFO [2021-06-01 14:01:31]   Stringency 0.1
## INFO [2021-06-01 14:01:31]    Change the following TFs to 'undetermined' as they were classified as activator/repressor before but the Wilcoxon test was not significant: AP2B.0.B,ARNT2.0.D,ATF2.1.B,BRCA1.0.D,CLOCK.0.C,COT2.1.A,E2F1.0.A,ELF1.0.A,ETV5.0.C,FLI1.1.A,FUBP1.0.D
## INFO [2021-06-01 14:01:31]   Stringency 0.05
## INFO [2021-06-01 14:01:31]    Change the following TFs to 'undetermined' as they were classified as activator/repressor before but the Wilcoxon test was not significant: AP2B.0.B,ATF2.1.B,BRCA1.0.D,E2F1.0.A,ELF1.0.A,ETV5.0.C,FLI1.1.A
## INFO [2021-06-01 14:01:31]   Stringency 0.01
## INFO [2021-06-01 14:01:31]    Change the following TFs to 'undetermined' as they were classified as activator/repressor before but the Wilcoxon test was not significant: BRCA1.0.D,E2F1.0.A,ELF1.0.A
## INFO [2021-06-01 14:01:31]   Stringency 0.001
## INFO [2021-06-01 14:01:31]    Change the following TFs to 'undetermined' as they were classified as activator/repressor before but the Wilcoxon test was not significant: BRCA1.0.D,E2F1.0.A
## INFO [2021-06-01 14:01:31]  Summary of classification:
## INFO [2021-06-01 14:01:31]   Column classification_q0.1_final
## INFO [2021-06-01 14:01:31]    activator: 2,    undetermined: 62,    repressor: 1,    not-expressed: 10
## INFO [2021-06-01 14:01:31]   Column classification_q0.05_final
## INFO [2021-06-01 14:01:31]    activator: 1,    undetermined: 63,    repressor: 1,    not-expressed: 10
## INFO [2021-06-01 14:01:31]   Column classification_q0.01_final
## INFO [2021-06-01 14:01:31]    activator: 1,    undetermined: 64,    repressor: 0,    not-expressed: 10
## INFO [2021-06-01 14:01:31]   Column classification_q0.001_final
## INFO [2021-06-01 14:01:31]    activator: 1,    undetermined: 64,    repressor: 0,    not-expressed: 10
## INFO [2021-06-01 14:01:31]  Finished successfully. Execution time: 11.2 secs
## INFO [2021-06-01 14:01:31] Plotting density plots with foreground and background for each TF to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/TF_classification_densityPlotsForegroundBackground_expression_permuted.pdf</code></pre>
<pre><code>## INFO [2021-06-01 14:01:32]  Finished successfully. Execution time: 1.1 secs
## INFO [2021-06-01 14:01:32] Plotting AR summary plot to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/TF_classification_stringencyThresholds_expression_permuted.pdf</code></pre>
<pre><code>## INFO [2021-06-01 14:01:32]  Finished successfully. Execution time: 0 secs
## INFO [2021-06-01 14:01:32] Shuffling rows per column
## INFO [2021-06-01 14:01:33]  Finished successfully. Execution time: 0.5 secs
## INFO [2021-06-01 14:01:33] Plotting AR heatmap to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/TF_classification_summaryHeatmap_expression_permuted.pdf</code></pre>
<pre><code>## INFO [2021-06-01 14:01:34]  Finished successfully. Execution time: 1.4 secs</code></pre>
557
558
559
560
561
562
563
564
565
566
567
568
<p>From the output, we see that the classification has been run for both real and permuted data, as before. For permuted data, almost all TFs are classified as <em>undetermined</em>, while for the non-permuted one, the majority of TFs is either an activator or repressor. This is irrespective of the classification stringency. Overall, this is not surprising and in fact re-assuring and indicates we capture real signal.</p>
<p>The contents of these plots is identical to and uses in fact practically the same code as our <em>diffTF</em> software. We refer to the following links for more details:</p>
<ol style="list-style-type: decimal">
<li><a href="https://doi.org/10.1016/j.celrep.2019.10.106" title="The original publication explaining the method and motivation in detail">diffTF_paper</a></li>
<li>In general, <a href="https://difftf.readthedocs.io" title="the *ReadTheDocs* help for *diffTF*">readtehdocs</a>, and in particular <a href="https://difftf.readthedocs.io/en/latest/chapter2.html#files-comparisontype-diagnosticplotsclassification1-pdf-and-comparisontype-diagnosticplotsclassification2-pdf" title="the following part*">readtehdocs</a>. In <em>File {comparisonType}.diagnosticPlotsClassification1.pdf:, pages 1-4</em>, the content of the files "TF_classification_stringencyThresholds* are explained in detail, while in <em>File {comparisonType}.diagnosticPlotsClassification2.pdf:, Page 20 - end</em> the contents of the files <em>TF_classification_summaryHeatmap</em> and <em>TF_classification_densityPlotsForegroundBackground</em> are elaborated upon.</li>
</ol>
<p>For more parameter details, see the R help (<code><a href="../reference/AR_classification_wrapper.html">?AR_classification_wrapper</a></code>).</p>
</div>
<div id="save-grn-object-to-disk-optional" class="section level2">
<h2 class="hasAnchor">
<a href="#save-grn-object-to-disk-optional" class="anchor"></a>Save GRN object to disk (optional)</h2>
<p>After steps that take up a bit of time, it may make sense to store the <em>GRN</em> object to disk in order to be able to restore it at any time point. This can simply be done, for example, by saving it as an <em>rds</em> file using the built-in function <em>saveRDS</em> from R to save our <em>GRN</em> object in a compressed rds format.</p>
Christian Arnold's avatar
Christian Arnold committed
569
<div class="sourceCode" id="cb54"><pre class="downlit sourceCode r">
570
571
572
573
574
575
576
577
<code class="sourceCode R"><span class="va">GRN_file_outputRDS</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/paste.html">paste0</a></span><span class="op">(</span><span class="va">dir_output</span>, <span class="st">"/GRN.rds"</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/r/base/readRDS.html">saveRDS</a></span><span class="op">(</span><span class="va">GRN</span>, <span class="va">GRN_file_outputRDS</span><span class="op">)</span>

<span class="co"># Read it back into R with GRN = readRDS(GRN_file_outputRDS)</span></code></pre></div>
</div>
<div id="add-peak-gene-connections" class="section level2">
<h2 class="hasAnchor">
<a href="#add-peak-gene-connections" class="anchor"></a>Add peak-gene connections</h2>
578
579
580
581
582
583
584
585
<p>Let’s add now the second type of connections, peak-genes!</p>
<!-- TODO -->
<!-- Type of overlap for gene: Either "TSS" or "full". If "full", any extended peak-gene overlap is taken, regardless of where in the gene it occurs -->
<!-- If set to "TSS", only overlap of extended peaks with the TSS of the gene (assumed to be at the 5' position) is considered -->
<!-- Until 09.09.20, "full" was being used by default, this parameter did not exist before -->
<!-- Only relevant when no TAD domains are provided; if TADs are provided, this parameter can be ignored. -->
<!-- Specifies the neighborhood size in bp (for both upstream and downstream of the peak) for peaks to find genes in vicinity and associate/correlate genes with peaks -->
<!-- Default value 250000, here set to a smaller value to decrease running time -->
586
<p>For more parameter details, see the R help (<code><a href="../reference/addConnections_peak_gene.html">?addConnections_peak_gene</a></code>).</p>
Christian Arnold's avatar
Christian Arnold committed
587
<div class="sourceCode" id="cb55"><pre class="downlit sourceCode r">
588
<code class="sourceCode R"><span class="va">GRN</span> <span class="op">=</span> <span class="fu">GRN</span><span class="fu">::</span><span class="fu"><a href="../reference/addConnections_peak_gene.html">addConnections_peak_gene</a></span><span class="op">(</span><span class="va">GRN</span>, overlapTypeGene <span class="op">=</span> <span class="st">"TSS"</span>, corMethod <span class="op">=</span> <span class="st">"pearson"</span>, 
Christian Arnold's avatar
Christian Arnold committed
589
590
591
    promoterRange <span class="op">=</span> <span class="fl">10000</span>, TADs <span class="op">=</span> <span class="cn">NULL</span>, nCores <span class="op">=</span> <span class="fl">2</span>, plotDiagnosticPlots <span class="op">=</span> <span class="cn">TRUE</span>, forceRerun <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
<pre><code>## INFO [2021-06-01 14:01:46]  Calculate statistics for each peak and gene (mean and CV)
## INFO [2021-06-01 14:01:47] 
592
593
## Real data
## 
Christian Arnold's avatar
Christian Arnold committed
594
595
596
597
598
599
600
## INFO [2021-06-01 14:01:47] Calculate peak-gene correlations for neighborhood size 10000
## INFO [2021-06-01 14:01:47] Calculate peak gene overlaps...
## INFO [2021-06-01 14:01:47] Extend peaks based on user-defined extension size of 10000 up- and downstream.
## INFO [2021-06-01 14:01:47] Reading pre-compiled genome annotation data 
## INFO [2021-06-01 14:01:47]  Finished successfully. Execution time: 0.5 secs
## INFO [2021-06-01 14:01:47]  Iterate through 41912 peak-gene combinations and (if possible) calculate correlations using 2 cores. This may take a few minutes.
## INFO [2021-06-01 14:01:56]  Finished execution using 2 cores. TOTAL RUNNING TIME: 8.5 secs
601
## 
Christian Arnold's avatar
Christian Arnold committed
602
603
604
605
606
## INFO [2021-06-01 14:01:56]  Finished with calculating correlations, creating final data frame and filter NA rows due to missing RNA-seq data
## INFO [2021-06-01 14:01:56]  Initial number of rows: 41912
## INFO [2021-06-01 14:01:56]  Finished. Final number of rows: 18804
## INFO [2021-06-01 14:01:56]  Finished successfully. Execution time: 9.3 secs
## INFO [2021-06-01 14:01:56] 
607
608
## Permuted data
## 
Christian Arnold's avatar
Christian Arnold committed
609
610
611
612
613
614
615
616
## INFO [2021-06-01 14:01:56] Calculate random peak-gene correlations for neighborhood size 10000
## INFO [2021-06-01 14:01:56] Calculate peak gene overlaps...
## INFO [2021-06-01 14:01:56] Extend peaks based on user-defined extension size of 10000 up- and downstream.
## INFO [2021-06-01 14:01:56] Reading pre-compiled genome annotation data 
## INFO [2021-06-01 14:01:56]  Finished successfully. Execution time: 0.4 secs
## INFO [2021-06-01 14:01:57]  Randomize gene-peak links by shuffling the peak IDs.
## INFO [2021-06-01 14:01:57]  Iterate through 41912 peak-gene combinations and (if possible) calculate correlations using 2 cores. This may take a few minutes.
## INFO [2021-06-01 14:02:05]  Finished execution using 2 cores. TOTAL RUNNING TIME: 8.7 secs
617
## 
Christian Arnold's avatar
Christian Arnold committed
618
619
620
621
622
623
624
625
626
627
## INFO [2021-06-01 14:02:05]  Finished with calculating correlations, creating final data frame and filter NA rows due to missing RNA-seq data
## INFO [2021-06-01 14:02:05]  Initial number of rows: 41912
## INFO [2021-06-01 14:02:06]  Finished. Final number of rows: 18808
## INFO [2021-06-01 14:02:06]  Finished successfully. Execution time: 9.4 secs
## INFO [2021-06-01 14:02:06] Plotting diagnostic plots for peak-gene correlations to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/peakGene_diagnosticPlots_all.pdf</code></pre>
<pre><code>## INFO [2021-06-01 14:02:09]  Finished successfully. Execution time: 3.2 secs
## INFO [2021-06-01 14:02:09] Plotting diagnostic plots for peak-gene correlations to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/peakGene_diagnosticPlots_protein_coding.pdf</code></pre>
<pre><code>## INFO [2021-06-01 14:02:12]  Finished successfully. Execution time: 3.1 secs
## INFO [2021-06-01 14:02:12] Plotting diagnostic plots for peak-gene correlations to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/peakGene_diagnosticPlots_protein_coding+lincRNA.pdf</code></pre>
<pre><code>## INFO [2021-06-01 14:02:15]  Finished successfully. Execution time: 3.3 secs</code></pre>
628
629
630
631
632
633
634
635
636
637
638
<p>We see from the output that almost 42,000 peak-gene links have been identified that match our parameters (here: a maximum peak-gene distance of 10 kb). From these 42.000, however, only around 18,804 actually had corresponding RNA-seq data available, while RNA-seq data was missing or has been filtered for the other. This is a rather typical case, as not all known and annotated genes are included in the RNA-seq data in the first place. Similar to before, the correlations have also been performed for the permuted data.</p>
</div>
<div id="quality-control-3-diagnostic-plots-for-peak-gene-connections" class="section level2">
<h2 class="hasAnchor">
<a href="#quality-control-3-diagnostic-plots-for-peak-gene-connections" class="anchor"></a>Quality control 3: Diagnostic plots for peak-gene connections</h2>
<p>Let’s now check some diagnostic plots for the peak-gene connections. In analogy to the other diagnostic plots that we encountered already before, we describe their interpretation and meaning in detail in the Introductory vignette.</p>
</div>
<div id="combine-tf-peak-and-peak-gene-connections-and-filter" class="section level2">
<h2 class="hasAnchor">
<a href="#combine-tf-peak-and-peak-gene-connections-and-filter" class="anchor"></a>Combine TF-peak and peak-gene connections and filter</h2>
<p>Now that we added both TF-peaks and peak-gene links to our <em>GRN</em> object, we are ready to filter and combine them. So far, they are stored separately in the <em>GRN</em> object for various reasons (see the Introductory Vignette for details), but ultimately, we aim for combining them to derive TF-peak-gene connections. To do so, we can simply run the <em>filterGRNAndConnectGenes</em> function and filter the individual TF-peak and peak-gene links to our liking. The function has many more arguments, and we only specify a few in the example below. As before, we get a <em>GRN</em> object back that now contains the merged and filtered TF-peak-gene connections that we can later extract. Some of the filters apply to the TF-peak links, some of them to the peak-gene links, the parameter name is intended to indicate that.</p>
Christian Arnold's avatar
Christian Arnold committed
639
<div class="sourceCode" id="cb60"><pre class="downlit sourceCode r">
640
<code class="sourceCode R"><span class="va">GRN</span> <span class="op">=</span> <span class="fu">GRN</span><span class="fu">::</span><span class="fu"><a href="../reference/filterGRNAndConnectGenes.html">filterGRNAndConnectGenes</a></span><span class="op">(</span><span class="va">GRN</span>, TF_peak.fdr.threshold <span class="op">=</span> <span class="fl">0.2</span>, peak_gene.fdr.threshold <span class="op">=</span> <span class="fl">0.2</span>, 
641
642
    peak_gene.fdr.method <span class="op">=</span> <span class="st">"BH"</span>, gene.types <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"protein_coding"</span>, <span class="st">"lincRNA"</span><span class="op">)</span>, allowMissingTFs <span class="op">=</span> <span class="cn">FALSE</span>, 
    allowMissingGenes <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
Christian Arnold's avatar
Christian Arnold committed
643
644
<pre><code>## INFO [2021-06-01 14:02:15] Filter GRN network
## INFO [2021-06-01 14:02:15] 
645
646
## 
## Real data
Christian Arnold's avatar
Christian Arnold committed
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
## INFO [2021-06-01 14:02:15] Inital number of rows left before all filtering steps: 23153
## INFO [2021-06-01 14:02:15]  Filter network and retain only rows with TF-peak connections with an FDR &lt; 0.2
## INFO [2021-06-01 14:02:15]   Number of TF-peak rows before filtering TFs: 23153
## INFO [2021-06-01 14:02:15]   Number of TF-peak rows after filtering TFs: 4923
## INFO [2021-06-01 14:02:15] 2. Filter peak-gene connections
## INFO [2021-06-01 14:02:15]  Filter genes by gene type, keep only the following gene types: protein_coding, lincRNA
## INFO [2021-06-01 14:02:15]   Number of peak-gene rows before filtering by gene type: 18828
## INFO [2021-06-01 14:02:15]   Number of peak-gene rows after filtering by gene type: 18734
## INFO [2021-06-01 14:02:16] 3. Merging TF-peak with peak-gene connections and filter the combined table...
## INFO [2021-06-01 14:02:16] Inital number of rows left before all filtering steps: 5972
## INFO [2021-06-01 14:02:16]  Filter network and retain only rows with peak_gene.r in the following interval: (0 - 1]
## INFO [2021-06-01 14:02:16]   Number of rows before filtering TFs: 5972
## INFO [2021-06-01 14:02:16]   Number of rows after filtering TFs: 4330
## INFO [2021-06-01 14:02:16]  Calculate FDR based on remaining rows, filter network and retain only rows with peak-gene connections with an FDR &lt; 0.2
## INFO [2021-06-01 14:02:16]   Number of rows before filtering genes (including NA): 4330
## INFO [2021-06-01 14:02:16]   Number of rows before filtering genes (excluding NA): 2368
## INFO [2021-06-01 14:02:16]   Number of rows after filtering genes (including NA): 2593
## INFO [2021-06-01 14:02:16]   Number of rows after filtering genes (excluding NA): 631
## INFO [2021-06-01 14:02:16] Final number of rows left after all filtering steps: 2593
## INFO [2021-06-01 14:02:16]  Finished successfully. Execution time: 0.5 secs
## INFO [2021-06-01 14:02:16] 
668
669
## 
## Permuted data
Christian Arnold's avatar
Christian Arnold committed
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
## INFO [2021-06-01 14:02:16] Inital number of rows left before all filtering steps: 68
## INFO [2021-06-01 14:02:16]  Filter network and retain only rows with TF-peak connections with an FDR &lt; 0.2
## INFO [2021-06-01 14:02:16]   Number of TF-peak rows before filtering TFs: 68
## INFO [2021-06-01 14:02:16]   Number of TF-peak rows after filtering TFs: 13
## INFO [2021-06-01 14:02:16] 2. Filter peak-gene connections
## INFO [2021-06-01 14:02:16]  Filter genes by gene type, keep only the following gene types: protein_coding, lincRNA
## INFO [2021-06-01 14:02:16]   Number of peak-gene rows before filtering by gene type: 18832
## INFO [2021-06-01 14:02:16]   Number of peak-gene rows after filtering by gene type: 18738
## INFO [2021-06-01 14:02:16] 3. Merging TF-peak with peak-gene connections and filter the combined table...
## INFO [2021-06-01 14:02:16] Inital number of rows left before all filtering steps: 14
## INFO [2021-06-01 14:02:16]  Filter network and retain only rows with peak_gene.r in the following interval: (0 - 1]
## INFO [2021-06-01 14:02:16]   Number of rows before filtering TFs: 14
## INFO [2021-06-01 14:02:16]   Number of rows after filtering TFs: 11
## INFO [2021-06-01 14:02:16]  Calculate FDR based on remaining rows, filter network and retain only rows with peak-gene connections with an FDR &lt; 0.2
## INFO [2021-06-01 14:02:16]   Number of rows before filtering genes (including NA): 11
## INFO [2021-06-01 14:02:16]   Number of rows before filtering genes (excluding NA): 2
## INFO [2021-06-01 14:02:16]   Number of rows after filtering genes (including NA): 10
## INFO [2021-06-01 14:02:16]   Number of rows after filtering genes (excluding NA): 1
## INFO [2021-06-01 14:02:16] Final number of rows left after all filtering steps: 10
## INFO [2021-06-01 14:02:16]  Finished successfully. Execution time: 0.9 secs</code></pre>
690
691
692
693
694
695
696
<p>The output shows the number of links before and after applying a particular filter that has been set for both real and permuted data. Expectedly and reassuringly, almost no connections remain for the permuted data, while the real data keeps around 2500 connections.</p>
<p>For more parameter details, see the R help (<code><a href="../reference/filterGRNAndConnectGenes.html">?filterGRNAndConnectGenes</a></code>).</p>
</div>
<div id="add-tf-gene-correlations-optional" class="section level2">
<h2 class="hasAnchor">
<a href="#add-tf-gene-correlations-optional" class="anchor"></a>Add TF-gene correlations (optional)</h2>
<p>Optionally, we can also include extra columns about the correlation of TF and genes directly. So far, only TF-peaks and peak-genes have been correlated, but not directly TFs and genes. Based on a filtered set of TF-peak-gene connections, the function <em>add_TF_gene_correlation</em> calculates the TF-gene correlation for each connection from the filtered set for which the TF is not missing.</p>
Christian Arnold's avatar
Christian Arnold committed
697
<div class="sourceCode" id="cb62"><pre class="downlit sourceCode r">
698
<code class="sourceCode R"><span class="va">GRN</span> <span class="op">=</span> <span class="fu">GRN</span><span class="fu">::</span><span class="fu"><a href="../reference/add_TF_gene_correlation.html">add_TF_gene_correlation</a></span><span class="op">(</span><span class="va">GRN</span>, corMethod <span class="op">=</span> <span class="st">"pearson"</span>, nCores <span class="op">=</span> <span class="fl">1</span>, forceRerun <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
Christian Arnold's avatar
Christian Arnold committed
699
700
701
702
703
704
705
706
707
<pre><code>## INFO [2021-06-01 14:02:16] Calculate correlations for TF and genes from the filtered set of connections
## INFO [2021-06-01 14:02:16]  Real data
## INFO [2021-06-01 14:02:16]   Iterate through 587 TF-gene combinations and (if possible) calculate correlations using 1 cores. This may take a few minutes.
## INFO [2021-06-01 14:02:17]  Finished execution using 1 cores. TOTAL RUNNING TIME: 0.9 secs
## 
## INFO [2021-06-01 14:02:17]   Done. Construct the final table, this may result in an increased number of TF-gene pairs due to different TF names linked to the same Ensembl ID.
## INFO [2021-06-01 14:02:17]  Permuted data
## INFO [2021-06-01 14:02:17]   Iterate through 1 TF-gene combinations and (if possible) calculate correlations using 1 cores. This may take a few minutes.
## INFO [2021-06-01 14:02:18]  Finished execution using 1 cores. TOTAL RUNNING TIME: 0.7 secs
708
## 
Christian Arnold's avatar
Christian Arnold committed
709
## INFO [2021-06-01 14:02:18]   Done. Construct the final table, this may result in an increased number of TF-gene pairs due to different TF names linked to the same Ensembl ID.</code></pre>
710
711
712
713
714
715
716
<p>As can be seen from the output, the Pearson correlation for 587 TF-gene pairs has been calculated. From the around 2500 connections we obtained above, since we set the parameter <em>allowMissingGenes = TRUE</em>, for the majority of the TF-peak-gene connections the gene is actually missing. That is, while a TF-peak connection below the specified significance threshold exists, no corresponding gene could be found that connects to the same peak, therefore setting the gene to <em>NA</em> rather than excluding the row altogether.</p>
<p>For more parameter details, see the R help (<code><a href="../reference/add_TF_gene_correlation.html">?add_TF_gene_correlation</a></code>).</p>
</div>
<div id="retrieve-filtered-connections" class="section level2">
<h2 class="hasAnchor">
<a href="#retrieve-filtered-connections" class="anchor"></a>Retrieve filtered connections</h2>
<p>We are now ready to retrieve the connections and the additional data we added to them. This can be done with a helper function that retrieves a data frame from a <em>GRN</em> object from a particular slot. Here, we specify <em>all.filtered</em>, as we want to retrieve all filtered connections. For more parameter details, see the R help (<code>getGRNConnections</code>). Note that the first time, we assign a different variable to the return of the function (i.e., <em>GRN_connections.all</em> and NOT <em>GRN</em> as before). Importantly, we have to select a new variable as we would otherwise overwrite our <em>GRN</em> object altogether! All <em>get</em> functions from the <em>GRN</em> package return an element from within the object and NOT the object itself, so please keep that in mind and always check what the functions returns before running it. You can simply do so in the R help (<code><a href="../reference/getGRNConnections.html">?getGRNConnections</a></code>).</p>
Christian Arnold's avatar
Christian Arnold committed
717
718
<div class="sourceCode" id="cb64"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">GRN_connections.all</span> <span class="op">=</span> <span class="fu">GRN</span><span class="fu">::</span><span class="fu"><a href="../reference/getGRNConnections.html">getGRNConnections</a></span><span class="op">(</span><span class="va">GRN</span>, type <span class="op">=</span> <span class="st">"all.filtered"</span>, include_TF_gene_correlations <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751

<span class="va">GRN_connections.all</span></code></pre></div>
<pre><code>## # A tibble: 2,593 x 28
##    TF.name TF.ENSEMBL TF_peak.r_bin TF_peak.r TF_peak.fdr TF_peak.fdr_orig
##    &lt;chr&gt;   &lt;fct&gt;      &lt;fct&gt;             &lt;dbl&gt;       &lt;dbl&gt;            &lt;dbl&gt;
##  1 ARI3A.… ENSG00000… [0.65,0.7)        0.662      0.142            0.142 
##  2 ASCL2.… ENSG00000… (-0.75,-0.7]     -0.701      0.108            0.108 
##  3 BATF3.… ENSG00000… [0.65,0.7)        0.684      0.185            0.185 
##  4 BATF3.… ENSG00000… [0.65,0.7)        0.684      0.185            0.185 
##  5 BATF3.… ENSG00000… [0.65,0.7)        0.689      0.185            0.185 
##  6 BATF3.… ENSG00000… [0.75,0.8)        0.792      0.0465           0.0465
##  7 BC11A.… ENSG00000… (-0.75,-0.7]     -0.746      0                0     
##  8 BRCA1.… ENSG00000… [0.65,0.7)        0.653      0.132            0.132 
##  9 CDX2.0… ENSG00000… [0.7,0.75)        0.706      0.0241           0.0241
## 10 CEBPA.… ENSG00000… (-0.6,-0.55]     -0.594      0.127            0.127 
## # … with 2,583 more rows, and 22 more variables: TF_peak.fdr_direction &lt;fct&gt;,
## #   TF_peak.connectionType &lt;fct&gt;, peak.ID &lt;fct&gt;, peak.mean &lt;dbl&gt;,
## #   peak.median &lt;dbl&gt;, peak.CV &lt;dbl&gt;, peak_gene.distance &lt;int&gt;,
## #   peak_gene.r &lt;dbl&gt;, peak_gene.p_raw &lt;dbl&gt;, peak_gene.p_adj &lt;dbl&gt;,
## #   gene.ENSEMBL &lt;fct&gt;, gene.mean &lt;dbl&gt;, gene.median &lt;dbl&gt;, gene.CV &lt;dbl&gt;,
## #   gene.chr &lt;fct&gt;, gene.start &lt;int&gt;, gene.end &lt;int&gt;, gene.strand &lt;fct&gt;,
## #   gene.type &lt;fct&gt;, gene.name &lt;fct&gt;, TF_gene.r &lt;dbl&gt;, TF_gene.p_raw &lt;dbl&gt;</code></pre>
<p>The table contains a total of 28 columns, and the prefix of each column name indicates the part of the <em>GRN</em> network that the column refers to (e.g., TFs, TF-peaks, peaks, peak-genes or genes, or TF-gene if <em>add_TF_gene_correlation</em> has been run before). Data are stored in a format that minimizes the memory footprint (e.g., each character column is stored as a factor). This table can now be used for any downstream analysis, as it is just a normal data frame.</p>
</div>
<div id="visualize-the-filtered-grn-connections" class="section level2">
<h2 class="hasAnchor">
<a href="#visualize-the-filtered-grn-connections" class="anchor"></a>Visualize the filtered <em>GRN</em> connections</h2>
<p>The <em>GRN</em> package will soon also offer some rudimentary functions to visualize a filtered <em>GRN</em> network. Stay tuned! Meanwhile, you can use the <em>igraph</em> package to construct a graph out of the filtered TF-peak-gene connection table (see above).</p>
</div>
<div id="generate-a-connection-summary" class="section level2">
<h2 class="hasAnchor">
<a href="#generate-a-connection-summary" class="anchor"></a>Generate a connection summary</h2>
<p>It is often useful to get a grasp of the general connectivity of a network and the number of connections that survive the filtering. This makes it possible to make an informed decision about which FDR to choose for TF-peak and peak-gene links, depending on how many links are retained and how many connections are needed for downstream analysis. To facilitate this and automate it, we offer a convenience function that in essence iterates over different combinations of filtering parameters and calls <em>filterGRNAndConnectGenes</em> once for each of them, and then records various connectivity statistics. Note that running this function may take a while. Afterwards, we can graphically summarize this result in either a heatmap or a boxplot. For more parameter details, see the R help (<code><a href="../reference/generateStatsSummary.html">?generateStatsSummary</a></code> and <code>plot_stats_connectionSummary</code>).</p>
Christian Arnold's avatar
Christian Arnold committed
752
<div class="sourceCode" id="cb66"><pre class="downlit sourceCode r">
753
<code class="sourceCode R"><span class="va">GRN</span> <span class="op">=</span> <span class="fu">GRN</span><span class="fu">::</span><span class="fu"><a href="../reference/generateStatsSummary.html">generateStatsSummary</a></span><span class="op">(</span><span class="va">GRN</span>, TF_peak.fdr <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">0.01</span>, <span class="fl">0.05</span>, <span class="fl">0.1</span>, <span class="fl">0.2</span><span class="op">)</span>, TF_peak.connectionTypes <span class="op">=</span> <span class="st">"all"</span>, 
754
755
756
    peak_gene.p_raw <span class="op">=</span> <span class="cn">NULL</span>, peak_gene.fdr <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">0.01</span>, <span class="fl">0.05</span>, <span class="fl">0.1</span>, <span class="fl">0.2</span><span class="op">)</span>, peak_gene.r_range <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">0</span>, 
        <span class="fl">1</span><span class="op">)</span>, allowMissingGenes <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="cn">FALSE</span>, <span class="cn">TRUE</span><span class="op">)</span>, allowMissingTFs <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="cn">FALSE</span><span class="op">)</span>, gene.types <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"protein_coding"</span>, 
        <span class="st">"lincRNA"</span><span class="op">)</span><span class="op">)</span></code></pre></div>
Christian Arnold's avatar
Christian Arnold committed
757
758
<pre><code>## INFO [2021-06-01 14:02:18] Generating summary. This may take a while...
## INFO [2021-06-01 14:02:18] 
759
760
## Real data...
## 
Christian Arnold's avatar
Christian Arnold committed
761
762
763
764
765
## INFO [2021-06-01 14:02:18] Calculate network stats for TF-peak FDR of 0.01
## INFO [2021-06-01 14:02:22] Calculate network stats for TF-peak FDR of 0.05
## INFO [2021-06-01 14:02:26] Calculate network stats for TF-peak FDR of 0.1
## INFO [2021-06-01 14:02:29] Calculate network stats for TF-peak FDR of 0.2
## INFO [2021-06-01 14:02:33] 
766
767
## Permuted data...
## 
Christian Arnold's avatar
Christian Arnold committed
768
769
770
771
772
## INFO [2021-06-01 14:02:33] Calculate network stats for TF-peak FDR of 0.01
## INFO [2021-06-01 14:02:36] Calculate network stats for TF-peak FDR of 0.05
## INFO [2021-06-01 14:02:40] Calculate network stats for TF-peak FDR of 0.1
## INFO [2021-06-01 14:02:43] Calculate network stats for TF-peak FDR of 0.2</code></pre>
<div class="sourceCode" id="cb68"><pre class="downlit sourceCode r">
773
<code class="sourceCode R"><span class="va">GRN</span> <span class="op">=</span> <span class="fu">GRN</span><span class="fu">::</span><span class="fu"><a href="../reference/plot_stats_connectionSummary.html">plot_stats_connectionSummary</a></span><span class="op">(</span><span class="va">GRN</span>, type <span class="op">=</span> <span class="st">"heatmap"</span>, forceRerun <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
Christian Arnold's avatar
Christian Arnold committed
774
775
776
777
<pre><code>## INFO [2021-06-01 14:02:47] Plotting connection summary to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/GRN.connectionSummary_heatmap.pdf</code></pre>
<pre><code>## INFO [2021-06-01 14:02:47] Finished writing plots to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/GRN.connectionSummary_heatmap.pdf
## INFO [2021-06-01 14:02:47]  Finished successfully. Execution time: 0.5 secs</code></pre>
<div class="sourceCode" id="cb71"><pre class="downlit sourceCode r">
778
<code class="sourceCode R"><span class="va">GRN</span> <span class="op">=</span> <span class="fu">GRN</span><span class="fu">::</span><span class="fu"><a href="../reference/plot_stats_connectionSummary.html">plot_stats_connectionSummary</a></span><span class="op">(</span><span class="va">GRN</span>, type <span class="op">=</span> <span class="st">"boxplot"</span>, forceRerun <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
Christian Arnold's avatar
Christian Arnold committed
779
780
<pre><code>## INFO [2021-06-01 14:02:47] Plotting diagnostic plots for network connections to file /g/scb2/zaugg/carnold/Projects/GRN_pipeline/src/GRN/vignettes/output/plots/GRN.connectionSummary_boxplot.pdf</code></pre>
<pre><code>## INFO [2021-06-01 14:02:58]  Finished successfully. Execution time: 10.7 secs</code></pre>
781
782
783
784
785
786
<p>The output is not very informative here and just tells us about the current progress and parameter it iterates over. We can now check the two new PDF files that have been created! Please see the Introductory Vignette for examples and interpretation.</p>
</div>
<div id="wrapping-up" class="section level2">
<h2 class="hasAnchor">
<a href="#wrapping-up" class="anchor"></a>Wrapping up</h2>
<p>We are basically finished with the main workflow, all that is left to do is to save our <em>GRN</em> object to disk so we can load it at a later time point without having to repeat the analysis. We recommend to run a convenience function beforehand that aims to reduce the size of the <em>GRN</em> object by deleting some intermediate data that may still be stored within the object. Afterwards, as we did already in the middle of the workflow, we save the object finally in rds format.</p>
Christian Arnold's avatar
Christian Arnold committed
787
<div class="sourceCode" id="cb74"><pre class="downlit sourceCode r">
788
<code class="sourceCode R"><span class="va">GRN</span> <span class="op">=</span> <span class="fu">GRN</span><span class="fu">::</span><span class="fu"><a href="../reference/deleteIntermediateData.html">deleteIntermediateData</a></span><span class="op">(</span><span class="va">GRN</span><span class="op">)</span>
789
790
791
792
793
794
795
796
797
798
799
800
801
<span class="fu"><a href="https://rdrr.io/r/base/readRDS.html">saveRDS</a></span><span class="op">(</span><span class="va">GRN</span>, <span class="va">GRN_file_outputRDS</span><span class="op">)</span></code></pre></div>
<p>Finally, we again save the object in an rds file, in analogy to the intermediate save above.</p>
<p>For more parameter details, see the R help (<code><a href="../reference/deleteIntermediateData.html">?deleteIntermediateData</a></code>).</p>
</div>
</div>
<div id="how-to-continue" class="section level1">
<h1 class="hasAnchor">
<a href="#how-to-continue" class="anchor"></a>How to continue?</h1>
<p>From here on, possibilities are endless, and you can further investigate patterns and trends in the data! We hope that the <em>GRN</em> package is useful for your research and encourage you to contact us if you have any question or feature request!</p>
</div>
<div id="session-info" class="section level1">
<h1 class="hasAnchor">
<a href="#session-info" class="anchor"></a>Session Info</h1>
Christian Arnold's avatar
Christian Arnold committed
802
<div class="sourceCode" id="cb75"><pre class="downlit sourceCode r">
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/utils/sessionInfo.html">sessionInfo</a></span><span class="op">(</span><span class="op">)</span></code></pre></div>
<pre><code>## R version 3.6.3 (2020-02-29)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.1 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
Christian Arnold's avatar
Christian Arnold committed
821
## [1] parallel  stats4    stats     graphics  grDevices utils     datasets 
822
823
824
## [8] methods   base     
## 
## other attached packages:
Christian Arnold's avatar
Christian Arnold committed
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
##  [1] progress_1.2.2                          
##  [2] TxDb.Hsapiens.UCSC.hg38.knownGene_3.10.0
##  [3] GenomicFeatures_1.38.2                  
##  [4] GenomicRanges_1.38.0                    
##  [5] GenomeInfoDb_1.22.1                     
##  [6] org.Hs.eg.db_3.10.0                     
##  [7] AnnotationDbi_1.48.0                    
##  [8] IRanges_2.20.2                          
##  [9] S4Vectors_0.24.4                        
## [10] Biobase_2.46.0                          
## [11] BiocGenerics_0.32.0                     
## [12] limma_3.42.2                            
## [13] checkmate_2.0.0                         
## [14] futile.logger_1.4.3                     
## [15] GRN_0.10.1                              
## [16] GRNData_0.99.0                          
841
842
843
844
845
846
847
848
849
## [17] forcats_0.5.1                           
## [18] stringr_1.4.0                           
## [19] dplyr_1.0.4                             
## [20] purrr_0.3.4                             
## [21] readr_1.4.0                             
## [22] tidyr_1.1.2                             
## [23] tibble_3.0.6                            
## [24] ggplot2_3.3.3                           
## [25] tidyverse_1.3.0                         
Christian Arnold's avatar
Christian Arnold committed
850
851
## [26] knitr_1.31                              
## [27] BiocStyle_2.19.1                        
852
853
854
855
856
857
858
859
860
## 
## loaded via a namespace (and not attached):
##   [1] readxl_1.3.1                backports_1.2.1            
##   [3] Hmisc_4.4-2                 BiocFileCache_1.10.2       
##   [5] systemfonts_1.0.1           plyr_1.8.6                 
##   [7] splines_3.6.3               BiocParallel_1.20.1        
##   [9] digest_0.6.27               htmltools_0.5.1.1          
##  [11] fansi_0.4.2                 magrittr_2.0.1             
##  [13] memoise_2.0.0               cluster_2.1.0              
Christian Arnold's avatar
Christian Arnold committed
861
##  [15] Biostrings_2.54.0           annotate_1.64.0            
862
863
864
##  [17] modelr_0.1.8                matrixStats_0.58.0         
##  [19] askpass_1.1                 pkgdown_1.6.1              
##  [21] prettyunits_1.1.1           jpeg_0.1-8.1               
Christian Arnold's avatar
Christian Arnold committed
865
866
##  [23] colorspace_2.0-0            rappdirs_0.3.3             
##  [25] blob_1.2.1                  rvest_0.3.6                
867
868
869
870
871
872
873
##  [27] textshaping_0.3.2           haven_2.3.1                
##  [29] xfun_0.20                   crayon_1.4.1               
##  [31] RCurl_1.98-1.2              jsonlite_1.7.2             
##  [33] genefilter_1.68.0           survival_3.1-12            
##  [35] glue_1.4.2                  gtable_0.3.0               
##  [37] zlibbioc_1.32.0             XVector_0.26.0             
##  [39] DelayedArray_0.12.3         scales_1.1.1               
874
##  [41] pheatmap_1.0.12             futile.options_1.0.1       
875
876
877
878
879
880
##  [43] DBI_1.1.1                   Rcpp_1.0.6                 
##  [45] viridisLite_0.3.0           xtable_1.8-4               
##  [47] htmlTable_2.1.0             foreign_0.8-71             
##  [49] bit_4.0.4                   Formula_1.2-4              
##  [51] htmlwidgets_1.5.3           httr_1.4.2                 
##  [53] RColorBrewer_1.1-2          ellipsis_0.3.1             
881
882
##  [55] farver_2.0.3                pkgconfig_2.0.3            
##  [57] XML_3.99-0.3                nnet_7.3-14                
883
##  [59] dbplyr_2.1.0                locfit_1.5-9.4             
884
885
886
##  [61] utf8_1.1.4                  labeling_0.4.2             
##  [63] reshape2_1.4.4              tidyselect_1.1.0           
##  [65] rlang_0.4.10                munsell_0.5.0              
887
##  [67] cellranger_1.1.0            tools_3.6.3                
888
##  [69] cachem_1.0.3                cli_2.5.0                  
889
890
891
892
893
894
895
896
897
898
899
900
901
902
##  [71] generics_0.1.0              RSQLite_2.2.3              
##  [73] broom_0.7.4                 evaluate_0.14              
##  [75] fastmap_1.1.0               yaml_2.2.1                 
##  [77] ragg_1.1.1                  bit64_4.0.5                
##  [79] fs_1.5.0                    formatR_1.7                
##  [81] xml2_1.3.2                  biomaRt_2.42.1             
##  [83] compiler_3.6.3              rstudioapi_0.13            
##  [85] curl_4.3                    png_0.1-7                  
##  [87] reprex_1.0.0                geneplotter_1.64.0         
##  [89] stringi_1.5.3               desc_1.2.0                 
##  [91] lattice_0.20-41             Matrix_1.2-18              
##  [93] vctrs_0.3.6                 pillar_1.4.7               
##  [95] lifecycle_0.2.0             BiocManager_1.30.10        
##  [97] data.table_1.13.6           bitops_1.0-6               
Christian Arnold's avatar
Christian Arnold committed
903
##  [99] rtracklayer_1.46.0          patchwork_1.0.1            
904
905
## [101] R6_2.5.0                    latticeExtra_0.6-29        
## [103] bookdown_0.21               gridExtra_2.3              
Christian Arnold's avatar
Christian Arnold committed
906
907
908
909
910
911
912
913
## [105] lambda.r_1.2.4              assertthat_0.2.1           
## [107] SummarizedExperiment_1.16.1 openssl_1.4.3              
## [109] DESeq2_1.26.0               rprojroot_2.0.2            
## [111] withr_2.4.1                 GenomicAlignments_1.22.1   
## [113] Rsamtools_2.2.3             GenomeInfoDbData_1.2.2     
## [115] hms_1.0.0                   grid_3.6.3                 
## [117] rpart_4.1-15                rmarkdown_2.7              
## [119] lubridate_1.7.9.2           base64enc_0.1-3</code></pre>
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
</div>
  </div>

  <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">

        <nav id="toc" data-toggle="toc"><h2 data-toc-skip>Contents</h2>
    </nav>
</div>

</div>



      <footer><div class="copyright">
  <p>Developed by Christian Arnold, Judith Zaugg.</p>
</div>

<div class="pkgdown">
  <p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.6.1.</p>
</div>

      </footer>
</div>

  


  </body>
</html>