{"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":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-04-22T23:43:17.901144Z","iopub.execute_input":"2023-04-22T23:43:17.901706Z","iopub.status.idle":"2023-04-22T23:43:17.92135Z","shell.execute_reply.started":"2023-04-22T23:43:17.90165Z","shell.execute_reply":"2023-04-22T23:43:17.920151Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install pandas\nimport pandas as pd\nimport numpy as np\n!pip install scanpy\nimport scanpy as sc\nimport os\nimport seaborn as sns\nimport sys\nimport gc\nimport warnings\n\n","metadata":{"execution":{"iopub.status.busy":"2023-04-22T23:43:17.923921Z","iopub.execute_input":"2023-04-22T23:43:17.924798Z","iopub.status.idle":"2023-04-22T23:43:40.702572Z","shell.execute_reply.started":"2023-04-22T23:43:17.92475Z","shell.execute_reply":"2023-04-22T23:43:40.701126Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"MAIN = '../input/cafa-5-protein-function-prediction'\nTrain_terms = os.path.join(MAIN + '/Train/train_terms.tsv')\nTrain_tax = os.path.join(MAIN + '/Train/train_taxonomy.tsv')\n","metadata":{"execution":{"iopub.status.busy":"2023-04-22T23:43:40.704938Z","iopub.execute_input":"2023-04-22T23:43:40.705991Z","iopub.status.idle":"2023-04-22T23:43:40.712071Z","shell.execute_reply.started":"2023-04-22T23:43:40.705948Z","shell.execute_reply":"2023-04-22T23:43:40.710754Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Train_data_terms = pd.read_csv(Train_terms,sep='\\t')\nTrain_data_tax = pd.read_csv(Train_tax, sep='\\t')","metadata":{"execution":{"iopub.status.busy":"2023-04-22T23:43:40.714608Z","iopub.execute_input":"2023-04-22T23:43:40.715163Z","iopub.status.idle":"2023-04-22T23:43:42.868374Z","shell.execute_reply.started":"2023-04-22T23:43:40.71513Z","shell.execute_reply":"2023-04-22T23:43:42.86739Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display(Train_data_terms)\n","metadata":{"execution":{"iopub.status.busy":"2023-04-22T23:43:42.869687Z","iopub.execute_input":"2023-04-22T23:43:42.87002Z","iopub.status.idle":"2023-04-22T23:43:42.884997Z","shell.execute_reply.started":"2023-04-22T23:43:42.86999Z","shell.execute_reply":"2023-04-22T23:43:42.883891Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display(Train_data_tax)","metadata":{"execution":{"iopub.status.busy":"2023-04-22T23:43:42.886656Z","iopub.execute_input":"2023-04-22T23:43:42.886974Z","iopub.status.idle":"2023-04-22T23:43:42.901084Z","shell.execute_reply.started":"2023-04-22T23:43:42.886944Z","shell.execute_reply":"2023-04-22T23:43:42.899964Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.merge(Train_data_terms, Train_data_tax, on=[\"EntryID\"])","metadata":{"execution":{"iopub.status.busy":"2023-04-22T23:43:42.902187Z","iopub.execute_input":"2023-04-22T23:43:42.902474Z","iopub.status.idle":"2023-04-22T23:43:43.862998Z","shell.execute_reply.started":"2023-04-22T23:43:42.902445Z","shell.execute_reply":"2023-04-22T23:43:43.86192Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display(df)","metadata":{"execution":{"iopub.status.busy":"2023-04-22T23:43:43.864294Z","iopub.execute_input":"2023-04-22T23:43:43.865216Z","iopub.status.idle":"2023-04-22T23:43:43.87948Z","shell.execute_reply.started":"2023-04-22T23:43:43.865179Z","shell.execute_reply":"2023-04-22T23:43:43.878631Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"df.boxplot(by ='aspect', column =['taxonomyID'], grid = False)\n","metadata":{"execution":{"iopub.status.busy":"2023-04-22T23:43:43.880658Z","iopub.execute_input":"2023-04-22T23:43:43.881003Z","iopub.status.idle":"2023-04-22T23:43:53.158612Z","shell.execute_reply.started":"2023-04-22T23:43:43.88097Z","shell.execute_reply":"2023-04-22T23:43:53.157308Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"aspect\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-04-22T23:43:53.161787Z","iopub.execute_input":"2023-04-22T23:43:53.162129Z","iopub.status.idle":"2023-04-22T23:43:53.502161Z","shell.execute_reply.started":"2023-04-22T23:43:53.162098Z","shell.execute_reply":"2023-04-22T23:43:53.500828Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"df = pd.DataFrame({'sub-ontology':['BPO', 'CCO', 'MFO'], 'val':[3497732, 1196017, 670114]})\nax = df.plot.bar(x='sub-ontology', y='val', rot=0)","metadata":{"execution":{"iopub.status.busy":"2023-04-22T23:43:53.503689Z","iopub.execute_input":"2023-04-22T23:43:53.504364Z","iopub.status.idle":"2023-04-22T23:43:53.773353Z","shell.execute_reply.started":"2023-04-22T23:43:53.504325Z","shell.execute_reply":"2023-04-22T23:43:53.772265Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Investigate sequences using BioPython","metadata":{}},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"\nfrom Bio import SeqIO\ncount = 0\nsequences = [] # Here we are setting up an array to save our sequences for the next step\n\nfor seq_record in SeqIO.parse(\"../input/cafa-5-protein-function-prediction/Train/train_sequences.fasta\", \"fasta\"):\n    if (count < 6):\n        sequences.append(seq_record)\n        print(\"Id: \" + seq_record.id + \" \\t \" + \"Length: \" + str(\"{:,d}\".format(len(seq_record))) )\n        print(repr(seq_record.seq) + \"\\n\")\n        count = count + 1\n","metadata":{"execution":{"iopub.status.busy":"2023-04-22T23:43:53.774671Z","iopub.execute_input":"2023-04-22T23:43:53.775043Z","iopub.status.idle":"2023-04-22T23:43:55.543285Z","shell.execute_reply.started":"2023-04-22T23:43:53.775011Z","shell.execute_reply":"2023-04-22T23:43:55.542066Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Lets set these sequences up for easy access later\n\nP20536 = sequences[0].seq\nO73864 = sequences[1].seq\nO95231 = sequences[2].seq\nA0A0B4J1F4 = sequences[3].seq\nP54366 = sequences[4].seq\nP33681 = sequences[5].seq\n","metadata":{"execution":{"iopub.status.busy":"2023-04-22T23:43:55.544939Z","iopub.execute_input":"2023-04-22T23:43:55.545306Z","iopub.status.idle":"2023-04-22T23:43:55.551221Z","shell.execute_reply.started":"2023-04-22T23:43:55.545272Z","shell.execute_reply":"2023-04-22T23:43:55.550016Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(P20536)","metadata":{"execution":{"iopub.status.busy":"2023-04-22T23:43:55.552705Z","iopub.execute_input":"2023-04-22T23:43:55.553151Z","iopub.status.idle":"2023-04-22T23:43:55.563944Z","shell.execute_reply.started":"2023-04-22T23:43:55.553105Z","shell.execute_reply":"2023-04-22T23:43:55.562563Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"from Bio.SeqUtils.ProtParam import ProteinAnalysis\nmy_seq = (P20536)\nanalysed_seq = ProteinAnalysis(my_seq)\nanalysed_seq.molecular_weight()\n17103.1617\nanalysed_seq.gravy()\n-0.597368421052632\nanalysed_seq.count_amino_acids()\n{'A': 6, 'C': 3, 'E': 12, 'D': 5, 'G': 14, 'F': 6, 'I': 5, 'H': 5, 'K': 12, 'M':\n 2, 'L': 18, 'N': 7, 'Q': 6, 'P': 8, 'S': 10, 'R': 6, 'T': 13, 'W': 1, 'V': 5,\n 'Y': 8}\n \n","metadata":{"execution":{"iopub.status.busy":"2023-04-22T23:43:55.565654Z","iopub.execute_input":"2023-04-22T23:43:55.566037Z","iopub.status.idle":"2023-04-22T23:43:55.578023Z","shell.execute_reply.started":"2023-04-22T23:43:55.566003Z","shell.execute_reply":"2023-04-22T23:43:55.576622Z"},"trusted":true},"execution_count":null,"outputs":[]}]}