-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Dear author,
Thank you for constructing this fantastic tool.
While running spatialcorr.analysis_pipeline_set function, I got following errors.
Can you please take a loot at this and let me know what I can do to handle this?
Thank you,
Jihyun.
Kept 1723/1898 spots.
/Users/AA/opt/anaconda3/lib/python3.9/site-packages/numpy/lib/function_base.py:2897: RuntimeWarning: invalid value encountered in divide
c /= stddev[:, None]
/Users/AA/opt/anaconda3/lib/python3.9/site-packages/numpy/lib/function_base.py:2898: RuntimeWarning: invalid value encountered in divide
c /= stddev[None, :]
Cluster 'Submucosal connective tissues' has a singular covariance matrix. Removing spots from this cluster
Cluster 'mucsularis mucosa' has a singular covariance matrix. Removing spots from this cluster
Cluster 'Submucosal glands' has a singular covariance matrix. Removing spots from this cluster
Cluster 'Suprabasal' has a singular covariance matrix. Removing spots from this cluster
Cluster 'Basal (Hyperplasia)' has a singular covariance matrix. Removing spots from this cluster
Cluster 'Invasive' has a singular covariance matrix. Removing spots from this cluster
Cluster 'Submucosal vessels/lymphatics' has a singular covariance matrix. Removing spots from this cluster
Cluster 'Mucin ducts' has a singular covariance matrix. Removing spots from this cluster
IndexError Traceback (most recent call last)
Input In [7], in <cell line: 1>()
----> 1 spatialcorr.analysis_pipeline_set(
2 adata, # The dataset
3 LR_pairs, # The gene set
4 'cluster', # The key in adata.obs storing the cluster info
5 max_perms=100, # Maximum number of permutations to run
6 dsize=15, # Control the size of the dots
7 verbose=0, # Don't output any debugging information
8 )
File ~/opt/anaconda3/lib/python3.9/site-packages/spatialcorr/wrappers.py:611, in analysis_pipeline_set(adata, genes, cond_key, bandwidth, max_perms, row_key, col_key, reject_thresh, contrib_thresh, dsize, run_br, spot_to_neighbors, spot_to_neighbors_clust, n_procs, verbose, fig_path, fig_format, dpi)
591 kernel_matrix = compute_kernel_matrix(
592 adata.obs,
593 bandwidth=bandwidth,
(...)
597 region_key=cond_key
598 )
599 plot_filtered_spots(
600 adata,
601 kernel_matrix,
(...)
608 ticks=False
609 )
--> 611 p_val, additional = run_test(
612 adata,
613 genes,
614 bandwidth,
615 cond_key=cond_key,
616 contrib_thresh=contrib_thresh,
617 row_key=row_key,
618 col_key=col_key,
619 verbose=verbose,
620 n_procs=n_procs,
621 run_br=run_br,
622 compute_spotwise_pvals=True,
623 max_perms=max_perms,
624 mc_pvals=False,
625 spot_to_neighbors=spot_to_neighbors_clust
626 )
627 kept_inds = additional['kept_inds']
628 clust_to_p_val = additional['region_to_p_val']
File ~/opt/anaconda3/lib/python3.9/site-packages/spatialcorr/statistical_test.py:1128, in run_test(adata, test_genes, bandwidth, run_br, cond_key, contrib_thresh, row_key, col_key, precomputed_kernel, verbose, n_procs, compute_spotwise_pvals, standardize_var, max_perms, mc_pvals, spot_to_neighbors, alpha, compute_gene_pair_pvals, gene_pair_perms)
1113 p_val, t_obs, t_nulls, obs_spot_lls, spotwise_t_nulls, spot_p_vals = _between_groups_test(
1114 expr,
1115 adata.obs,
(...)
1125 spot_to_neighbors=spot_to_neighbors
1126 )
1127 else:
-> 1128 p_val, t_obs, t_nulls, obs_spot_lls, spotwise_t_nulls, ct_to_pval = _within_groups_test(
1129 expr,
1130 adata.obs,
1131 kernel_matrix,
1132 ct_to_indices=ct_to_indices,
1133 ct_to_indices_filt=ct_to_indices_filt,
1134 verbose=verbose,
1135 n_procs=n_procs,
1136 keep_indices=keep_inds,
1137 compute_clust_pvals=compute_spotwise_pvals, # TODO change variable name
1138 sequential_bail_out=max_perms,
1139 mc_pvals=mc_pvals,
1140 spot_to_neighbors=spot_to_neighbors
1141 )
1142 additional['region_to_p_val'] = ct_to_pval
1143 # Perform FDR correction for testing multiple regions
File ~/opt/anaconda3/lib/python3.9/site-packages/spatialcorr/statistical_test.py:923, in _within_groups_test(expr, df, kernel_matrix, verbose, n_procs, ct_to_indices, ct_to_indices_filt, keep_indices, use_sequential, sequential_n_greater, sequential_bail_out, compute_clust_pvals, mc_pvals, spot_to_neighbors)
920 all_spotwise_t_nulls = np.array(all_spotwise_t_nulls)[:len(all_t_nulls),:]
921 all_spotwise_t_nulls = all_spotwise_t_nulls.T
--> 923 ct_to_obs = {
924 ct: np.sum(np.array(obs_spot_lls)[inds])
925 for ct, inds in ct_to_indices_filt.items()
926 }
927 ct_to_nulls = {
928 ct: np.sum(all_spotwise_t_nulls[inds,:], axis=0)
929 for ct, inds in ct_to_indices_filt.items()
930 }
931 ct_to_p_val = {
932 ct: (len([x for x in ct_to_nulls[ct] if x > ct_to_obs[ct]])+1) / (len(ct_to_nulls[ct])+1)
933 for ct in ct_to_nulls
934 }
File ~/opt/anaconda3/lib/python3.9/site-packages/spatialcorr/statistical_test.py:924, in (.0)
920 all_spotwise_t_nulls = np.array(all_spotwise_t_nulls)[:len(all_t_nulls),:]
921 all_spotwise_t_nulls = all_spotwise_t_nulls.T
923 ct_to_obs = {
--> 924 ct: np.sum(np.array(obs_spot_lls)[inds])
925 for ct, inds in ct_to_indices_filt.items()
926 }
927 ct_to_nulls = {
928 ct: np.sum(all_spotwise_t_nulls[inds,:], axis=0)
929 for ct, inds in ct_to_indices_filt.items()
930 }
931 ct_to_p_val = {
932 ct: (len([x for x in ct_to_nulls[ct] if x > ct_to_obs[ct]])+1) / (len(ct_to_nulls[ct])+1)
933 for ct in ct_to_nulls
934 }
IndexError: index 410 is out of bounds for axis 0 with size 408