Closed lifan18 closed 10 months ago
Hi there. Thanks for your interest in SpaGCN. Regarding your questions:
Hi Dr. Hu,
Thank you very much for your reply! Really appreciate!
For the 3rd question above, I fixed the equal length of all arrays, however, it still has a trouble in radius calculation. See my codes as below.
adj_2d=spg.calculate_adj_matrix(x=x_array, y=y_array, histology=False)
start, end= np.quantile(adj_2d[adj_2d!=0],q=0.5), np.quantile(adj_2d[adj_2d!=0],q=0.1)
print(start)
print(end)
r=spg.search_radius(target_cluster=target, cell_id=raw.obs.index.tolist(), x=x_array, y=y_array, pred=raw.obs["pred"].tolist(), start=start, end=end, num_min=1, num_max=14, max_run=100)
#r=2.8726212047040462
#Detect neighboring domains
nbr_domians=spg.find_neighbor_clusters(target_cluster=target,
cell_id=raw.obs.index.tolist(),
x=raw.obs["x_array"].tolist(),
y=raw.obs["y_array"].tolist(),
pred=raw.obs["pred"].tolist(),
radius=r,
ratio=1/2)
The error reported as below.
Traceback (most recent call last):
File "w11_1_2_noreduce_SVGs.py", line 74, in <module>
ratio=1/2)
File "/usr/nzx-cluster/apps/SpaGCN/1.2.5/lib/python3.7/site-packages/SpaGCN/util.py", line 157, in find_neighbor_clusters
tmp_nbr=df[((df["x"]-x)**2+(df["y"]-y)**2)<=(radius**2)]
TypeError: unsupported operand type(s) for ** or pow(): 'NoneType' and 'int'
May you have tips on this trouble? Is the r calculation only for 10X chips?
Thank you!
Regards
Hi Dr. Hu,
Sorry for new questions. I am running SpaGCN for identifying SVGs using my spatial data.
There are some troubles stopped me to get through this section.
In the example,
I was trying to use Seurat cluster results named
RG1
,oRG
andEX
etc., could it be possible to use letters to define domains instead of numbers?The
x_pixel
andy_pixel
parameters, however, my data only includesx_array
andy_array
. From my observation, these two parameters only appear once, should I just ignore these two pixel settings in SVGs section?nbr_domians detection, I ran these code below and got some errors.
Detect neighboring domains
nbr_domians=spg.find_neighbor_clusters(target_cluster=target, cell_id=raw.obs.index.tolist(), x=raw.obs["x_array"].tolist(), y=raw.obs["y_array"].tolist(), pred=raw.obs["pred"].tolist(), radius=r, ratio=1/2)
Traceback (most recent call last): File "w11_1_2_noreduce_SVGs.py", line 58, in
r=spg.search_radius(target_cluster=target, cell_id=adata.obs.index.tolist(), x=x_array, y=y_array, pred=adata.obs["group"].tolist(), start=start, end=end, num_min=10, num_max=14, max_run=100)
File "/usr/nzx-cluster/apps/SpaGCN/1.2.5/lib/python3.7/site-packages/SpaGCN/util.py", line 111, in search_radius
num_low=count_nbr(target_cluster,cell_id, x, y, pred, start)
File "/usr/nzx-cluster/apps/SpaGCN/1.2.5/lib/python3.7/site-packages/SpaGCN/util.py", line 97, in count_nbr
df = pd.DataFrame(data=df)
File "/usr/nzx-cluster/apps/SpaGCN/1.2.5/lib/python3.7/site-packages/pandas/core/frame.py", line 614, in init
mgr = dict_to_mgr(data, index, columns, dtype=dtype, copy=copy, typ=manager)
File "/usr/nzx-cluster/apps/SpaGCN/1.2.5/lib/python3.7/site-packages/pandas/core/internals/construction.py", line 465, in dict_to_mgr
arrays, data_names, index, columns, dtype=dtype, typ=typ, consolidate=copy
File "/usr/nzx-cluster/apps/SpaGCN/1.2.5/lib/python3.7/site-packages/pandas/core/internals/construction.py", line 119, in arrays_to_mgr
index = _extract_index(arrays)
File "/usr/nzx-cluster/apps/SpaGCN/1.2.5/lib/python3.7/site-packages/pandas/core/internals/construction.py", line 635, in _extract_index
raise ValueError("All arrays must be of the same length")
ValueError: All arrays must be of the same length
Thank you very much!
Best