How to implement MonkeyBread pipeline for Visium spatial data

Hi there!
I am trying to implement MonkeyBread package on my spatial transcriptomics data but I get some error while I have put all the data files needed in the directory:

I followed the tutorial so far exactly as explained. But get this error.

folder_path = ‘/Users/pedram/Desktop/MonkeyBread’
adata = mb.util.load_merscope(folder_path)
… reading from cache file cache/Users-pedram-Desktop-MonkeyBread-cell_by_gene.h5ad

KeyError Traceback (most recent call last)
Input In [25], in <cell line: 2>()
1 folder_path = '/Users/pedram/Desktop/MonkeyBread
----> 2 adata = mb.util.load_merscope(folder_path)

File ~/opt/anaconda3/lib/python3.9/site-packages/monkeybread/util/_load_merscope.py:74, in load_merscope(folder, use_cache, cell_bounds, transcript_locations, paths)
72 coordinates = pd.read_csv(f"{folder}/{paths[‘coordinates’]}")
73 coordinates = coordinates.rename({“Unnamed: 0”: “cell_id”}, axis=1)
—> 74 data = counts[coordinates.cell_id] # Slice data by coordinate index
75 data.obsm[“X_spatial”] = coordinates[[“center_x”, “center_y”]].to_numpy()
76 data.obs[“width”] = coordinates[“max_x”].to_numpy() - coordinates[“min_x”].to_numpy()

File ~/opt/anaconda3/lib/python3.9/site-packages/anndata/_core/anndata.py:1113, in AnnData.getitem(self, index)
1111 def getitem(self, index: Index) → “AnnData”:
1112 “”“Returns a sliced view of the object.”“”
→ 1113 oidx, vidx = self._normalize_indices(index)
1114 return AnnData(self, oidx=oidx, vidx=vidx, asview=True)

File ~/opt/anaconda3/lib/python3.9/site-packages/anndata/_core/anndata.py:1094, in AnnData._normalize_indices(self, index)
1093 def _normalize_indices(self, index: Optional[Index]) → Tuple[slice, slice]:
→ 1094 return _normalize_indices(index, self.obs_names, self.var_names)

File ~/opt/anaconda3/lib/python3.9/site-packages/anndata/_core/index.py:35, in _normalize_indices(index, names0, names1)
33 index = index[0].values, index[1]
34 ax0, ax1 = unpack_index(index)
—> 35 ax0 = _normalize_index(ax0, names0)
36 ax1 = _normalize_index(ax1, names1)
37 return ax0, ax1

File ~/opt/anaconda3/lib/python3.9/site-packages/anndata/_core/index.py:101, in _normalize_index(indexer, index)
99 if np.any(positions < 0):
100 not_found = indexer[positions < 0]
→ 101 raise KeyError(
102 f"Values {list(not_found)}, from {list(indexer)}, "
103 “are not valid obs/ var names or indices.”
104 )
105 return positions # np.ndarray[int]
106 else:

KeyError: “Values [‘AAACAAGTATCTCCCA.1’, ‘AAACAATCTACTAGCA.1’, ‘AAACACCAATAACTGC.1’, ‘AAACAGAGCGACTCCT.1’, ‘AAACAGGGTCTATATT.1’, ‘AAACAGTGTTCCTGGG.1’, ‘AAACATTTCCCGGATT.1’, ‘AAACCGGGTAGGTACC.1’, ‘AAACCGTTCGTCCAGG.1’, ‘AAACCTAAGCAGCCGG.1’, ‘AAACCTCATGAAGTTG.1’, ‘AAACGAAGAACATACC.1’, ‘AAACGAGACGGTTGAT.1’, ‘AAACGGGCGTACGGGT.1’, ‘AAACGGTTGCGAACTG.1’, ‘AAACGTGTTCGCCCTA.1’, ‘AAACTAACGTGGCGAC.1’, ‘AAACTCGGTTCGCAAT.1’, ‘AAACTCGTGATATAAG.1’, ‘AAACTGCTGGCTCCAA.1’, ‘AAACTTAATTGCACGC.1’, ‘AAACTTGCAAACGTAT.1’, ‘AAAGACCCAAGTCGCG.1’, ‘AAAGACTGGGCGCTTT.1’, ‘AAAGCTTGCCTACATA.1’, ‘AAAGGCCCTATAATAC.1’, ‘AAAGGCTACGGACCAT.1’, ‘AAAGGCTCTCGCGCCG.1’, ‘AAAGGGATGTAGCAAG.1’, ‘AAAGGGCAGCTTGAAT.1’, ‘AAAGGTAAGCTGTACC.1’, 'AAAGTAGCATTGC”

Hi, thanks for reaching out.

It seems that the error is related to the AnnData package and not the SpatialData package. Could you please provide additional details? Which tutorial did you run? Also, can you post a reproducible minimal working example of the code that fails (or as a start the code that fails itself, even if not reproducible, sometimes it is enough).

Thanks @LucaMarconato for your response.
I follow this tutorial:
Tutorial — monkeybread

Everything from the first codes are working great.But when it comes to this, I get error:
“# No need to specify custom file paths, this function will read in all relevant files in the directory provided.
adata = mb.util.load_merscope(”./data")"[quote=“LucaMarconato, post:2, topic:1693, full:true”]
Hi, thanks for reaching out.

It seems that the error is related to the AnnData package and not the SpatialData package. Could you please provide additional details? Which tutorial did you run? Also, can you post a reproducible minimal working example of the code that fails (or as a start the code that fails itself, even if not reproducible, sometimes it is enough).
[/quote]

[quote=“LucaMarconato, post:2, topic:1693, full:true”]
Hi, thanks for reaching out.

It seems that the error is related to the AnnData package and not the SpatialData package. Could you please provide additional details? Which tutorial did you run? Also, can you post a reproducible minimal working example of the code that fails (or as a start the code that fails itself, even if not reproducible, sometimes it is enough).

Thanks for the additional info. It seems indeed a bug in the monkeybread package, not developed by us.

I see that you opened a issue also there, so I am going to link it here for future reference (Cannot merge the dataset · Issue #25 · immunitastx/monkeybread · GitHub) and close this thread.