Using graph from Scanpy
Hrovatin opened this issue · 6 comments
Is there a way to use MELD with a graph from Scanpy? I have some large datasets and I would like to avoid recomputing graphs, since my adata already contains a graph and I can easily save it together with my adata if I just use Scanpy. Not sure about how your graphtools graph works.
Also, transform says
sample_indicators : ndarray [n, p]
1- or 2-dimensional sample indicator array to filter.
But I get an error if I inpput already one-hot encoded labels as it expects categorical column it seems.
Could you enable passing of one hot encoding as I would like some cells to belong to no category (e.g. I do not want to compute densities for all categories).
Hi @Hrovatin! Thanks for your interest in MELD. You can use the connecitivies matrix from scanpy.pp.neighbors
to build a graphtools Graph and pass that to MELD like this:
G = gt.Graph(adata.obsp["connectivities"], precomputed="adjacency")
meld_op.fit(G)
# Run on a 1-dimensional indicator vector
sample_densities = meld_op.transform(np.random.binomial(1, 0.5, size=G.N))
Then you could just take sample_densities[1]
to get the density for the positive case. You can't calculate a likelihood here because you're not wanting the "not-1" case to be a category. Does that make sense? You'll need to use the densities for the 1
category as densities directly.
Thank you.
However, I decided to do normalization over conditions for which I computed MELD as this gives me results that better correspond to ground truth based on marker genes.
Interesting, can you share that analysis/comparison? If you'd prefer to do it in a private channel you can find my email in my github profile.
I have contacted you over email.
@Hrovatin @dburkhardt would you two be willing to share the outcome of your discussion? I'd be interested in the conclusions.
Thanks!