Open jamesboot opened 2 months ago
Thanks! It's tricky to add support directly to proseg, because h5ad is a pretty complex format, but I ought to include python code to do this in the future. In the mean time, something like this should do the trick:
import pandas as pd
import numpy as np
from anndata import AnnData
# Or, `pd.read_csv` if csv files were generated by proseg
df_counts = pd.read_parquet("expected-counts.parquet")
df_metadata = pd.read_parquet("cell-metadata.parquet")
X = np.asarray(df_counts, dtype=np.float32)
xys = np.stack([df_metadata.centroid_x, df_metadata.centroid_y], 1)
adata = AnnData(
X=X,
obs=df_metadata,
obsm={"spatial": xys},
var=pd.DataFrame(index=df_counts.columns))
Thanks! Will give that a go
Hi,
Thanks for creating such a great tool, love the pre-print.
I'm thinking about applying this method to some CosMx data. I already have a pipeline for importing CosMx data into squidpy and then using some of the tools available there to perform spatial analysis. I was just wondering if it is possible to generate an AnnData object from the proseg outputs, or if you have any recommendations for analysis tools/packages downstream of proseg?
Cheers James