You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeError: unsupported operand type(s) for -: 'str' and 'int'
It seems the imagecol and imagerow are dtypes int64, I don't know if this is the dtype they are supposed to be. The cell_type obs is a category dtype. Any help would be greatly appreciated!
The text was updated successfully, but these errors were encountered:
Hello,
I have visium data that I converted to an Anndata object using the stlearn workflow:
https://stlearn.readthedocs.io/en/latest/tutorials/Read_any_data.html
import stlearn as st
import pandas as pd
import numpy
count_matrix = pandas.read_csv("
/Anndata_objects/s18_counts.csv")/Anndata_objects/s18_coordinates.csv")spatial = pandas.read_csv("
metadata = pandas.read_csv("~/Anndata_objects/s18_metadata.csv")
adata = st.create_stlearn(count=count_matrix,spatial=spatial,library_id="s18", scale=1,background_color="white")
adata.obs["cell_type"] = numpy.asarray(metadata["celltype"])
adata.obs["cell_type"] = pd.Categorical(adata.obs["cell_type"]
print(adata)
AnnData object with n_obs × n_vars = 3064 × 14290
obs: 'imagecol', 'imagerow', 'cell_type'
uns: 'spatial'
obsm: 'spatial'
print(adata.obs['cell_type'])
0 Astro
1 Astro
2 Astro
3 Astro
4 Astro
...
3059 Astro
3060 Astro
3061 Astro
3062 Astro
3063 Astro
Name: cell_type, Length: 3064, dtype: category
Categories (4, object): ['Astro', 'Inhib.neurons', 'OC-like', 'Pericyte']
print(adata.obs['imagecol'])
print(adata.obs['imagerow'])
0 9484
1 10932
2 3795
3 11225
4 8690
...
3059 6488
3060 10767
3061 11087
3062 8716
3063 2701
Name: imagecol, Length: 3064, dtype: int64
0 3721
1 11258
2 4467
3 4170
4 2543
...
3059 6003
3060 9169
3061 10258
3062 10539
3063 8378
Name: imagerow, Length: 3064, dtype: int64
When I try to then run st.pl.cluster_plot(adata, use_label='cell_type'), I get the following error:
TypeError Traceback (most recent call last)
in
----> 1 st.pl.cluster_plot(adata, use_label='cell_type')
/usr/local/python/lib/python3.9/site-packages/stlearn/plotting/cluster_plot.py in cluster_plot(adata, title, figsize, cmap, use_label, list_clusters, ax, fig, show_plot, show_axis, show_image, show_color_bar, zoom_coord, crop, margin, size, image_alpha, cell_alpha, fname, dpi, show_subcluster, show_cluster_labels, show_trajectories, reverse, show_node, threshold_spots, text_box_size, color_bar_size, bbox_to_anchor, trajectory_node_size, trajectory_alpha, trajectory_width, trajectory_edge_color, trajectory_arrowsize)
85 assert use_label != None, "Please select
use_label
parameter"86
---> 87 ClusterPlot(
88 adata,
89 title=title,
/usr/local/python/lib/python3.9/site-packages/stlearn/plotting/classes.py in init(self, adata, title, figsize, cmap, use_label, list_clusters, ax, fig, show_plot, show_axis, show_image, show_color_bar, crop, zoom_coord, margin, size, image_alpha, cell_alpha, fname, dpi, show_subcluster, show_cluster_labels, show_trajectories, reverse, show_node, threshold_spots, text_box_size, color_bar_size, bbox_to_anchor, trajectory_node_size, trajectory_alpha, trajectory_width, trajectory_edge_color, trajectory_arrowsize)
659 trajectory_arrowsize: Optional[int] = 17,
660 ):
--> 661 super().init(
662 adata=adata,
663 title=title,
/usr/local/python/lib/python3.9/site-packages/stlearn/plotting/classes.py in init(self, adata, title, figsize, cmap, use_label, list_clusters, ax, fig, show_plot, show_axis, show_image, show_color_bar, color_bar_label, zoom_coord, crop, margin, size, image_alpha, cell_alpha, use_raw, fname, dpi, **kwds)
136 crop = False
137 if crop:
--> 138 self._crop_image(self.ax, margin)
139
140 def _select_clusters(self):
/usr/local/python/lib/python3.9/site-packages/stlearn/plotting/classes.py in _crop_image(self, main_ax, margin)
186 def _crop_image(self, main_ax: _AxesSubplot, margin: float):
187
--> 188 main_ax.set_xlim(self.imagecol.min() - margin, self.imagecol.max() + margin)
189
190 main_ax.set_ylim(self.imagerow.min() - margin, self.imagerow.max() + margin)
TypeError: unsupported operand type(s) for -: 'str' and 'int'
It seems the imagecol and imagerow are dtypes int64, I don't know if this is the dtype they are supposed to be. The cell_type obs is a category dtype. Any help would be greatly appreciated!
The text was updated successfully, but these errors were encountered: