Mouse Brain Alpha Shape Neighborhoods¶
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!
# macOS requirement
import os
os.environ['DYLD_LIBRARY_PATH'] = '/opt/homebrew/lib:' + os.environ.get('DYLD_LIBRARY_PATH', '')
# macOS requirement
import os
os.environ['DYLD_LIBRARY_PATH'] = '/opt/homebrew/lib:' + os.environ.get('DYLD_LIBRARY_PATH', '')
In [3]:
Copied!
from shapely import Point, MultiPoint, MultiPolygon
import geopandas as gpd
import numpy as np
import pandas as pd
import geopandas as gpd
from libpysal.cg import alpha_shape
import matplotlib.pyplot as plt
import json
from ipywidgets import Widget
import celldega as dega
from shapely import Point, MultiPoint, MultiPolygon
import geopandas as gpd
import numpy as np
import pandas as pd
import geopandas as gpd
from libpysal.cg import alpha_shape
import matplotlib.pyplot as plt
import json
from ipywidgets import Widget
import celldega as dega
Load Data¶
In [4]:
Copied!
base_path = 'https://raw.githubusercontent.com/broadinstitute/celldega_Xenium_Prime_Mouse_Brain_Coronal_FF_outs/main/Xenium_Prime_Mouse_Brain_Coronal_FF_outs/'
base_path = 'https://raw.githubusercontent.com/broadinstitute/celldega_Xenium_Prime_Mouse_Brain_Coronal_FF_outs/main/Xenium_Prime_Mouse_Brain_Coronal_FF_outs/'
In [5]:
Copied!
meta_cell_ini = pd.read_parquet(base_path + 'cell_metadata.parquet')
cluster = pd.read_parquet(base_path + 'cell_clusters/cluster.parquet')
meta_cluster = pd.read_parquet(base_path + 'cell_clusters/meta_cluster.parquet')
meta_cell = pd.concat([meta_cell_ini, cluster], axis=1)
meta_cell_ini = pd.read_parquet(base_path + 'cell_metadata.parquet')
cluster = pd.read_parquet(base_path + 'cell_clusters/cluster.parquet')
meta_cluster = pd.read_parquet(base_path + 'cell_clusters/meta_cluster.parquet')
meta_cell = pd.concat([meta_cell_ini, cluster], axis=1)
Calculate Alpha Shape Neighborhoods¶
In [6]:
Copied!
gdf_alpha = dega.nbhd.alpha_shape_cell_clusters(meta_cell, cat='cluster', alphas=[100, 150, 200, 250, 300, 350])
geojson_alpha = dega.nbhd.alpha_shape_geojson(gdf_alpha, meta_cluster, inst_alpha=250)
gdf_alpha = dega.nbhd.alpha_shape_cell_clusters(meta_cell, cat='cluster', alphas=[100, 150, 200, 250, 300, 350])
geojson_alpha = dega.nbhd.alpha_shape_geojson(gdf_alpha, meta_cluster, inst_alpha=250)
In [7]:
Copied!
Widget.close_all()
base_url = base_path.rstrip('/')
landscape_ist = dega.viz.Landscape(
technology='Xenium',
ini_zoom = -4.5,
ini_x=6000,
ini_y=8000,
base_url = base_url,
nbhd=geojson_alpha
)
landscape_ist
Widget.close_all()
base_url = base_path.rstrip('/')
landscape_ist = dega.viz.Landscape(
technology='Xenium',
ini_zoom = -4.5,
ini_x=6000,
ini_y=8000,
base_url = base_url,
nbhd=geojson_alpha
)
landscape_ist
Out[7]:
In [ ]:
Copied!
In [ ]:
Copied!