Skip to content

Add MAGIC API - #193

Merged
falexwolf merged 2 commits into
scverse:masterfrom
scottgigante:master
Jul 11, 2018
Merged

falexwolf merged 2 commits into
scverse:masterfrom
scottgigante:master

Conversation

@scottgigante

Copy link
Copy Markdown
Contributor

MAGIC API modelled off the DCA API. A couple of comments:

  • I changed threads to n_jobs to match sc.tl API
  • I use sc.settings.verbosity rather than False for verbose default
  • I updated the PHATE API while I was here
  • I'm open to suggestions on how to handle name_list.

Re: name_list: MAGIC accepts both gene names and column indices. I've set it up currently to return to adata.obsm['X_magic'] if genes are specified as the number of columns is reduced from the original data, and to adata.X if all genes are returned. However, adata.obsm['X_magic'] now has no information about the order of the genes, unless I return it from MAGIC as a pandas.DataFrame, or as an AnnData object in its own right. What do you think?

P.S. MAGIC handling genes on AnnData input is currently on the dev branch, but will be merged to master once we settle on an API.

@falexwolf

Copy link
Copy Markdown
Member

Looks good! Thanks! 😄

@falexwolf
falexwolf merged commit a968194 into scverse:master Jul 11, 2018
@falexwolf

Copy link
Copy Markdown
Member

However, adata.obsm['X_magic'] now has no information about the order of the genes, unless I return it from MAGIC as a pandas.DataFrame, or as an AnnData object in its own right. What do you think?

Just read this again. Right. This is not a good solution. Let met think about.

@scottgigante

Copy link
Copy Markdown
Contributor Author

One option is to not allow using to request a gene subset with MAGIC from Scanpy, but I don't particularly like that as the returned data is forcibly dense and could be extremely large. Alternatively, I could return a new AnnData object (force copy=True) with var_names corresponding to the genes that were returned.

@falexwolf

Copy link
Copy Markdown
Member

I'd say that the second option is very viable for the task of imputation, which is a bit different than all other tools - instead of "adding" annotation, one replaces the whole data matrix.

So, I'd say, if you do not want to impute the whole data matrix as is, one should return a new AnnData for the wished gene selection.

Now the only problem is that people might get confused because magic doesn't do an inplace operation in this case.

So I'd leave copy=None, the default behavior being the inplace replacement of the full data matrix. If one passes a gene list, the passed AnnData should stay unchanged but a new imputed "AnnData" is returned. People can then directly use this for further tasks...

Sounds like a good solution to me.

@scottgigante scottgigante mentioned this pull request Jul 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants