Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
def get_bbox(adata, library_id, *, library_key="sample", img_key="hires", margin=50): | |
adata = adata[adata.obs[library_key] == library_id, :] | |
coords = adata.obsm["spatial"] | |
scale_factor = adata.uns["spatial"][library_id]["scalefactors"][f"tissue_{img_key}_scalef"] | |
return tuple( | |
np.array( | |
[ | |
np.min(coords[:, 0]) - margin, | |
np.min(coords[:, 1]) - margin, | |
np.max(coords[:, 0]) + margin, |
This file contains hidden or 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
from functools import partial | |
import math | |
from typing import Literal | |
from datashader.mpl_ext import dsshow, alpha_colormap | |
import datashader as ds | |
from joblib import parallel_backend | |
from mpl_toolkits.axes_grid1 import ImageGrid | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
import scanpy as sc |
OlderNewer