{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Imports","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2023-09-15T02:17:09.483732Z","iopub.execute_input":"2023-09-15T02:17:09.484095Z","iopub.status.idle":"2023-09-15T02:17:10.717766Z","shell.execute_reply.started":"2023-09-15T02:17:09.484067Z","shell.execute_reply":"2023-09-15T02:17:10.716686Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Set up","metadata":{"_kg_hide-output":true}},{"cell_type":"code","source":"train_pq = pd.read_parquet('/kaggle/input/stanford-ribonanza-rna-folding-converted/train_data.parquet')","metadata":{"execution":{"iopub.status.busy":"2023-09-15T02:17:12.469792Z","iopub.execute_input":"2023-09-15T02:17:12.470479Z","iopub.status.idle":"2023-09-15T02:17:25.818015Z","shell.execute_reply.started":"2023-09-15T02:17:12.470432Z","shell.execute_reply":"2023-09-15T02:17:25.816774Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_pq = train_pq.dropna(axis=\"columns\", how=\"all\")\ntrain_pq\n\n# this drops 134 columns","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2023-09-15T02:17:25.819885Z","iopub.execute_input":"2023-09-15T02:17:25.820530Z","iopub.status.idle":"2023-09-15T02:17:28.816543Z","shell.execute_reply.started":"2023-09-15T02:17:25.820488Z","shell.execute_reply":"2023-09-15T02:17:28.815447Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data Visualization","metadata":{}},{"cell_type":"code","source":"plot_df = train_pq[\"experiment_type\"].value_counts()\nplot_df.plot(kind='pie', title=\"experiment_type\", autopct='%1.0f%%')","metadata":{"execution":{"iopub.status.busy":"2023-09-15T02:17:31.852875Z","iopub.execute_input":"2023-09-15T02:17:31.853289Z","iopub.status.idle":"2023-09-15T02:17:32.145689Z","shell.execute_reply.started":"2023-09-15T02:17:31.853258Z","shell.execute_reply":"2023-09-15T02:17:32.144502Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Create a DataFrame with counts of SF values for each experiment_type\nplot_df = train_pq.groupby('experiment_type')['SN_filter'].value_counts().unstack(fill_value=0)\n\n# Create a pie chart for each experiment_type\nfor experiment_type, row in plot_df.iterrows():\n    row.plot(kind='pie', autopct='%1.0f%%', labels=['SN=0', 'SN=1'])\n    plt.title(f\"experiment_type {experiment_type}\")\n    plt.ylabel('')  # Remove the y-label to make the chart cleaner\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2023-09-15T02:19:22.175829Z","iopub.execute_input":"2023-09-15T02:19:22.176230Z","iopub.status.idle":"2023-09-15T02:19:22.679901Z","shell.execute_reply.started":"2023-09-15T02:19:22.176199Z","shell.execute_reply":"2023-09-15T02:19:22.678505Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_df = train_pq[\"SN_filter\"].value_counts()\nplot_df.plot(kind='pie', title=\"SN_filter\", autopct='%1.0f%%')","metadata":{"execution":{"iopub.status.busy":"2023-09-15T02:19:44.721808Z","iopub.execute_input":"2023-09-15T02:19:44.722180Z","iopub.status.idle":"2023-09-15T02:19:44.976942Z","shell.execute_reply.started":"2023-09-15T02:19:44.722152Z","shell.execute_reply":"2023-09-15T02:19:44.975758Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_df = train_pq[\"dataset_name\"].value_counts()\nplot_df.plot(kind='barh', figsize=(20,20))","metadata":{"execution":{"iopub.status.busy":"2023-09-12T03:25:45.734481Z","iopub.execute_input":"2023-09-12T03:25:45.734898Z","iopub.status.idle":"2023-09-12T03:25:47.082495Z","shell.execute_reply.started":"2023-09-12T03:25:45.734868Z","shell.execute_reply":"2023-09-12T03:25:47.081537Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"NUM_FEATURE_COLUMNS = [i for i in train_pq.columns if i not in ['sequence_id','sequence','experiment_type', 'dataset_name','SN_filter','dataset_name']]\nNUM_FEATURE_COLUMNS = NUM_FEATURE_COLUMNS[:141] # removing all the 'reactivity_error_*'\n#print(NUM_FEATURE_COLUMNS[0])\n#print(NUM_FEATURE_COLUMNS[1])\n#print(NUM_FEATURE_COLUMNS[2::5])\n#print(len(NUM_FEATURE_COLUMNS))","metadata":{"execution":{"iopub.status.busy":"2023-09-12T03:59:10.425495Z","iopub.execute_input":"2023-09-12T03:59:10.425875Z","iopub.status.idle":"2023-09-12T03:59:10.432983Z","shell.execute_reply.started":"2023-09-12T03:59:10.425846Z","shell.execute_reply":"2023-09-12T03:59:10.431526Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# can't graph all the data, so I am taking a random sample\n# Confidence level: ~ 95% ; Margin of error: ~ 5%\n\ntmpdf = train_pq.sample(n = 400)","metadata":{"execution":{"iopub.status.busy":"2023-09-12T03:34:45.254322Z","iopub.execute_input":"2023-09-12T03:34:45.254713Z","iopub.status.idle":"2023-09-12T03:34:45.325446Z","shell.execute_reply.started":"2023-09-12T03:34:45.254683Z","shell.execute_reply":"2023-09-12T03:34:45.323785Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"figure, axis = plt.subplots(47, 3, figsize=(25, 250))\nplt.subplots_adjust(hspace=0.25, wspace=0.3)\n\nfor i, column_name in enumerate(NUM_FEATURE_COLUMNS):\n    row = i//3\n    col = i % 3\n    bp = sns.barplot(ax=axis[row, col], x=tmpdf['sequence_id'], y=tmpdf[column_name])\n    bp.set(xticklabels=[])\n    #bp.set_xticklabels(bp.get_xticklabels(), rotation=90, size = 7)\n    axis[row, col].set_title(column_name)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-09-12T03:49:01.519472Z","iopub.execute_input":"2023-09-12T03:49:01.519823Z","iopub.status.idle":"2023-09-12T03:54:22.072978Z","shell.execute_reply.started":"2023-09-12T03:49:01.519797Z","shell.execute_reply":"2023-09-12T03:54:22.072146Z"},"trusted":true},"execution_count":null,"outputs":[]}]}