Open jianggl2000 opened 9 months ago
I fixed the cell, it now works:
#Read original 10x_h5 data and save it to h5ad
from scanpy import read_10x_h5
adata = read_10x_h5("path/filtered_feature_bc_matrix.h5")
spatial=pd.read_csv("path/spatial/tissue_positions_list.csv",
sep=",",header=None,na_filter=False,index_col=0)
adata.obs["Sample"]=spatial[1]
adata.obs["array_x"]=spatial[2]
adata.obs["array_y"]=spatial[3]
adata.obs["pixel_x"]=spatial[4]
adata.obs["pixel_y"]=spatial[5]
#Select captured samples
adata=adata[adata.obs["Sample"]==1]
adata.var_names=[i.upper() for i in list(adata.var_names)]
adata.var["genename"]=adata.var.index.astype("str")
adata.write_h5ad("Spatial.h5ad")
Also if using cv2 (method 1), this line of code:
spots=counts.obs.loc[:, ['pixel_x', 'pixel_y', "array_x", "array_y"]]
must also be executed
Thanks for the great work! The tutorial gives an example on how to convert h5 to h5ad.
However, the data
['pixel_x', 'pixel_y', "array_x", "array_y"]
are not created withread_10x_h5
by default. Should the following code be added or to replace x2-x5 above?Also, I cannot find the pkl files in the results folder, nor in download data/results files, for
7.1 Read in cell type annotations
.FileNotFoundError: [Errno 2] No such file or directory: './results/B_annotation_c_d.pkl'
did I miss anything?