-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IBCDPE-795] Adds
rna_distribution_data
GX Suite (#144)
* adds rna_dd gx suite * pre-commit
- Loading branch information
Showing
4 changed files
with
423 additions
and
0 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,243 @@ | ||
{ | ||
"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')\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Create Expectation Suite for RNA Distribution 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": [ | ||
"rna_distribution_data_file = syn.get(\"syn28094691\").path\n" | ||
] | ||
}, | ||
{ | ||
"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", | ||
" rna_distribution_data_file\n", | ||
")\n", | ||
"validator.expectation_suite_name = \"rna_distribution_data\"\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Add Expectations to Validator Object For Each Column" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# model\n", | ||
"validator.expect_column_values_to_be_of_type(\"model\", \"str\")\n", | ||
"validator.expect_column_values_to_not_be_null(\"model\")\n", | ||
"validator.expect_column_values_to_be_in_set(\"model\", [\"AD Diagnosis (males and females)\", \"AD Diagnosis x AOD (males and females)\",\"AD Diagnosis x Sex (females only)\", \"AD Diagnosis x Sex (males only)\"])" | ||
] | ||
}, | ||
{ | ||
"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\", [\"CBE\", \"DLPFC\", \"FP\", \"IFG\", \"PHG\", \"STG\", \"TCX\", \"ACC\", \"PCC\"])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# min\n", | ||
"validator.expect_column_values_to_be_of_type(\"min\", \"float\")\n", | ||
"validator.expect_column_values_to_not_be_null(\"min\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# max\n", | ||
"validator.expect_column_values_to_be_of_type(\"max\", \"float\")\n", | ||
"validator.expect_column_values_to_not_be_null(\"max\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# median\n", | ||
"validator.expect_column_values_to_be_of_type(\"median\", \"float\")\n", | ||
"validator.expect_column_values_to_not_be_null(\"median\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# first_quartile\n", | ||
"validator.expect_column_values_to_be_of_type(\"first_quartile\", \"float\")\n", | ||
"validator.expect_column_values_to_not_be_null(\"first_quartile\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# third_quartile\n", | ||
"validator.expect_column_values_to_be_of_type(\"third_quartile\", \"float\")\n", | ||
"validator.expect_column_values_to_not_be_null(\"third_quartile\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# multi-field\n", | ||
"validator.expect_column_pair_values_a_to_be_greater_than_b(\"max\", \"third_quartile\")\n", | ||
"validator.expect_column_pair_values_a_to_be_greater_than_b(\"third_quartile\", \"median\")\n", | ||
"validator.expect_column_pair_values_a_to_be_greater_than_b(\"median\", \"first_quartile\")\n", | ||
"validator.expect_column_pair_values_a_to_be_greater_than_b(\"first_quartile\", \"min\")" | ||
] | ||
}, | ||
{ | ||
"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 | ||
} |
Oops, something went wrong.