-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjscatter_soma_analysis.py
More file actions
73 lines (56 loc) · 1.72 KB
/
jscatter_soma_analysis.py
File metadata and controls
73 lines (56 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import marimo
__generated_with = "0.13.11"
app = marimo.App(width="medium")
@app.cell
def _():
import marimo as mo
import tiledbsoma.io
import scanpy as sc
import jscatter
import pandas as pd
import numpy as np
import seaborn as sns
return jscatter, mo, sns, tiledbsoma
@app.cell
def _(mo, tiledbsoma):
input_h5ad_file = mo.cli_args().get("h5ad") or "/project/immune_variation/processed_data/merged_anndata/merged_pilot_data_harmony.h5ad"
soma_path = mo.cli_args().get("soma_out") or "/project/immune_variation/processed_data/merged_anndata/merged_pilot_data_harmony_soma"
td = tiledbsoma.io.from_h5ad(
experiment_uri=soma_path,
input_path=input_h5ad_file,
measurement_name="RNA",
obs_id_name="obs_id",
var_id_name="var_id")
return (td,)
@app.cell
def _(td, tiledbsoma):
sc_data = tiledbsoma.Experiment.open(td)
return (sc_data,)
@app.cell
def _(sc_data):
table = sc_data.ms["RNA"].obsm['X_umap'].read().tables().concat().to_pandas()
umap_df = table.pivot(
index="soma_dim_0", # Cell/observation index
columns="soma_dim_1", # UMAP dimension (0=UMAP_1, 1=UMAP_2)
values="soma_data" # Coordinate values
)
umap_df.head()
return (umap_df,)
@app.cell
def _(sns, umap_df):
sns.scatterplot(data=umap_df, x=0, y=1, s=1)
return
@app.cell
def _():
return
@app.cell
def _(df, jscatter):
scatter = jscatter.Scatter(data=df, x='mass', y='speed')
scatter.color(by='mass', map='plasma', order='reverse')
scatter.opacity(by='density')
scatter.size(by='pval', map=[2, 4, 6, 8, 10])
scatter.background('#1E1E20')
scatter.show()
return
if __name__ == "__main__":
app.run()