-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
10273a5
commit 7a584a7
Showing
31 changed files
with
1,478 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
""" | ||
Import/export ``Daf`` data from/to ``AnnData``. See the Julia | ||
`documentation <https://tanaylab.github.io/Daf.jl/v0.1.0/anndata_format.html>`__ for details. | ||
""" | ||
|
||
__all__ = ["h5ad_as_daf", "daf_as_h5ad"] | ||
|
||
from typing import Optional | ||
|
||
from .data import DafReader | ||
from .formats import MemoryDaf | ||
from .generic import JL_ABNORMAL_HANDLER | ||
from .generic import AbnormalHandler | ||
from .julia_import import jl | ||
|
||
|
||
def h5ad_as_daf( | ||
h5ad: str, | ||
*, | ||
name: Optional[str] = None, | ||
obs_is: Optional[str] = None, | ||
var_is: Optional[str] = None, | ||
X_is: Optional[str] = None, | ||
unsupported_handler: AbnormalHandler = "WarnHandler", | ||
) -> MemoryDaf: | ||
""" | ||
View ``AnnData`` as a ``Daf`` data set, specifically using a ``MemoryDaf``. See the Julia | ||
`documentation <https://tanaylab.github.io/Daf.jl/v0.1.0/anndata_format.html#anndata_as_daf>`__ for details. | ||
Note that you only pass an ``h5ad`` path, since the Julia ``AnnData`` object comes from the ``Muon.jl`` package and | ||
is not compatible with the Python ``anndata`` object. | ||
""" | ||
return MemoryDaf( | ||
jl.Daf.anndata_as_daf( | ||
h5ad, | ||
name=name, | ||
obs_is=obs_is, | ||
var_is=var_is, | ||
X_is=X_is, | ||
unsupported_handler=JL_ABNORMAL_HANDLER[unsupported_handler], | ||
) | ||
) | ||
|
||
|
||
def daf_as_h5ad( | ||
daf: DafReader, *, obs_is: Optional[str] = None, var_is: Optional[str] = None, X_is: Optional[str] = None, h5ad: str | ||
) -> None: | ||
""" | ||
View the ``Daf`` data set as ``AnnData``. See the Julia | ||
`documentation <https://tanaylab.github.io/Daf.jl/v0.1.0/anndata_format.html#Daf.AnnDataFormat.daf_as_anndata>`__ | ||
for details. | ||
Note this just creates the ``h5ad`` file. We do not return the ``AnnData`` object, because it is a Julia | ||
(``Muon.jl``) ``AnnData`` object, which is **not** a Python ``anndata`` ``AnnData`` object. | ||
""" | ||
jl.daf_as_anndata(daf, obs_is=obs_is, var_is=var_is, X_is=X_is, h5ad=h5ad) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
""" | ||
Types that arguably should belong in a more general-purpose package. See the Julia | ||
`documentation <https://tanaylab.github.io/Daf.jl/v0.1.0/generic.html>`__ for details. | ||
""" | ||
|
||
from typing import Literal | ||
|
||
from .julia_import import jl | ||
|
||
__all__ = ["AbnormalHandler"] | ||
|
||
|
||
#: The action to take when encountering an "abnormal" (but recoverable) operation. See the Julia | ||
#: `documentation <https://tanaylab.github.io/Daf.jl/v0.1.0/generic.html#Daf.Generic.AbnormalHandler>`__ for details. | ||
AbnormalHandler = Literal["IgnoreHandler"] | Literal["WarnHandler"] | Literal["ErrorHandler"] | ||
|
||
JL_ABNORMAL_HANDLER = { | ||
"IgnoreHandler": jl.Daf.Generic.IgnoreHandler, | ||
"WarnHandler": jl.Daf.Generic.WarnHandler, | ||
"ErrorHandler": jl.Daf.Generic.ErrorHandler, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
anndata_format | ||
============== | ||
|
||
.. automodule:: daf.anndata_format | ||
:Members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
<!DOCTYPE html> | ||
<html class="writer-html5" lang="en" data-content_root="../../"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>daf.anndata_format — Daf 0.1.0 documentation</title> | ||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" /> | ||
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" /> | ||
|
||
|
||
<!--[if lt IE 9]> | ||
<script src="../../_static/js/html5shiv.min.js"></script> | ||
<![endif]--> | ||
|
||
<script src="../../_static/jquery.js?v=5d32c60e"></script> | ||
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script> | ||
<script src="../../_static/documentation_options.js?v=01f34227"></script> | ||
<script src="../../_static/doctools.js?v=888ff710"></script> | ||
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script> | ||
<script src="../../_static/js/theme.js"></script> | ||
<link rel="index" title="Index" href="../../genindex.html" /> | ||
<link rel="search" title="Search" href="../../search.html" /> | ||
</head> | ||
|
||
<body class="wy-body-for-nav"> | ||
<div class="wy-grid-for-nav"> | ||
<nav data-toggle="wy-nav-shift" class="wy-nav-side"> | ||
<div class="wy-side-scroll"> | ||
<div class="wy-side-nav-search" > | ||
|
||
|
||
|
||
<a href="../../index.html" class="icon icon-home"> | ||
Daf | ||
<img src="../../_static/logo.svg" class="logo" alt="Logo"/> | ||
</a> | ||
<div class="version"> | ||
0.1.0 | ||
</div> | ||
<div role="search"> | ||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get"> | ||
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" /> | ||
<input type="hidden" name="check_keywords" value="yes" /> | ||
<input type="hidden" name="area" value="default" /> | ||
</form> | ||
</div> | ||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> | ||
<ul> | ||
<li class="toctree-l1"><a class="reference internal" href="../../readme.html">README</a></li> | ||
</ul> | ||
<ul> | ||
<li class="toctree-l1"><a class="reference internal" href="../../API.html">API</a></li> | ||
</ul> | ||
|
||
</div> | ||
</div> | ||
</nav> | ||
|
||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > | ||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i> | ||
<a href="../../index.html">Daf</a> | ||
</nav> | ||
|
||
<div class="wy-nav-content"> | ||
<div class="rst-content"> | ||
<div role="navigation" aria-label="Page navigation"> | ||
<ul class="wy-breadcrumbs"> | ||
<li><a href="../../index.html" class="icon icon-home" aria-label="Home"></a></li> | ||
<li class="breadcrumb-item"><a href="../index.html">Module code</a></li> | ||
<li class="breadcrumb-item active">daf.anndata_format</li> | ||
<li class="wy-breadcrumbs-aside"> | ||
</li> | ||
</ul> | ||
<hr/> | ||
</div> | ||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> | ||
<div itemprop="articleBody"> | ||
|
||
<h1>Source code for daf.anndata_format</h1><div class="highlight"><pre> | ||
<span></span><span class="sd">"""</span> | ||
<span class="sd">Import/export ``Daf`` data from/to ``AnnData``. See the Julia</span> | ||
<span class="sd">`documentation <https://tanaylab.github.io/Daf.jl/v0.1.0/anndata_format.html>`__ for details.</span> | ||
<span class="sd">"""</span> | ||
|
||
<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"h5ad_as_daf"</span><span class="p">,</span> <span class="s2">"daf_as_h5ad"</span><span class="p">]</span> | ||
|
||
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Optional</span> | ||
|
||
<span class="kn">from</span> <span class="nn">.data</span> <span class="kn">import</span> <span class="n">DafReader</span> | ||
<span class="kn">from</span> <span class="nn">.formats</span> <span class="kn">import</span> <span class="n">MemoryDaf</span> | ||
<span class="kn">from</span> <span class="nn">.generic</span> <span class="kn">import</span> <span class="n">JL_ABNORMAL_HANDLER</span> | ||
<span class="kn">from</span> <span class="nn">.generic</span> <span class="kn">import</span> <span class="n">AbnormalHandler</span> | ||
<span class="kn">from</span> <span class="nn">.julia_import</span> <span class="kn">import</span> <span class="n">jl</span> | ||
|
||
|
||
<div class="viewcode-block" id="h5ad_as_daf"> | ||
<a class="viewcode-back" href="../../anndata_format.html#daf.anndata_format.h5ad_as_daf">[docs]</a> | ||
<span class="k">def</span> <span class="nf">h5ad_as_daf</span><span class="p">(</span> | ||
<span class="n">h5ad</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> | ||
<span class="o">*</span><span class="p">,</span> | ||
<span class="n">name</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> | ||
<span class="n">obs_is</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> | ||
<span class="n">var_is</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> | ||
<span class="n">X_is</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> | ||
<span class="n">unsupported_handler</span><span class="p">:</span> <span class="n">AbnormalHandler</span> <span class="o">=</span> <span class="s2">"WarnHandler"</span><span class="p">,</span> | ||
<span class="p">)</span> <span class="o">-></span> <span class="n">MemoryDaf</span><span class="p">:</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
<span class="sd"> View ``AnnData`` as a ``Daf`` data set, specifically using a ``MemoryDaf``. See the Julia</span> | ||
<span class="sd"> `documentation <https://tanaylab.github.io/Daf.jl/v0.1.0/anndata_format.html#anndata_as_daf>`__ for details.</span> | ||
|
||
<span class="sd"> Note that you only pass an ``h5ad`` path, since the Julia ``AnnData`` object comes from the ``Muon.jl`` package and</span> | ||
<span class="sd"> is not compatible with the Python ``anndata`` object.</span> | ||
<span class="sd"> """</span> | ||
<span class="k">return</span> <span class="n">MemoryDaf</span><span class="p">(</span> | ||
<span class="n">jl</span><span class="o">.</span><span class="n">Daf</span><span class="o">.</span><span class="n">anndata_as_daf</span><span class="p">(</span> | ||
<span class="n">h5ad</span><span class="p">,</span> | ||
<span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span> | ||
<span class="n">obs_is</span><span class="o">=</span><span class="n">obs_is</span><span class="p">,</span> | ||
<span class="n">var_is</span><span class="o">=</span><span class="n">var_is</span><span class="p">,</span> | ||
<span class="n">X_is</span><span class="o">=</span><span class="n">X_is</span><span class="p">,</span> | ||
<span class="n">unsupported_handler</span><span class="o">=</span><span class="n">JL_ABNORMAL_HANDLER</span><span class="p">[</span><span class="n">unsupported_handler</span><span class="p">],</span> | ||
<span class="p">)</span> | ||
<span class="p">)</span></div> | ||
|
||
|
||
|
||
<div class="viewcode-block" id="daf_as_h5ad"> | ||
<a class="viewcode-back" href="../../anndata_format.html#daf.anndata_format.daf_as_h5ad">[docs]</a> | ||
<span class="k">def</span> <span class="nf">daf_as_h5ad</span><span class="p">(</span> | ||
<span class="n">daf</span><span class="p">:</span> <span class="n">DafReader</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">obs_is</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">var_is</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">X_is</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">h5ad</span><span class="p">:</span> <span class="nb">str</span> | ||
<span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
<span class="sd"> View the ``Daf`` data set as ``AnnData``. See the Julia</span> | ||
<span class="sd"> `documentation <https://tanaylab.github.io/Daf.jl/v0.1.0/anndata_format.html#Daf.AnnDataFormat.daf_as_anndata>`__</span> | ||
<span class="sd"> for details.</span> | ||
|
||
<span class="sd"> Note this just creates the ``h5ad`` file. We do not return the ``AnnData`` object, because it is a Julia</span> | ||
<span class="sd"> (``Muon.jl``) ``AnnData`` object, which is **not** a Python ``anndata`` ``AnnData`` object.</span> | ||
<span class="sd"> """</span> | ||
<span class="n">jl</span><span class="o">.</span><span class="n">daf_as_anndata</span><span class="p">(</span><span class="n">daf</span><span class="p">,</span> <span class="n">obs_is</span><span class="o">=</span><span class="n">obs_is</span><span class="p">,</span> <span class="n">var_is</span><span class="o">=</span><span class="n">var_is</span><span class="p">,</span> <span class="n">X_is</span><span class="o">=</span><span class="n">X_is</span><span class="p">,</span> <span class="n">h5ad</span><span class="o">=</span><span class="n">h5ad</span><span class="p">)</span></div> | ||
|
||
</pre></div> | ||
|
||
</div> | ||
</div> | ||
<footer> | ||
|
||
<hr/> | ||
|
||
<div role="contentinfo"> | ||
<p>© Copyright 2023-2024 Weizmann Institute of Science.</p> | ||
</div> | ||
|
||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a | ||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> | ||
provided by <a href="https://readthedocs.org">Read the Docs</a>. | ||
|
||
|
||
</footer> | ||
</div> | ||
</div> | ||
</section> | ||
</div> | ||
<script> | ||
jQuery(function () { | ||
SphinxRtdTheme.Navigation.enable(true); | ||
}); | ||
</script> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.