|
| 1 | +<!DOCTYPE html> |
| 2 | + |
| 3 | +<html> |
| 4 | + |
| 5 | +<head> |
| 6 | + |
| 7 | +<meta charset="utf-8" /> |
| 8 | +<meta name="generator" content="pandoc" /> |
| 9 | +<meta http-equiv="X-UA-Compatible" content="IE=EDGE" /> |
| 10 | + |
| 11 | +<meta name="viewport" content="width=device-width, initial-scale=1"> |
| 12 | + |
| 13 | +<meta name="author" content="Wei Vivian Li, Rutgers Department of Biostatistics and Epidemiology" /> |
| 14 | + |
| 15 | +<meta name="date" content="2020-06-01" /> |
| 16 | + |
| 17 | +<title>Introduction to scLink</title> |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +<style type="text/css">code{white-space: pre;}</style> |
| 22 | +<style type="text/css" data-origin="pandoc"> |
| 23 | +div.sourceCode { overflow-x: auto; } |
| 24 | +table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode { |
| 25 | + margin: 0; padding: 0; vertical-align: baseline; border: none; } |
| 26 | +table.sourceCode { width: 100%; line-height: 100%; } |
| 27 | +td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; } |
| 28 | +td.sourceCode { padding-left: 5px; } |
| 29 | +code > span.kw { color: #007020; font-weight: bold; } /* Keyword */ |
| 30 | +code > span.dt { color: #902000; } /* DataType */ |
| 31 | +code > span.dv { color: #40a070; } /* DecVal */ |
| 32 | +code > span.bn { color: #40a070; } /* BaseN */ |
| 33 | +code > span.fl { color: #40a070; } /* Float */ |
| 34 | +code > span.ch { color: #4070a0; } /* Char */ |
| 35 | +code > span.st { color: #4070a0; } /* String */ |
| 36 | +code > span.co { color: #60a0b0; font-style: italic; } /* Comment */ |
| 37 | +code > span.ot { color: #007020; } /* Other */ |
| 38 | +code > span.al { color: #ff0000; font-weight: bold; } /* Alert */ |
| 39 | +code > span.fu { color: #06287e; } /* Function */ |
| 40 | +code > span.er { color: #ff0000; font-weight: bold; } /* Error */ |
| 41 | +code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */ |
| 42 | +code > span.cn { color: #880000; } /* Constant */ |
| 43 | +code > span.sc { color: #4070a0; } /* SpecialChar */ |
| 44 | +code > span.vs { color: #4070a0; } /* VerbatimString */ |
| 45 | +code > span.ss { color: #bb6688; } /* SpecialString */ |
| 46 | +code > span.im { } /* Import */ |
| 47 | +code > span.va { color: #19177c; } /* Variable */ |
| 48 | +code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */ |
| 49 | +code > span.op { color: #666666; } /* Operator */ |
| 50 | +code > span.bu { } /* BuiltIn */ |
| 51 | +code > span.ex { } /* Extension */ |
| 52 | +code > span.pp { color: #bc7a00; } /* Preprocessor */ |
| 53 | +code > span.at { color: #7d9029; } /* Attribute */ |
| 54 | +code > span.do { color: #ba2121; font-style: italic; } /* Documentation */ |
| 55 | +code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */ |
| 56 | +code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */ |
| 57 | +code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */ |
| 58 | + |
| 59 | +</style> |
| 60 | +<script> |
| 61 | +// apply pandoc div.sourceCode style to pre.sourceCode instead |
| 62 | +(function() { |
| 63 | + var sheets = document.styleSheets; |
| 64 | + for (var i = 0; i < sheets.length; i++) { |
| 65 | + if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue; |
| 66 | + try { var rules = sheets[i].cssRules; } catch (e) { continue; } |
| 67 | + for (var j = 0; j < rules.length; j++) { |
| 68 | + var rule = rules[j]; |
| 69 | + // check if there is a div.sourceCode rule |
| 70 | + if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") continue; |
| 71 | + var style = rule.style.cssText; |
| 72 | + // check if color or background-color is set |
| 73 | + if (rule.style.color === '' && rule.style.backgroundColor === '') continue; |
| 74 | + // replace div.sourceCode by a pre.sourceCode rule |
| 75 | + sheets[i].deleteRule(j); |
| 76 | + sheets[i].insertRule('pre.sourceCode{' + style + '}', j); |
| 77 | + } |
| 78 | + } |
| 79 | +})(); |
| 80 | +</script> |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | +<link href="data:text/css;charset=utf-8,body%20%7B%0Abackground%2Dcolor%3A%20%23fff%3B%0Amargin%3A%201em%20auto%3B%0Amax%2Dwidth%3A%20700px%3B%0Aoverflow%3A%20visible%3B%0Apadding%2Dleft%3A%202em%3B%0Apadding%2Dright%3A%202em%3B%0Afont%2Dfamily%3A%20%22Open%20Sans%22%2C%20%22Helvetica%20Neue%22%2C%20Helvetica%2C%20Arial%2C%20sans%2Dserif%3B%0Afont%2Dsize%3A%2014px%3B%0Aline%2Dheight%3A%201%2E35%3B%0A%7D%0A%23header%20%7B%0Atext%2Dalign%3A%20center%3B%0A%7D%0A%23TOC%20%7B%0Aclear%3A%20both%3B%0Amargin%3A%200%200%2010px%2010px%3B%0Apadding%3A%204px%3B%0Awidth%3A%20400px%3B%0Aborder%3A%201px%20solid%20%23CCCCCC%3B%0Aborder%2Dradius%3A%205px%3B%0Abackground%2Dcolor%3A%20%23f6f6f6%3B%0Afont%2Dsize%3A%2013px%3B%0Aline%2Dheight%3A%201%2E3%3B%0A%7D%0A%23TOC%20%2Etoctitle%20%7B%0Afont%2Dweight%3A%20bold%3B%0Afont%2Dsize%3A%2015px%3B%0Amargin%2Dleft%3A%205px%3B%0A%7D%0A%23TOC%20ul%20%7B%0Apadding%2Dleft%3A%2040px%3B%0Amargin%2Dleft%3A%20%2D1%2E5em%3B%0Amargin%2Dtop%3A%205px%3B%0Amargin%2Dbottom%3A%205px%3B%0A%7D%0A%23TOC%20ul%20ul%20%7B%0Amargin%2Dleft%3A%20%2D2em%3B%0A%7D%0A%23TOC%20li%20%7B%0Aline%2Dheight%3A%2016px%3B%0A%7D%0Atable%20%7B%0Amargin%3A%201em%20auto%3B%0Aborder%2Dwidth%3A%201px%3B%0Aborder%2Dcolor%3A%20%23DDDDDD%3B%0Aborder%2Dstyle%3A%20outset%3B%0Aborder%2Dcollapse%3A%20collapse%3B%0A%7D%0Atable%20th%20%7B%0Aborder%2Dwidth%3A%202px%3B%0Apadding%3A%205px%3B%0Aborder%2Dstyle%3A%20inset%3B%0A%7D%0Atable%20td%20%7B%0Aborder%2Dwidth%3A%201px%3B%0Aborder%2Dstyle%3A%20inset%3B%0Aline%2Dheight%3A%2018px%3B%0Apadding%3A%205px%205px%3B%0A%7D%0Atable%2C%20table%20th%2C%20table%20td%20%7B%0Aborder%2Dleft%2Dstyle%3A%20none%3B%0Aborder%2Dright%2Dstyle%3A%20none%3B%0A%7D%0Atable%20thead%2C%20table%20tr%2Eeven%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0A%7D%0Ap%20%7B%0Amargin%3A%200%2E5em%200%3B%0A%7D%0Ablockquote%20%7B%0Abackground%2Dcolor%3A%20%23f6f6f6%3B%0Apadding%3A%200%2E25em%200%2E75em%3B%0A%7D%0Ahr%20%7B%0Aborder%2Dstyle%3A%20solid%3B%0Aborder%3A%20none%3B%0Aborder%2Dtop%3A%201px%20solid%20%23777%3B%0Amargin%3A%2028px%200%3B%0A%7D%0Adl%20%7B%0Amargin%2Dleft%3A%200%3B%0A%7D%0Adl%20dd%20%7B%0Amargin%2Dbottom%3A%2013px%3B%0Amargin%2Dleft%3A%2013px%3B%0A%7D%0Adl%20dt%20%7B%0Afont%2Dweight%3A%20bold%3B%0A%7D%0Aul%20%7B%0Amargin%2Dtop%3A%200%3B%0A%7D%0Aul%20li%20%7B%0Alist%2Dstyle%3A%20circle%20outside%3B%0A%7D%0Aul%20ul%20%7B%0Amargin%2Dbottom%3A%200%3B%0A%7D%0Apre%2C%20code%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0Aborder%2Dradius%3A%203px%3B%0Acolor%3A%20%23333%3B%0Awhite%2Dspace%3A%20pre%2Dwrap%3B%20%0A%7D%0Apre%20%7B%0Aborder%2Dradius%3A%203px%3B%0Amargin%3A%205px%200px%2010px%200px%3B%0Apadding%3A%2010px%3B%0A%7D%0Apre%3Anot%28%5Bclass%5D%29%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0A%7D%0Acode%20%7B%0Afont%2Dfamily%3A%20Consolas%2C%20Monaco%2C%20%27Courier%20New%27%2C%20monospace%3B%0Afont%2Dsize%3A%2085%25%3B%0A%7D%0Ap%20%3E%20code%2C%20li%20%3E%20code%20%7B%0Apadding%3A%202px%200px%3B%0A%7D%0Adiv%2Efigure%20%7B%0Atext%2Dalign%3A%20center%3B%0A%7D%0Aimg%20%7B%0Abackground%2Dcolor%3A%20%23FFFFFF%3B%0Apadding%3A%202px%3B%0Aborder%3A%201px%20solid%20%23DDDDDD%3B%0Aborder%2Dradius%3A%203px%3B%0Aborder%3A%201px%20solid%20%23CCCCCC%3B%0Amargin%3A%200%205px%3B%0A%7D%0Ah1%20%7B%0Amargin%2Dtop%3A%200%3B%0Afont%2Dsize%3A%2035px%3B%0Aline%2Dheight%3A%2040px%3B%0A%7D%0Ah2%20%7B%0Aborder%2Dbottom%3A%204px%20solid%20%23f7f7f7%3B%0Apadding%2Dtop%3A%2010px%3B%0Apadding%2Dbottom%3A%202px%3B%0Afont%2Dsize%3A%20145%25%3B%0A%7D%0Ah3%20%7B%0Aborder%2Dbottom%3A%202px%20solid%20%23f7f7f7%3B%0Apadding%2Dtop%3A%2010px%3B%0Afont%2Dsize%3A%20120%25%3B%0A%7D%0Ah4%20%7B%0Aborder%2Dbottom%3A%201px%20solid%20%23f7f7f7%3B%0Amargin%2Dleft%3A%208px%3B%0Afont%2Dsize%3A%20105%25%3B%0A%7D%0Ah5%2C%20h6%20%7B%0Aborder%2Dbottom%3A%201px%20solid%20%23ccc%3B%0Afont%2Dsize%3A%20105%25%3B%0A%7D%0Aa%20%7B%0Acolor%3A%20%230033dd%3B%0Atext%2Ddecoration%3A%20none%3B%0A%7D%0Aa%3Ahover%20%7B%0Acolor%3A%20%236666ff%3B%20%7D%0Aa%3Avisited%20%7B%0Acolor%3A%20%23800080%3B%20%7D%0Aa%3Avisited%3Ahover%20%7B%0Acolor%3A%20%23BB00BB%3B%20%7D%0Aa%5Bhref%5E%3D%22http%3A%22%5D%20%7B%0Atext%2Ddecoration%3A%20underline%3B%20%7D%0Aa%5Bhref%5E%3D%22https%3A%22%5D%20%7B%0Atext%2Ddecoration%3A%20underline%3B%20%7D%0A%0Acode%20%3E%20span%2Ekw%20%7B%20color%3A%20%23555%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%0Acode%20%3E%20span%2Edt%20%7B%20color%3A%20%23902000%3B%20%7D%20%0Acode%20%3E%20span%2Edv%20%7B%20color%3A%20%2340a070%3B%20%7D%20%0Acode%20%3E%20span%2Ebn%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Efl%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Ech%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Est%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Eco%20%7B%20color%3A%20%23888888%3B%20font%2Dstyle%3A%20italic%3B%20%7D%20%0Acode%20%3E%20span%2Eot%20%7B%20color%3A%20%23007020%3B%20%7D%20%0Acode%20%3E%20span%2Eal%20%7B%20color%3A%20%23ff0000%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%0Acode%20%3E%20span%2Efu%20%7B%20color%3A%20%23900%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%20code%20%3E%20span%2Eer%20%7B%20color%3A%20%23a61717%3B%20background%2Dcolor%3A%20%23e3d2d2%3B%20%7D%20%0A" rel="stylesheet" type="text/css" /> |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | +</head> |
| 90 | + |
| 91 | +<body> |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | +<h1 class="title toc-ignore">Introduction to scLink</h1> |
| 97 | +<h4 class="author">Wei Vivian Li, Rutgers Department of Biostatistics and Epidemiology</h4> |
| 98 | +<h4 class="date">2020-06-01</h4> |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +<p>A system-level understanding of the regulation and coordination mechanisms of gene expression is essential to understanding the complexity of biological processes in health and disease. With the rapid development of single-cell RNA sequencing technologies, it is now possible to investigate gene interactions in a cell-type-specific manner. Here we introduce the <code>scLink</code> package, which uses statistical network modeling to understand the co-expression relationships among genes and to construct sparse gene co-expression networks from single-cell gene expression data.</p> |
| 103 | +<p>Here we demonstrate the functionality of <code>scLink</code> using the example data stored in the package.</p> |
| 104 | +<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">library</span>(scLink)</code></pre></div> |
| 105 | +<pre><code>## Loading required package: parallel</code></pre> |
| 106 | +<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">count =<span class="st"> </span><span class="kw">readRDS</span>(<span class="kw">system.file</span>(<span class="st">"extdata"</span>, <span class="st">"example.rds"</span>, <span class="dt">package =</span> <span class="st">"scLink"</span>)) |
| 107 | +genes =<span class="st"> </span><span class="kw">readRDS</span>(<span class="kw">system.file</span>(<span class="st">"extdata"</span>, <span class="st">"genes.rds"</span>, <span class="dt">package =</span> <span class="st">"scLink"</span>))</code></pre></div> |
| 108 | +<p>The example raw count matrix <code>count</code> has 793 <strong>rows</strong> representing different cells and 23,341 <strong>columns</strong> representing different genes. <code>genes</code> is a character vector of 500 genes of interest.</p> |
| 109 | +<div id="sclink_norm" class="section level2"> |
| 110 | +<h2><code>sclink_norm</code></h2> |
| 111 | +<p>We use the function <code>sclink_norm</code> to process single cell read count for application of the sclink method. The code below will normalize the read count matrix with a library size of <span class="math inline">\(10^6\)</span> and only keep the 500 genes in <code>genes</code> for downstream analysis. Note that the normalized count matrix <code>count.norm</code> is on the <span class="math inline">\(\log_{10}\)</span> scale.</p> |
| 112 | +<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">count.norm =<span class="st"> </span><span class="kw">sclink_norm</span>(count, <span class="dt">scale.factor =</span> <span class="fl">1e6</span>, <span class="dt">filter.genes =</span> <span class="ot">FALSE</span>, <span class="dt">gene.names =</span> genes)</code></pre></div> |
| 113 | +<p>If users do not have a particular gene list for network inference, they can set <code>filter.genes=TRUE</code> to filter for the top <span class="math inline">\(n\)</span> genes with largest average expression values. For example:</p> |
| 114 | +<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">count.norm =<span class="st"> </span><span class="kw">sclink_norm</span>(count, <span class="dt">scale.factor =</span> <span class="fl">1e6</span>, <span class="dt">filter.genes =</span> <span class="ot">TRUE</span>, <span class="dt">n =</span> <span class="dv">500</span>)</code></pre></div> |
| 115 | +</div> |
| 116 | +<div id="sclink_net" class="section level2"> |
| 117 | +<h2><code>sclink_net</code></h2> |
| 118 | +<p>After the pre-processing step, we use the function <code>sclink_net</code> to calculate the robust correlation matrix and identifed sparse co-expression network of scLink. <code>expr</code> is the normalized count matrix output by <code>sclink_norm</code> or supplied by the users. <code>lda</code> is the candidate regularization parameters used in scLink’s graphical model. The users can set <code>ncores</code> to take advantage of parallel computation.</p> |
| 119 | +<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">networks =<span class="st"> </span><span class="kw">sclink_net</span>(<span class="dt">expr =</span> count.norm, <span class="dt">ncores =</span> <span class="dv">1</span>, <span class="dt">lda =</span> <span class="kw">seq</span>(<span class="fl">0.5</span>, <span class="fl">0.1</span>, <span class="op">-</span><span class="fl">0.05</span>))</code></pre></div> |
| 120 | +<p><code>sclink_net</code> returns a list of results. The scLink’s robust correlation matrix can be retrieved from the <code>cor</code> element:</p> |
| 121 | +<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">networks<span class="op">$</span>cor[<span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,<span class="dv">1</span><span class="op">:</span><span class="dv">3</span>]</code></pre></div> |
| 122 | +<pre><code>## Rn45s Eef1a1 Malat1 |
| 123 | +## Rn45s 1.00000000 -0.27604002 -0.08561265 |
| 124 | +## Eef1a1 -0.27604002 1.00000000 -0.05138179 |
| 125 | +## Malat1 -0.08561265 -0.05138179 1.00000000</code></pre> |
| 126 | +<p>The gene co-expression networks and summary statistics can be retrieved from the <code>summary</code> element, which is a list with the same length as <code>lda</code>: each element corresponds to one regularization parameter.</p> |
| 127 | +<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">net1 =<span class="st"> </span>networks<span class="op">$</span>summary[[<span class="dv">1</span>]] |
| 128 | +<span class="kw">names</span>(net1)</code></pre></div> |
| 129 | +<pre><code>## [1] "adj" "Sigma" "nedge" "bic" "lambda"</code></pre> |
| 130 | +<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">### adjacency matrix |
| 131 | +net1<span class="op">$</span>adj[<span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,<span class="dv">1</span><span class="op">:</span><span class="dv">3</span>]</code></pre></div> |
| 132 | +<pre><code>## Rn45s Eef1a1 Malat1 |
| 133 | +## Rn45s 1 0 0 |
| 134 | +## Eef1a1 0 1 0 |
| 135 | +## Malat1 0 0 1</code></pre> |
| 136 | +<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">### concentration matrix |
| 137 | +net1<span class="op">$</span>Sigma[<span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,<span class="dv">1</span><span class="op">:</span><span class="dv">3</span>]</code></pre></div> |
| 138 | +<pre><code>## Rn45s Eef1a1 Malat1 |
| 139 | +## Rn45s 1.696584 0.000000 0.000000 |
| 140 | +## Eef1a1 0.000000 1.665809 0.000000 |
| 141 | +## Malat1 0.000000 0.000000 1.578271</code></pre> |
| 142 | +<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">### BIC |
| 143 | +net1<span class="op">$</span>bic</code></pre></div> |
| 144 | +<pre><code>## [1] 1255450</code></pre> |
| 145 | +<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">### number of edges |
| 146 | +net1<span class="op">$</span>nedge</code></pre></div> |
| 147 | +<pre><code>## [1] 127</code></pre> |
| 148 | +<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">### regularization parameter lambda |
| 149 | +net1<span class="op">$</span>lambda</code></pre></div> |
| 150 | +<pre><code>## [1] 0.5</code></pre> |
| 151 | +</div> |
| 152 | +<div id="sclink_cor" class="section level2"> |
| 153 | +<h2><code>sclink_cor</code></h2> |
| 154 | +<p>Since it is very difficult to infer co-expression relationships for lowly expressed genes in single-cell data, we suggest the filtering step as used in <code>sclink_norm</code> to select genes. This also reduces the computational burden. However, if the users would like to infer gene networks for a large gene list (e.g., <span class="math inline">\(> 5000\)</span> genes), we suggest that the users first use <code>sclink_cor</code> to investigate the correlation structures among these genes.</p> |
| 155 | +<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">corr =<span class="st"> </span><span class="kw">sclink_cor</span>(<span class="dt">expr =</span> count.norm, <span class="dt">ncores =</span> <span class="dv">1</span>)</code></pre></div> |
| 156 | +<p>If the correlation matrix suggests obvious gene modules, then the users can apply <code>sclink_net</code> separately on these modules to reduce computation time and increase accuracy.</p> |
| 157 | +</div> |
| 158 | + |
| 159 | + |
| 160 | + |
| 161 | +<!-- code folding --> |
| 162 | + |
| 163 | + |
| 164 | +<!-- dynamically load mathjax for compatibility with self-contained --> |
| 165 | +<script> |
| 166 | + (function () { |
| 167 | + var script = document.createElement("script"); |
| 168 | + script.type = "text/javascript"; |
| 169 | + script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"; |
| 170 | + document.getElementsByTagName("head")[0].appendChild(script); |
| 171 | + })(); |
| 172 | +</script> |
| 173 | + |
| 174 | +</body> |
| 175 | +</html> |
0 commit comments