squidpy
squidpy copied to clipboard
Calculate Moran's I statistic using `obsm` or `obs`
Description
Calculate Moran's I statistic using obsm
or obs
instead of just columns in var
...
I was wondering if it would be possible to add this functionality to sq.gr.spatial_autocorr()
? I tried using sq.pl.extract(dataset, "X")
to move dataset.obsm["X"]
into dataset.obs
, but it seems the genes
parameter of sq.gr.spatial_autocorr()
is only supposed to be used for columns in dataset.var
. Would it be possible to expand this function for this use case?
As a followup, I managed to accomplish what I wanted using:
from scanpy.metrics._morans_i import morans_i
morans_i(dataset.obsp["adjacency_matrix"], dataset.obsm["X"].T)
So I guess I was just wondering if there was a nice way this could be integrated into Squidpy.
Are you looking for more functionality than you'd get from:
sc.metrics.morans_i(dataset, use_graph="adjacency_matrix", obsm="X")
@alam-shahul I'd check out @ivirshup suggestion, calling scanpy directly. We provide a parallelized version but it'd be a bit of work to allow for non-genes to be handled. let us know if it works
closing