Landscape-Clustergram Visium-HD¶
In [1]:
Copied!
%load_ext autoreload
%autoreload 2
%env ANYWIDGET_HMR=1
%load_ext autoreload
%autoreload 2
%env ANYWIDGET_HMR=1
env: ANYWIDGET_HMR=1
In [2]:
Copied!
import numpy as np
import pandas as pd
import celldega as dega
from ipywidgets import Widget
import numpy as np
import pandas as pd
import celldega as dega
from ipywidgets import Widget
/Users/feni/Documents/celldega/dega/lib/python3.12/site-packages/h5py/__init__.py:36: UserWarning: h5py is running against HDF5 1.14.5 when it was built against 1.14.6, this may cause problems _warn(("h5py is running against HDF5 {0} when it was built against {1}, "
Viz¶
In [3]:
Copied!
base_url = 'https://raw.githubusercontent.com/broadinstitute/celldega_Visium-HD_Mouse_Lung_Fresh_Frozen/main/LandscapeFiles'
base_url = 'https://raw.githubusercontent.com/broadinstitute/celldega_Visium-HD_Mouse_Lung_Fresh_Frozen/main/LandscapeFiles'
In [4]:
Copied!
Widget.close_all()
landscape_sst = dega.viz.Landscape(
technology='Visium-HD',
base_url=base_url,
square_tile_size=3,
height=600
)
Widget.close_all()
landscape_sst = dega.viz.Landscape(
technology='Visium-HD',
base_url=base_url,
square_tile_size=3,
height=600
)
/var/folders/8d/jxpy9rd10j7fp2rcj_s5sz3c0000gq/T/ipykernel_14589/469116797.py:2: UserWarning: Transformation matrix not found at https://raw.githubusercontent.com/broadinstitute/celldega_Visium-HD_Mouse_Lung_Fresh_Frozen/main/LandscapeFiles/micron_to_image_transform.csv. Using identity. landscape_sst = dega.viz.Landscape(
In [5]:
Copied!
df_sig = pd.read_parquet(f'{base_url}/df_sig.parquet')
meta_gene = pd.read_parquet(f'{base_url}/meta_gene.parquet')
meta_gene['mean_log1p'] = np.log1p(meta_gene['mean'])
df_sig = pd.read_parquet(f'{base_url}/df_sig.parquet')
meta_gene = pd.read_parquet(f'{base_url}/meta_gene.parquet')
meta_gene['mean_log1p'] = np.log1p(meta_gene['mean'])
In [6]:
Copied!
mat = dega.clust.Matrix(data=df_sig, meta_row=meta_gene, row_attr=['mean_log1p'])
mat.filter(by='var', num=5000, axis='row')
mat.filter(by='mean', num=1000, axis='row')
mat.norm(by='total', axis='col')
mat.norm(by='zscore', axis='row')
mat.cluster()
cgm = dega.viz.Clustergram(matrix=mat, width=500, height=500)
mat = dega.clust.Matrix(data=df_sig, meta_row=meta_gene, row_attr=['mean_log1p'])
mat.filter(by='var', num=5000, axis='row')
mat.filter(by='mean', num=1000, axis='row')
mat.norm(by='total', axis='col')
mat.norm(by='zscore', axis='row')
mat.cluster()
cgm = dega.viz.Clustergram(matrix=mat, width=500, height=500)
In [7]:
Copied!
dega.viz.landscape_clustergram(landscape=landscape_sst, mat=cgm)
dega.viz.landscape_clustergram(landscape=landscape_sst, mat=cgm)
Out[7]:
Enrichment Analysis: Enrichr¶
In [8]:
Copied!
dega.viz.clustergram_enrich(cgm)
dega.viz.clustergram_enrich(cgm)
Out[8]:
In [ ]:
Copied!