Skip to content

Commit

Permalink
[IBCDPE-954] Adds proteomics_srm GX Suite (#145)
Browse files Browse the repository at this point in the history
* adds srm nb

* adds proteomics_srm GX suite

* pre-commit fix

* updates uniqid and uniprotid regexes

* updates regex

* remove ?:

* pre-commit

* updates uniprot regex

* pre-commit
  • Loading branch information
BWMac authored Sep 24, 2024
1 parent e90c363 commit 86b5f29
Show file tree
Hide file tree
Showing 4 changed files with 503 additions and 0 deletions.
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ datasets:
genename: hgnc_symbol
ensg: ensembl_gene_id
destination: *dest
gx_enabled: true

- target_exp_validation_harmonized:
files:
Expand Down
276 changes: 276 additions & 0 deletions gx_suite_definitions/proteomics_srm.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import synapseclient\n",
"\n",
"import great_expectations as gx\n",
"\n",
"context = gx.get_context(project_root_dir='../src/agoradatatools/great_expectations')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Create Expectation Suite for Proteomics SRM Data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Get Example Data File"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"syn = synapseclient.Synapse()\n",
"syn.login()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"proteomics_srm_data_file = syn.get(\"syn52579910\").path"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create Validator Object on Data File"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"validator = context.sources.pandas_default.read_json(\n",
" proteomics_srm_data_file\n",
")\n",
"validator.expectation_suite_name = \"proteomics_srm\"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Add Expectations to Validator Object For Each Column"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# uniqid\n",
"validator.expect_column_values_to_be_of_type(\"uniqid\", \"str\")\n",
"validator.expect_column_values_to_not_be_null(\"uniqid\")\n",
"validator.expect_column_values_to_match_regex(\"uniqid\", \"^[A-Za-z0-9_.-]+\\\\|[OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# hgnc_symbol\n",
"validator.expect_column_values_to_be_of_type(\"hgnc_symbol\", \"str\")\n",
"validator.expect_column_value_lengths_to_be_between(\"hgnc_symbol\", 1, 15)\n",
"validator.expect_column_values_to_match_regex(\"hgnc_symbol\", \"^[A-Za-z0-9_.-]+$\")\n",
"validator.expect_column_values_to_not_be_null(\"hgnc_symbol\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# uniprotid\n",
"validator.expect_column_values_to_be_of_type(\"uniprotid\", \"str\")\n",
"validator.expect_column_value_lengths_to_be_between(\"uniprotid\", 1, 15)\n",
"validator.expect_column_values_to_match_regex(\"uniprotid\", \"[OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2}\")\n",
"validator.expect_column_values_to_not_be_null(\"uniprotid\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# ensembl_gene_id\n",
"validator.expect_column_values_to_be_of_type(\"ensembl_gene_id\", \"str\")\n",
"validator.expect_column_values_to_not_be_null(\"ensembl_gene_id\")\n",
"validator.expect_column_values_to_match_regex(\"ensembl_gene_id\", \"^ENSG\\d{11}$\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# tissue\n",
"validator.expect_column_values_to_be_of_type(\"tissue\", \"str\")\n",
"validator.expect_column_values_to_not_be_null(\"tissue\")\n",
"validator.expect_column_values_to_be_in_set(\"tissue\", [\"DLPFC\"])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# log2_fc\n",
"validator.expect_column_values_to_be_of_type(\"log2_fc\", \"float\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# ci_upr\n",
"validator.expect_column_values_to_be_of_type(\"ci_upr\", \"float\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# ci_lwr\n",
"validator.expect_column_values_to_be_of_type(\"ci_lwr\", \"float\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# pval\n",
"validator.expect_column_values_to_be_of_type(\"pval\", \"float\")\n",
"validator.expect_column_values_to_be_between(\"pval\", 0, 1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# cor_pval\n",
"validator.expect_column_values_to_be_of_type(\"cor_pval\", \"float\")\n",
"validator.expect_column_values_to_be_between(\"cor_pval\", 0, 1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# multi-field\n",
"validator.expect_compound_columns_to_be_unique([\"hgnc_symbol\", \"uniprotid\", \"tissue\"])\n",
"validator.expect_compound_columns_to_be_unique([\"ensembl_gene_id\", \"uniprotid\", \"tissue\"])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Save Expectation Suite"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"validator.save_expectation_suite(discard_failed_expectations=False)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create Checkpoint and View Results"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"checkpoint = context.add_or_update_checkpoint(\n",
" name=\"agora-test-checkpoint\",\n",
" validator=validator,\n",
")\n",
"checkpoint_result = checkpoint.run()\n",
"context.view_validation_result(checkpoint_result)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Build Data Docs - Click on Expectation Suite to View All Expectations"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"context.build_data_docs()\n",
"context.open_data_docs()\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit 86b5f29

Please sign in to comment.