Last active
March 24, 2023 07:17
-
-
Save mlin/f30c5beb1d5e7d99c6b36ff5f6b2aebc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="generator" content="pandoc" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |
<title>Census Datasets example</title> | |
<script>// Pandoc 2.9 adds attributes on both header and div. We remove the former (to | |
// be compatible with the behavior of Pandoc < 2.8). | |
document.addEventListener('DOMContentLoaded', function(e) { | |
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); | |
var i, h, a; | |
for (i = 0; i < hs.length; i++) { | |
h = hs[i]; | |
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 | |
a = h.attributes; | |
while (a.length > 0) h.removeAttribute(a[0].name); | |
} | |
}); | |
</script> | |
<style type="text/css"> | |
code{white-space: pre-wrap;} | |
span.smallcaps{font-variant: small-caps;} | |
span.underline{text-decoration: underline;} | |
div.column{display: inline-block; vertical-align: top; width: 50%;} | |
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} | |
ul.task-list{list-style: none;} | |
</style> | |
<style type="text/css"> | |
code { | |
white-space: pre; | |
} | |
.sourceCode { | |
overflow: visible; | |
} | |
</style> | |
<style type="text/css" data-origin="pandoc"> | |
pre > code.sourceCode { white-space: pre; position: relative; } | |
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; } | |
pre > code.sourceCode > span:empty { height: 1.2em; } | |
.sourceCode { overflow: visible; } | |
code.sourceCode > span { color: inherit; text-decoration: inherit; } | |
div.sourceCode { margin: 1em 0; } | |
pre.sourceCode { margin: 0; } | |
@media screen { | |
div.sourceCode { overflow: auto; } | |
} | |
@media print { | |
pre > code.sourceCode { white-space: pre-wrap; } | |
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; } | |
} | |
pre.numberSource code | |
{ counter-reset: source-line 0; } | |
pre.numberSource code > span | |
{ position: relative; left: -4em; counter-increment: source-line; } | |
pre.numberSource code > span > a:first-child::before | |
{ content: counter(source-line); | |
position: relative; left: -1em; text-align: right; vertical-align: baseline; | |
border: none; display: inline-block; | |
-webkit-touch-callout: none; -webkit-user-select: none; | |
-khtml-user-select: none; -moz-user-select: none; | |
-ms-user-select: none; user-select: none; | |
padding: 0 4px; width: 4em; | |
color: #aaaaaa; | |
} | |
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; } | |
div.sourceCode | |
{ } | |
@media screen { | |
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; } | |
} | |
code span.al { color: #ff0000; font-weight: bold; } | |
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } | |
code span.at { color: #7d9029; } | |
code span.bn { color: #40a070; } | |
code span.bu { color: #008000; } | |
code span.cf { color: #007020; font-weight: bold; } | |
code span.ch { color: #4070a0; } | |
code span.cn { color: #880000; } | |
code span.co { color: #60a0b0; font-style: italic; } | |
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } | |
code span.do { color: #ba2121; font-style: italic; } | |
code span.dt { color: #902000; } | |
code span.dv { color: #40a070; } | |
code span.er { color: #ff0000; font-weight: bold; } | |
code span.ex { } | |
code span.fl { color: #40a070; } | |
code span.fu { color: #06287e; } | |
code span.im { color: #008000; font-weight: bold; } | |
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } | |
code span.kw { color: #007020; font-weight: bold; } | |
code span.op { color: #666666; } | |
code span.ot { color: #007020; } | |
code span.pp { color: #bc7a00; } | |
code span.sc { color: #4070a0; } | |
code span.ss { color: #bb6688; } | |
code span.st { color: #4070a0; } | |
code span.va { color: #19177c; } | |
code span.vs { color: #4070a0; } | |
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } | |
</style> | |
<script> | |
// apply pandoc div.sourceCode style to pre.sourceCode instead | |
(function() { | |
var sheets = document.styleSheets; | |
for (var i = 0; i < sheets.length; i++) { | |
if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue; | |
try { var rules = sheets[i].cssRules; } catch (e) { continue; } | |
var j = 0; | |
while (j < rules.length) { | |
var rule = rules[j]; | |
// check if there is a div.sourceCode rule | |
if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") { | |
j++; | |
continue; | |
} | |
var style = rule.style.cssText; | |
// check if color or background-color is set | |
if (rule.style.color === '' && rule.style.backgroundColor === '') { | |
j++; | |
continue; | |
} | |
// replace div.sourceCode by a pre.sourceCode rule | |
sheets[i].deleteRule(j); | |
sheets[i].insertRule('pre.sourceCode{' + style + '}', j); | |
} | |
} | |
})(); | |
</script> | |
<style type="text/css">body { | |
background-color: #fff; | |
margin: 1em auto; | |
max-width: 700px; | |
overflow: visible; | |
padding-left: 2em; | |
padding-right: 2em; | |
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; | |
font-size: 14px; | |
line-height: 1.35; | |
} | |
#TOC { | |
clear: both; | |
margin: 0 0 10px 10px; | |
padding: 4px; | |
width: 400px; | |
border: 1px solid #CCCCCC; | |
border-radius: 5px; | |
background-color: #f6f6f6; | |
font-size: 13px; | |
line-height: 1.3; | |
} | |
#TOC .toctitle { | |
font-weight: bold; | |
font-size: 15px; | |
margin-left: 5px; | |
} | |
#TOC ul { | |
padding-left: 40px; | |
margin-left: -1.5em; | |
margin-top: 5px; | |
margin-bottom: 5px; | |
} | |
#TOC ul ul { | |
margin-left: -2em; | |
} | |
#TOC li { | |
line-height: 16px; | |
} | |
table { | |
margin: 1em auto; | |
border-width: 1px; | |
border-color: #DDDDDD; | |
border-style: outset; | |
border-collapse: collapse; | |
} | |
table th { | |
border-width: 2px; | |
padding: 5px; | |
border-style: inset; | |
} | |
table td { | |
border-width: 1px; | |
border-style: inset; | |
line-height: 18px; | |
padding: 5px 5px; | |
} | |
table, table th, table td { | |
border-left-style: none; | |
border-right-style: none; | |
} | |
table thead, table tr.even { | |
background-color: #f7f7f7; | |
} | |
p { | |
margin: 0.5em 0; | |
} | |
blockquote { | |
background-color: #f6f6f6; | |
padding: 0.25em 0.75em; | |
} | |
hr { | |
border-style: solid; | |
border: none; | |
border-top: 1px solid #777; | |
margin: 28px 0; | |
} | |
dl { | |
margin-left: 0; | |
} | |
dl dd { | |
margin-bottom: 13px; | |
margin-left: 13px; | |
} | |
dl dt { | |
font-weight: bold; | |
} | |
ul { | |
margin-top: 0; | |
} | |
ul li { | |
list-style: circle outside; | |
} | |
ul ul { | |
margin-bottom: 0; | |
} | |
pre, code { | |
background-color: #f7f7f7; | |
border-radius: 3px; | |
color: #333; | |
white-space: pre-wrap; | |
} | |
pre { | |
border-radius: 3px; | |
margin: 5px 0px 10px 0px; | |
padding: 10px; | |
} | |
pre:not([class]) { | |
background-color: #f7f7f7; | |
} | |
code { | |
font-family: Consolas, Monaco, 'Courier New', monospace; | |
font-size: 85%; | |
} | |
p > code, li > code { | |
padding: 2px 0px; | |
} | |
div.figure { | |
text-align: center; | |
} | |
img { | |
background-color: #FFFFFF; | |
padding: 2px; | |
border: 1px solid #DDDDDD; | |
border-radius: 3px; | |
border: 1px solid #CCCCCC; | |
margin: 0 5px; | |
} | |
h1 { | |
margin-top: 0; | |
font-size: 35px; | |
line-height: 40px; | |
} | |
h2 { | |
border-bottom: 4px solid #f7f7f7; | |
padding-top: 10px; | |
padding-bottom: 2px; | |
font-size: 145%; | |
} | |
h3 { | |
border-bottom: 2px solid #f7f7f7; | |
padding-top: 10px; | |
font-size: 120%; | |
} | |
h4 { | |
border-bottom: 1px solid #f7f7f7; | |
margin-left: 8px; | |
font-size: 105%; | |
} | |
h5, h6 { | |
border-bottom: 1px solid #ccc; | |
font-size: 105%; | |
} | |
a { | |
color: #0033dd; | |
text-decoration: none; | |
} | |
a:hover { | |
color: #6666ff; } | |
a:visited { | |
color: #800080; } | |
a:visited:hover { | |
color: #BB00BB; } | |
a[href^="http:"] { | |
text-decoration: underline; } | |
a[href^="https:"] { | |
text-decoration: underline; } | |
code > span.kw { color: #555; font-weight: bold; } | |
code > span.dt { color: #902000; } | |
code > span.dv { color: #40a070; } | |
code > span.bn { color: #d14; } | |
code > span.fl { color: #d14; } | |
code > span.ch { color: #d14; } | |
code > span.st { color: #d14; } | |
code > span.co { color: #888888; font-style: italic; } | |
code > span.ot { color: #007020; } | |
code > span.al { color: #ff0000; font-weight: bold; } | |
code > span.fu { color: #900; font-weight: bold; } | |
code > span.er { color: #a61717; background-color: #e3d2d2; } | |
</style> | |
</head> | |
<body> | |
<h1 class="title toc-ignore">Census Datasets example</h1> | |
<!-- | |
THIS VIGNETTE IS BASED ON: | |
https://github.com/chanzuckerberg/cell-census/blob/main/api/python/notebooks/api_demo/census_datasets.ipynb | |
--> | |
<p><em>Goal:</em> demonstrate basic use of the | |
<code>census_datasets</code> data frame.</p> | |
<p>Each Cell Census contains a top-level data frame itemizing the | |
datasets contained therein. You can read this <code>SOMADataFrame</code> | |
into an <a href="https://arrow.apache.org/docs/r/reference/Table.html">Arrow | |
Table</a>:</p> | |
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>census <span class="ot"><-</span> CellCensus<span class="sc">::</span><span class="fu">open_soma</span>()</span> | |
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>census_datasets <span class="ot"><-</span> census<span class="sc">$</span><span class="fu">get</span>(<span class="st">"census_info"</span>)<span class="sc">$</span><span class="fu">get</span>(<span class="st">"datasets"</span>)<span class="sc">$</span><span class="fu">read</span>()</span> | |
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="fu">print</span>(census_datasets)</span> | |
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="co">#> Table</span></span> | |
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="co">#> 503 rows x 8 columns</span></span> | |
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="co">#> $soma_joinid <int64 not null></span></span> | |
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a><span class="co">#> $collection_id <large_string not null></span></span> | |
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="co">#> $collection_name <large_string not null></span></span> | |
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a><span class="co">#> $collection_doi <large_string not null></span></span> | |
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a><span class="co">#> $dataset_id <large_string not null></span></span> | |
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a><span class="co">#> $dataset_title <large_string not null></span></span> | |
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a><span class="co">#> $dataset_h5ad_path <large_string not null></span></span> | |
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a><span class="co">#> $dataset_total_cell_count <int64 not null></span></span></code></pre></div> | |
<p>and then an R data frame:</p> | |
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>census_datasets <span class="ot"><-</span> <span class="fu">as.data.frame</span>(census_datasets)</span> | |
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="fu">print</span>(census_datasets[, <span class="fu">c</span>(</span> | |
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> <span class="st">"dataset_id"</span>,</span> | |
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="st">"dataset_title"</span>,</span> | |
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a> <span class="st">"dataset_total_cell_count"</span></span> | |
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a>)], <span class="at">n =</span> <span class="dv">5</span>)</span> | |
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="co">#> # A tibble: 503 × 3</span></span> | |
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a><span class="co">#> dataset_id dataset_title dataset_total_cell_c…¹</span></span> | |
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="co">#> <chr> <chr> <int></span></span> | |
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a><span class="co">#> 1 f512b8b6-369d-4a85-a695-116e0806857f Skin 68036</span></span> | |
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a><span class="co">#> 2 90d4a63b-5c02-43eb-acde-c49345681601 Fallopian tube RNA 60574</span></span> | |
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a><span class="co">#> 3 d1207c81-7309-43a7-a5a0-f4283670b62b Ovary RNA 26134</span></span> | |
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a><span class="co">#> 4 58b01044-c5e5-4b0f-8a2d-6ebf951e01ff A scRNA-seq atlas… 130908</span></span> | |
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a><span class="co">#> 5 97d9238c-1a39-4873-b0bb-963ec2d788e6 MSK SPECTRUM - De… 24025</span></span> | |
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a><span class="co">#> # ℹ 498 more rows</span></span> | |
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a><span class="co">#> # ℹ abbreviated name: ¹dataset_total_cell_count</span></span></code></pre></div> | |
<p>The sum of cell counts across all datasets should match the number of | |
cells across all SOMA experiments (human, mouse).</p> | |
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>census_data <span class="ot"><-</span> census<span class="sc">$</span><span class="fu">get</span>(<span class="st">"census_data"</span>)</span> | |
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>all_experiments <span class="ot"><-</span> <span class="fu">lapply</span>(census_data<span class="sc">$</span><span class="fu">to_list</span>(), <span class="cf">function</span>(it) census_data<span class="sc">$</span><span class="fu">get</span>(it<span class="sc">$</span>name))</span> | |
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="fu">print</span>(all_experiments)</span> | |
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="co">#> $homo_sapiens</span></span> | |
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="co">#> <SOMAExperiment></span></span> | |
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a><span class="co">#> uri: s3://cellxgene-data-public/cell-census/2023-03-16/soma/census_data/homo_sapiens </span></span> | |
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a><span class="co">#> arrays: obs* </span></span> | |
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a><span class="co">#> groups: ms* </span></span> | |
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a><span class="co">#> </span></span> | |
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a><span class="co">#> $mus_musculus</span></span> | |
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a><span class="co">#> <SOMAExperiment></span></span> | |
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a><span class="co">#> uri: s3://cellxgene-data-public/cell-census/2023-03-16/soma/census_data/mus_musculus </span></span> | |
<span id="cb3-13"><a href="#cb3-13" aria-hidden="true" tabindex="-1"></a><span class="co">#> arrays: obs* </span></span> | |
<span id="cb3-14"><a href="#cb3-14" aria-hidden="true" tabindex="-1"></a><span class="co">#> groups: ms*</span></span></code></pre></div> | |
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>experiments_total_cells <span class="ot"><-</span> <span class="fu">sum</span>(<span class="fu">sapply</span>(all_experiments, <span class="cf">function</span>(it) {</span> | |
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">nrow</span>(it<span class="sc">$</span>obs<span class="sc">$</span><span class="fu">read</span>(<span class="at">column_names =</span> <span class="fu">c</span>(<span class="st">"soma_joinid"</span>)))</span> | |
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a>}))</span> | |
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="fu">print</span>(<span class="fu">paste</span>(<span class="st">"Found"</span>, experiments_total_cells, <span class="st">"cells in all experiments."</span>))</span> | |
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a><span class="co">#> [1] "Found 48311298 cells in all experiments."</span></span> | |
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a><span class="fu">print</span>(<span class="fu">paste</span>(</span> | |
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a> <span class="st">"Found"</span>, <span class="fu">sum</span>(<span class="fu">as.vector</span>(census_datasets<span class="sc">$</span>dataset_total_cell_count)),</span> | |
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a> <span class="st">"cells in all datasets."</span></span> | |
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a>))</span> | |
<span id="cb4-10"><a href="#cb4-10" aria-hidden="true" tabindex="-1"></a><span class="co">#> [1] "Found 48311298 cells in all datasets."</span></span></code></pre></div> | |
<p>Let’s pick one dataset to slice out of the census, and turn into a | |
Seurat in-memory object. (This requires the <code>Seurat</code> package | |
to have been installed beforehand.)</p> | |
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>census_datasets[census_datasets<span class="sc">$</span>dataset_id <span class="sc">==</span> <span class="st">"0bd1a1de-3aee-40e0-b2ec-86c7a30c7149"</span>, ]</span> | |
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="co">#> # A tibble: 1 × 8</span></span> | |
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="co">#> soma_joinid collection_id collection_name collection_doi dataset_id</span></span> | |
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="co">#> <int> <chr> <chr> <chr> <chr> </span></span> | |
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="co">#> 1 345 0b9d8a04-bb9d-44da-aa27… Tabula Muris S… 10.1038/s4158… 0bd1a1de-…</span></span> | |
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a><span class="co">#> # ℹ 3 more variables: dataset_title <chr>, dataset_h5ad_path <chr>,</span></span> | |
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a><span class="co">#> # dataset_total_cell_count <int></span></span></code></pre></div> | |
<p>Create a query on the mouse experiment, “RNA” measurement, for the | |
<code>dataset_id</code>.</p> | |
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>obs_query <span class="ot"><-</span> tiledbsoma<span class="sc">::</span>SOMAAxisQuery<span class="sc">$</span><span class="fu">new</span>(</span> | |
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="at">value_filter =</span> <span class="st">"dataset_id == '0bd1a1de-3aee-40e0-b2ec-86c7a30c7149'"</span></span> | |
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a>)</span> | |
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a>expt_query <span class="ot"><-</span> tiledbsoma<span class="sc">::</span>SOMAExperimentAxisQuery<span class="sc">$</span><span class="fu">new</span>(</span> | |
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a> census_data<span class="sc">$</span><span class="fu">get</span>(<span class="st">"mus_musculus"</span>), <span class="st">"RNA"</span>,</span> | |
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a> <span class="at">obs_query =</span> obs_query</span> | |
<span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a>)</span> | |
<span id="cb6-8"><a href="#cb6-8" aria-hidden="true" tabindex="-1"></a>dataset_seurat <span class="ot"><-</span> expt_query<span class="sc">$</span><span class="fu">to_seurat</span>(<span class="fu">c</span>(<span class="at">counts =</span> <span class="st">"raw"</span>))</span> | |
<span id="cb6-9"><a href="#cb6-9" aria-hidden="true" tabindex="-1"></a><span class="co">#> Warning: No reductions found</span></span> | |
<span id="cb6-10"><a href="#cb6-10" aria-hidden="true" tabindex="-1"></a><span class="co">#> Warning: No graphs found in 'obsp'</span></span> | |
<span id="cb6-11"><a href="#cb6-11" aria-hidden="true" tabindex="-1"></a><span class="fu">print</span>(dataset_seurat)</span> | |
<span id="cb6-12"><a href="#cb6-12" aria-hidden="true" tabindex="-1"></a><span class="co">#> An object of class Seurat </span></span> | |
<span id="cb6-13"><a href="#cb6-13" aria-hidden="true" tabindex="-1"></a><span class="co">#> 52392 features across 40220 samples within 1 assay </span></span> | |
<span id="cb6-14"><a href="#cb6-14" aria-hidden="true" tabindex="-1"></a><span class="co">#> Active assay: RNA (52392 features, 0 variable features)</span></span></code></pre></div> | |
<p>You can also use the <code>CellCensus::get_source_h5ad_uri()</code> | |
API to fetch a URI pointing to the H5AD associated with this dataset_id. | |
This is the same H5AD you can download from the CELLxGENE Portal, and | |
may contain additional data-submitter provided information which was not | |
included in the Cell Census.</p> | |
<p>The “locator” returned by this API will include a URI and additional | |
information that may be necessary to use the URI (eg, the S3 | |
region).</p> | |
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>CellCensus<span class="sc">::</span><span class="fu">get_source_h5ad_uri</span>(<span class="st">"0bd1a1de-3aee-40e0-b2ec-86c7a30c7149"</span>)</span> | |
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="co">#> $uri</span></span> | |
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="co">#> [1] "s3://cellxgene-data-public/cell-census/2023-03-16/h5ads/0bd1a1de-3aee-40e0-b2ec-86c7a30c7149.h5ad"</span></span> | |
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="co">#> </span></span> | |
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a><span class="co">#> $s3_region</span></span> | |
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a><span class="co">#> [1] "us-west-2"</span></span></code></pre></div> | |
<p>The <code>CellCensus::download_source_h5ad()</code> API downloads the | |
H5AD to a local file, which can then be used in R using <a href="https://mojaveazure.github.io/seurat-disk/articles/convert-anndata.html">SeuratDisk’s | |
anndata converter</a>.</p> | |
<!-- code folding --> | |
<!-- dynamically load mathjax for compatibility with self-contained --> | |
<script> | |
(function () { | |
var script = document.createElement("script"); | |
script.type = "text/javascript"; | |
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"; | |
document.getElementsByTagName("head")[0].appendChild(script); | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment