Platform
Resources
Pricing
Sign in
Get started
Brian Staats
Workspace
Fork
Public
By
Brian Staats
Edited
Dec 6, 2022
Insert cell
data
=
d3
.
csv
(
"https://idk-etl-prod-download-bucket.s3.amazonaws.com/aibs_human_ctx_smart-seq/tsne.csv"
,
d3
.
autoType
)
;
Insert cell
metadata
=
d3
.
csv
(
"https://idk-etl-prod-download-bucket.s3.amazonaws.com/aibs_human_ctx_smart-seq/metadata.csv"
)
Insert cell
width
=
400
;
Insert cell
height
=
400
;
Insert cell
{
return
[
d3
.
min
(
data
,
d
=>
d
.
tsne_2
)
,
d3
.
max
(
data
,
d
=>
d
.
tsne_2
)
]
}
Insert cell
{
return
[
d3
.
min
(
data
,
d
=>
d
.
tsne_1
)
,
d3
.
max
(
data
,
d
=>
d
.
tsne_1
)
]
}
Insert cell
x
=
d3
.
scaleLinear
(
)
.
range
(
[
0
,
width
]
)
.
domain
(
[
d3
.
min
(
data
,
d
=>
d
.
tsne_1
)
,
d3
.
max
(
data
,
d
=>
d
.
tsne_1
)
]
)
;
Insert cell
y
=
d3
.
scaleLinear
(
)
.
range
(
[
height
,
0
]
)
.
domain
(
[
d3
.
min
(
data
,
d
=>
d
.
tsne_2
)
,
d3
.
max
(
data
,
d
=>
d
.
tsne_2
)
]
)
;
Insert cell
// context = DOM.context2d(width, height);
Insert cell
{
const
canvas
=
DOM
.
canvas
(
width
,
height
)
;
const
context
=
canvas
.
getContext
(
"2d"
)
;
data
.
forEach
(
d
=>
{
context
.
beginPath
(
)
;
context
.
arc
(
x
(
d
.
tsne_1
)
,
y
(
d
.
tsne_2
)
,
2
,
0
,
2
*
Math
.
PI
)
;
context
.
fill
(
)
;
}
)
;
return
canvas
;
// const canvas = DOM.canvas(width, height);
// const context = canvas.getContext("2d");
// const colorScale = d3.scaleOrdinal(d3.schemeTableau10)
// const points = data;//[ {x: 10, y: 10, value: 50}, {x: 20, y: 20, value: 60}, {x: 30, y: 30, value: 70}];
// data.forEach(d => {
// context.beginPath();
// context.arc(xScale(d.tsne_1), yScale(d.tsne_2), 1.5, 0, 2 * Math.PI, false);
// // context.fillStyle = colorScale(d.sample_name);
// context.fill();
// });
// context.canvas.call(zoom);
// return context.canvas
}
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
data
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
metadata
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
width
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
height
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
x
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
y
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML