Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Release v0.6.1

See merge request tron/addannot!196
  • Loading branch information
Pablo Riesgo Ferreiro committed Feb 8, 2022
2 parents ed32e53 + 4edb733 commit a83c4be
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 115 deletions.
4 changes: 3 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ include neofox/published_features/hex/EPItOMe_modified.R
include neofox/published_features/hex/hex.R
include neofox/expression_imputation/tcga_cohort_code.tab
include neofox/expression_imputation/tcga_exp_summary_modified.tab.gz.tbi
include neofox/expression_imputation/tcga_exp_summary_modified.tab.gz
include neofox/expression_imputation/tcga_exp_summary_modified.tab.gz
include requirements.txt
include README.md
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ Sphinx==4.2.0
m2r2==0.3.1
nbsphinx==0.8.7
pandoc==1.1.0
ipython==7.16.1
ipython==8.0.1
ipykernel==5.3.4
#sphinx_rtd_theme==0.5.0
#insipid_sphinx_theme==0.2.1
pydata-sphinx-theme==0.7.1
Jinja2==2.11
Jinja2==3.0.3
11 changes: 9 additions & 2 deletions docs/source/03_03_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ There are two ways to use NeoFox for annotation of neoantigen candidates with ne
To call NeoFox from the command line, use the following command. Make sure that the requirements have been added to PATH as described [here](02_installation.md) or add a config file as described below:

````commandline
neofox --candidate-file/--json-file neoantigens_candidates.tab/neoantigens_candidates.json --patient-data patient_data.txt --output-folder /path/to/out --output-prefix out_prefix [--with-table] [--with-json] [--num_cpus] [--affinity-threshold] [--config] [--patient-id]
neofox --candidate-file/--json-file neoantigens_candidates.tab/neoantigens_candidates.json \
--patient-data patient_data.txt \
--output-folder /path/to/out \
--output-prefix out_prefix \
[--with-table] [--with-json] [--num_cpus] [--affinity-threshold] [--config] [--patient-id]
````

where:
Expand All @@ -34,7 +38,10 @@ where:
This is an example to call NeoFox with a candidate-file and obtaining the annotated neoantigen candidates in [tabular](03_02_output_data.md#tabular-format) format:

````commandline
neofox --candidate-file neoantigens_candidates.tab --patient-data patient_data.tab --output-folder /path/to/out --output-prefix test
neofox --candidate-file neoantigens_candidates.tab \
--patient-data patient_data.tab \
--output-folder /path/to/out \
--output-prefix test
````

The optional **config** file with the paths to the dependencies can look like this:
Expand Down
5 changes: 0 additions & 5 deletions docs/source/03_04_examples.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Examples

## Notebooks

- :ref:`/notebooks/api_usage.ipynb`


## Demo dataset

- :download:`Neoantigens input file </notebooks/test_model_file.txt>`
Expand Down
173 changes: 70 additions & 103 deletions docs/source/notebooks/api_usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{
"data": {
"text/plain": [
"'0.5.4.dev3'"
"'0.6.1'"
]
},
"execution_count": 1,
Expand Down Expand Up @@ -55,53 +55,32 @@
"### Create a neoantigen\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from neofox.model.neoantigen import Neoantigen, Mutation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create a mutation:"
"Create a neoantigen candidate:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"mutation = Mutation(\n",
" wild_type_xmer=\"DEVLGEPSQDILVIDQTRLEATISPET\", \n",
" mutated_xmer=\"DEVLGEPSQDILVTDQTRLEATISPET\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create a neoantigen using the previous transcript and mutation:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"neoantigen = Neoantigen(\n",
"from neofox.model.factories import NeoantigenFactory\n",
"\n",
"# create a neoantigen candidate using the factory\n",
"neoantigen = NeoantigenFactory.build_neoantigen(\n",
" mutated_xmer=\"DEVLGEPSQDILVTDQTRLEATISPET\",\n",
" wild_type_xmer=\"DEVLGEPSQDILVIDQTRLEATISPET\",\n",
" patient_identifier=\"P123\", \n",
" mutation=mutation, \n",
" gene=\"VCAN\", \n",
" gene=\"VCAN\",\n",
" rna_expression=0.519506894, \n",
" rna_variant_allele_frequency=0.857142857, \n",
" dna_variant_allele_frequency=0.294573643)"
" dna_variant_allele_frequency=0.294573643,\n",
" my_custom_annotation=\"add any custom annotation as additional fields with any name\"\n",
")"
]
},
{
Expand All @@ -119,7 +98,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand All @@ -130,12 +109,22 @@
" \"patientIdentifier\": \"P123\",\n",
" \"gene\": \"VCAN\",\n",
" \"mutation\": {\n",
" \"position\": [\n",
" 14\n",
" ],\n",
" \"wildTypeXmer\": \"DEVLGEPSQDILVIDQTRLEATISPET\",\n",
" \"mutatedXmer\": \"DEVLGEPSQDILVTDQTRLEATISPET\"\n",
" },\n",
" \"rnaExpression\": 0.519506894,\n",
" \"imputedGeneExpression\": null,\n",
" \"dnaVariantAlleleFrequency\": 0.294573643,\n",
" \"rnaVariantAlleleFrequency\": 0.857142857\n",
" \"rnaVariantAlleleFrequency\": 0.857142857,\n",
" \"externalAnnotations\": [\n",
" {\n",
" \"name\": \"my_custom_annotation\",\n",
" \"value\": \"add any custom annotation as additional fields with any name\"\n",
" }\n",
" ]\n",
"}\n"
]
}
Expand All @@ -153,22 +142,26 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'patientIdentifier': 'P123',\n",
" 'gene': 'VCAN',\n",
" 'mutation': {'wildTypeXmer': 'DEVLGEPSQDILVIDQTRLEATISPET',\n",
" 'mutation': {'position': [14],\n",
" 'wildTypeXmer': 'DEVLGEPSQDILVIDQTRLEATISPET',\n",
" 'mutatedXmer': 'DEVLGEPSQDILVTDQTRLEATISPET'},\n",
" 'rnaExpression': 0.519506894,\n",
" 'imputedGeneExpression': None,\n",
" 'dnaVariantAlleleFrequency': 0.294573643,\n",
" 'rnaVariantAlleleFrequency': 0.857142857}"
" 'rnaVariantAlleleFrequency': 0.857142857,\n",
" 'externalAnnotations': [{'name': 'my_custom_annotation',\n",
" 'value': 'add any custom annotation as additional fields with any name'}]}"
]
},
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -186,16 +179,16 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"b'\\n\\x04P123\\x12\\x04VCAN\\x1a:\\x12\\x1bDEVLGEPSQDILVIDQTRLEATISPET\\x1a\\x1bDEVLGEPSQDILVTDQTRLEATISPET%g\\xfe\\x04?5[\\xd2\\x96>=\\xb7m[?'"
"b'\\n\\x04P123\\x12\\x04VCAN\\x1a=\\n\\x01\\x0e\\x12\\x1bDEVLGEPSQDILVIDQTRLEATISPET\\x1a\\x1bDEVLGEPSQDILVTDQTRLEATISPET%g\\xfe\\x04?5[\\xd2\\x96>=\\xb7m[?JT\\n\\x14my_custom_annotation\\x12<add any custom annotation as additional fields with any name'"
]
},
"execution_count": 7,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -217,57 +210,14 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from neofox.model.conversion import ModelConverter"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Transform a neoantigen into a Pandas `Series`:"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"patient_identifier P123\n",
"gene VCAN\n",
"rna_expression 0.519507\n",
"imputed_gene_expression 0\n",
"dna_variant_allele_frequency 0.294574\n",
"rna_variant_allele_frequency 0.857143\n",
"external_annotations []\n",
"mutation.position []\n",
"mutation.wild_type_xmer DEVLGEPSQDILVIDQTRLEATISPET\n",
"mutation.mutated_xmer DEVLGEPSQDILVTDQTRLEATISPET\n",
"neofox_annotations.annotations []\n",
"neofox_annotations.annotator \n",
"neofox_annotations.annotator_version \n",
"neofox_annotations.timestamp \n",
"neofox_annotations.resources_hash \n",
"Name: 0, dtype: object"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"neoantigen_series = ModelConverter.object2series(neoantigen)\n",
"neoantigen_series"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -499,7 +449,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -516,14 +466,14 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"[E 210928 12:18:02 validation:85] {}\n"
"[E 220208 11:32:29 validation:86] {}\n"
]
},
{
Expand All @@ -535,6 +485,8 @@
}
],
"source": [
"from neofox.model.neoantigen import Neoantigen, Mutation\n",
"\n",
"try:\n",
" ModelValidator.validate_neoantigen(neoantigen=Neoantigen())\n",
"except NeofoxDataValidationException as e:\n",
Expand All @@ -557,13 +509,20 @@
"name": "stderr",
"output_type": "stream",
"text": [
"[E 210928 12:18:02 validation:85] {\n",
"[E 220208 11:59:28 validation:86] {\n",
" \"patientIdentifier\": \"12345\",\n",
" \"gene\": \"VCAN\",\n",
" \"mutation\": {\n",
" \"wildTypeXmer\": \"123456AAAAAAAAAAAAAA\",\n",
" \"mutatedXmer\": \"123456GAAAAAAAAAAAAA\"\n",
" }\n",
" \"position\": [\n",
" 7\n",
" ],\n",
" \"wildTypeXmer\": \"123456GAAAAAAAAAAAAA\",\n",
" \"mutatedXmer\": \"123456AAAAAAAAAAAAAA\"\n",
" },\n",
" \"rnaExpression\": null,\n",
" \"imputedGeneExpression\": null,\n",
" \"dnaVariantAlleleFrequency\": null,\n",
" \"rnaVariantAlleleFrequency\": null\n",
" }\n"
]
},
Expand All @@ -577,12 +536,11 @@
],
"source": [
"try:\n",
" ModelValidator.validate_neoantigen(neoantigen=Neoantigen(\n",
" NeoantigenFactory.build_neoantigen(\n",
" patient_identifier=\"12345\",\n",
" gene=\"VCAN\",\n",
" mutation=Mutation(\n",
" wild_type_xmer=\"123456AAAAAAAAAAAAAA\", # wrong aminoacid representation\n",
" mutated_xmer=\"123456GAAAAAAAAAAAAA\")))\n",
" mutated_xmer=\"123456AAAAAAAAAAAAAA\", # wrong aminoacid representation\n",
" wild_type_xmer=\"123456GAAAAAAAAAAAAA\")\n",
"except NeofoxDataValidationException as e:\n",
" print(\"Error message: {}\".format(e))"
]
Expand All @@ -605,7 +563,17 @@
"text": [
"{\n",
" \"position\": [\n",
" 6\n",
" 1,\n",
" 2,\n",
" 3,\n",
" 4,\n",
" 5,\n",
" 6,\n",
" 7,\n",
" 8,\n",
" 9,\n",
" 10,\n",
" 11\n",
" ],\n",
" \"wildTypeXmer\": \"AAAAAAAAAAAAA\",\n",
" \"mutatedXmer\": \"AAAAAGAAAAA\"\n",
Expand All @@ -614,11 +582,10 @@
}
],
"source": [
"valid_neoantigen = ModelValidator.validate_neoantigen(neoantigen=Neoantigen(\n",
"valid_neoantigen = NeoantigenFactory.build_neoantigen(\n",
" patient_identifier=\"12345\",\n",
" mutation=Mutation(\n",
" wild_type_xmer=\"AAAAAAAAAAAAA\",\n",
" mutated_xmer=\"aaaaaGaaaaa\")))\n",
" wild_type_xmer=\"AAAAAAAAAAAAA\",\n",
" mutated_xmer=\"aaaaaGaaaaa\")\n",
"\n",
"print(valid_neoantigen.mutation.to_json(indent=2))"
]
Expand Down
2 changes: 1 addition & 1 deletion neofox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.#
VERSION = "0.6.0"
VERSION = "0.6.1"


REFERENCE_FOLDER_ENV = "NEOFOX_REFERENCE_FOLDER"
Expand Down
Loading

0 comments on commit a83c4be

Please sign in to comment.