-
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.
Merge pull request #22 from yutanagano/move_functional_api_to_top
Move functional api to top
- Loading branch information
Showing
10 changed files
with
86 additions
and
100 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ API reference | |
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
sceptr_sceptr | ||
sceptr | ||
sceptr_variant |
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,7 @@ | ||
.. _api: | ||
|
||
`sceptr` | ||
=============== | ||
|
||
.. automodule:: sceptr | ||
:members: |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,7 +1,75 @@ | ||
""" | ||
Simple Contrastive Embedding of the Primary sequence of T cell Receptors | ||
======================================================================== | ||
SCEPTR is a small, fast, and performant TCR representation model for alignment-free TCR analysis. | ||
The root module provides easy access to SCEPTR through a functional API which uses the default :py:class:`~sceptr.model.Sceptr` model. | ||
""" | ||
|
||
VERSION = "1.0.0-beta.1" | ||
from sceptr import variant | ||
from sceptr.model import Sceptr | ||
import sys | ||
from numpy import ndarray | ||
from pandas import DataFrame | ||
|
||
|
||
__version__ = "1.0.0-beta.1" | ||
|
||
|
||
def calc_cdist_matrix(anchors: DataFrame, comparisons: DataFrame) -> ndarray: | ||
""" | ||
Generate a cdist matrix between two collections of TCRs. | ||
Parameters | ||
---------- | ||
anchors : DataFrame | ||
DataFrame in the :ref:`prescribed format <data_format>`. | ||
comparisons : DataFrame | ||
DataFrame in the :ref:`prescribed format <data_format>`. | ||
Returns | ||
------- | ||
ndarray | ||
A 2D numpy ndarray representing a cdist matrix between TCRs from `anchors` and `comparisons`. | ||
The returned array will have shape (X, Y) where X is the number of TCRs in `anchors` and Y is the number of TCRs in `comparisons`. | ||
""" | ||
return get_default_model().calc_cdist_matrix(anchors, comparisons) | ||
|
||
|
||
def calc_pdist_vector(instances: DataFrame) -> ndarray: | ||
""" | ||
Generate a pdist set of distances between each pair of TCRs in the input data. | ||
Parameters | ||
---------- | ||
instances : DataFrame | ||
DataFrame in the :ref:`prescribed format <data_format>`. | ||
Returns | ||
------- | ||
ndarray | ||
A 2D numpy ndarray representing a pdist vector of distances between each pair of TCRs in `instances`. | ||
The returned array will have shape (1/2 * N * (N-1),), where N is the number of TCRs in `instances`. | ||
""" | ||
return get_default_model().calc_pdist_vector(instances) | ||
|
||
|
||
def calc_vector_representations(instances: DataFrame) -> ndarray: | ||
""" | ||
Map a table of TCRs provided as a pandas DataFrame in the above format to a set of vector representations. | ||
Parameters | ||
---------- | ||
instances : DataFrame | ||
DataFrame in the :ref:`prescribed format <data_format>`. | ||
Returns | ||
------- | ||
ndarray | ||
A 2D numpy ndarray object where every row vector corresponds to a row in `instances`. | ||
The returned array will have shape (N, D) where N is the number of TCRs in `instances` and D is the dimensionality of the SCEPTR model. | ||
""" | ||
return get_default_model().calc_vector_representations(instances) | ||
|
||
|
||
def get_default_model() -> Sceptr: | ||
if "_DEFAULT_MODEL" not in dir(sys.modules[__name__]): | ||
setattr(sys.modules[__name__], "_DEFAULT_MODEL", variant.default()) | ||
return _DEFAULT_MODEL |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from sceptr import sceptr | ||
import sceptr | ||
import numpy as np | ||
import pandas as pd | ||
import pytest | ||
|