Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly return lineages from scprep.run.slingshot.Slingshot #122

Open
alex-claman opened this issue Jun 17, 2021 · 0 comments
Open

Explicitly return lineages from scprep.run.slingshot.Slingshot #122

alex-claman opened this issue Jun 17, 2021 · 0 comments

Comments

@alex-claman
Copy link

Hello!

I really appreciate the wrapper you've built for the Slingshot function! It's the only way I found to use Slingshot from Python. However, I noticed something when trying to make inferences/graphs from the information provided by the function: the lineages returned by the R version of the Slingshot function are dropped with the way the function is written at the moment.

I was able to make some small modifications to scprep/scprep/run/slingshot.py to add a "lineages" key/value to the dictionary returned from the Python version of the Slingshot function.

From Line 63:
list(pseudotime = slingPseudotime(sling), curves = lapply(sling@curves, function(curve) curve$s[curve$ord,]))
I added a small change to also save the lineage information:
list(pseudotime = slingPseudotime(sling), curves = lapply(sling@curves, function(curve) curve$s[curve$ord,]), lineages = sling@lineages)

After Line 260:
slingshot["curves"] = np.array(list(slingshot["curves"].values()))
I added a similar line to cast from <U1 to int:
slingshot["lineages"] = {k: v.astype(int) for k, v in slingshot['lineages'].items()}

This allows me to go on to use the lineages, which are returned in a dictionary.

An example of the "lineages" key/value from the returned dictionary:
'lineages': {'Lineage1': array([7, 5, 0, 1, 4, 3, 2]), 'Lineage2': array([7, 5, 0, 1, 4, 3, 8]), 'Lineage3': array([7, 5, 0, 1, 4, 3, 9]), 'Lineage4': array([7, 5, 0, 6])}

Let me know if anything else would be helpful, if this isn't the proper forum for this request, or if I missed something that allowed for this functionality already! These would just be useful for my analyses and it would be nice for this feature to be included in the package for reproducibility and portability.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant