I tried to separately include the "spatial" cooridnates and images into adata.
1) Adding tissue coodinates :
c = scanpy.read_h5ad("p.h5ad")
all = pd.read_csv('spatial.csv', delimiter = ',',index_col=0) # " three Colum data
label imagerow imagecol
0 AAACCGGGTAGGTACC-1_1 261.297067 313.946997
1 AAACCGTTCGTCCAGG-1_1 233.577403 348.256620
2 AAACCTCATGAAGTTG-1_1 279.114362 296.827053
del all[all. columns[0]] # removed barcodes
all = all.to_numpy()
c.obsm["spatial"] = all
2) Reading image ##
import matplotlib.pyplot as plt
import PIL
import numpy as np
from PIL import Image
source_image_path="tissue_hires_image.png"
im = Image.open(source_image_path)
image = numpy.array(im)
image=image
spatial_key = "spatial"
library_id = "A1"
c.uns[spatial_key] = {library_id: {}}
c.uns[spatial_key][library_id]["images"] = {}
c.uns['spatial'][library_id]['images']['hires'] = image.astype(np.float32)
3) Plotting spatial cluster
sq.pl.spatial_scatter(c, color="integrated_snn_res.0.7")
It shows a image to one side. How can I fix this issue ?
I would appreciate all the suggestion.
Hi, were you able to figure this out? I found that I couldn't even transfer pca information using Convert, the result only had umap information.