<jupyter_start><jupyter_text>Data Commons Pilot - TOPMed MESA Data Analysis demo This demo shows some data visualization and data analysis procedures by interacting with the Gen3 Data Commons provided for the Data Commons Pilot (DCP) project. More specifically, the demo is focused on the TOPMed project entitled:"Multi-Ethnic Study of Atherosclerosis (MESA)"(https://www.ncbi.nlm.nih.gov/projects/gap/cgi-bin/study.cgi?study_id=phs000209.v13.p3)  DATA EXPLORATION: High-level Python library based on GraphQL queries Install required Python packages:<jupyter_code>!pip install matplotlib
!pip install lifelines<jupyter_output><empty_output><jupyter_text>Import library with pipeline functions and GraphQL queries as well as our credentials:<jupyter_code>%matplotlib inline
import dcp_analysis_functions as dcp
dcp.add_keys('credentials.json')<jupyter_output><empty_output><jupyter_text>Get summary metrics for each data type in the data-model for one project:<jupyter_code>dcp.query_summary_counts('topmed-MESA')<jupyter_output><empty_output><jupyter_text>Get summary counts per field across all projects or for specific project:<jupyter_code>gender_counts = dcp.query_summary_field('gender', 'demographic')
race_counts = dcp.query_summary_field('race', 'demographic')
age_counts = dcp.query_summary_field('age_range', 'demographic')
ht_counts = dcp.query_summary_field('hypertension_stage', 'diagnosis', 'topmed-MESA')<jupyter_output><empty_output><jupyter_text>Get field distribution for one variable: Visualize distribution of cholesterol levels in subjects:<jupyter_code>distribution = dcp.field_distribution('chol1','lab_result', 'topmed-MESA')<jupyter_output><empty_output><jupyter_text>DATA ANALISIS: TOPMed MESA Data Project This data analysis shows some preliminary results over TOPMed MESA project data reproduced using the following published studies: [1] <NAME>, <NAME>, <NAME>, <NAME> (2016). Legacy of MESA. Global Heart, 11(3), 269-274.https://www.sciencedirect.com/science/article/pii/S2211816016307098 (Table 1, MESA recruiment study)[2] <NAME>., <NAME>., <NAME>., <NAME>., <NAME>., & <NAME>. (2016). The Legacy of MESA – Providing Evidence for Subclinical Cardiovascular Disease in Risk Assessment. Global Heart, 11(3), 275–285.http://doi.org/10.1016/j.gheart.2016.08.003 (Figure 2, Kaplan-Meier cumulative-event curves for coronary events)<jupyter_code>project = 'topmed-MESA'<jupyter_output><empty_output><jupyter_text>Recruitment summary based on demographic variables (gender, race, age range): Quoting from [1]: "*MESA sampling was to obtain balanced recruitment across strata defined by sex, ethnicity, and age group rather than to represent the demographic distribution*". This distribution based on gender, age group and race can be observed in the following line chart:<jupyter_code>dcp.demographic_study(project)<jupyter_output><empty_output><jupyter_text>Kaplan-Meier curves for coronary events: Coronary Artery Calcium (CAC) scores are clearly associated to a graded increase risk of both hard and all CHD events [2]. This is shown in the following Kaplan-Meier survival and hazard curves based on CAC ranges:<jupyter_code>survival = dcp.calcium_score_survival(project, "Coronary Artery Calcium (CAC) Prob Cumulative Curve", 'hazard')
hazards  = dcp.calcium_score_survival(project, "Coronary Artery Calcium (CAC) Survival Curve", 'survival')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09408997353719495, 'fraction_numerical': 0.02175830638047633, 'mean_word_length': 7.483790523690773, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '256512', 'license': 'Apache-2.0', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1014, 'n_words': 318, 'path': 'DCP_MESA_Demo.ipynb', 'repo_name': 'uc-cdis/dcp-demo', 'size': '3463'}