From 70958bd46902200ef9976522d6a22a6ff60f19ef Mon Sep 17 00:00:00 2001 From: MelisCakan Date: Wed, 2 Apr 2025 21:41:12 +0300 Subject: [PATCH 1/4] preprocess - normalization methods are added --- src/modules/preprocessing.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/modules/preprocessing.py b/src/modules/preprocessing.py index e69de29..66c233f 100644 --- a/src/modules/preprocessing.py +++ b/src/modules/preprocessing.py @@ -0,0 +1,11 @@ +import scanpy as sc + +def preprocess(adata, target_sum = 1e4, max_value = 10): + data_normalization(adata, target_sum, max_value) + #other preprocessing methods here + +def data_normalization(adata, target_sum, max_value): + sc.pp.normalize_total(adata, target_sum) + sc.pp.log1p(adata) + sc.pp.regress_out(adata, ['total_counts', 'pct_counts_mt']) + sc.pp.scale(adata, max_value) \ No newline at end of file From 49b884ad80f8f1c3c1c5704b48093a376bb4717c Mon Sep 17 00:00:00 2001 From: MelisCakan Date: Wed, 2 Apr 2025 21:54:59 +0300 Subject: [PATCH 2/4] load file method has been added --- src/modules/load_file.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/load_file.py b/src/modules/load_file.py index e69de29..37e9a65 100644 --- a/src/modules/load_file.py +++ b/src/modules/load_file.py @@ -0,0 +1,5 @@ +import scanpy as sc + +def load_file(file_path): + adata = sc.read_10x_mtx(file_path, var_names='gene_symbols', cache=True) + return adata \ No newline at end of file From fd2da5ed6c7e0a6e7d8a645db3d4b5042db981b0 Mon Sep 17 00:00:00 2001 From: AZRA TUNCAY Date: Thu, 3 Apr 2025 17:47:12 +0300 Subject: [PATCH 3/4] Add Load_file&preprocessing_DEMO.ipynb to feature/load_file branch --- Load_file&preprocessing_DEMO.ipynb | 106 +++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 Load_file&preprocessing_DEMO.ipynb diff --git a/Load_file&preprocessing_DEMO.ipynb b/Load_file&preprocessing_DEMO.ipynb new file mode 100644 index 0000000..7e374c5 --- /dev/null +++ b/Load_file&preprocessing_DEMO.ipynb @@ -0,0 +1,106 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 3, + "id": "787e38a9-14a5-41f1-9186-e68008bc80c3", + "metadata": {}, + "outputs": [], + "source": [ + "import scanpy as sc\n", + "\n", + "def load_file_demo(file_path):\n", + " adata = sc.read_h5ad(file_path) # load h5ad file\n", + " adata.write(\"adata_demo.h5ad\") # save a new demo file\n", + " print(\"Data saved as adata_demo.h5ad\")\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "32cc9e28-f9df-4a12-bcab-4a152fc18855", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Data saved as adata_demo.h5ad\n" + ] + } + ], + "source": [ + "#run\n", + "file_path = \"/Users/azratuncay/Desktop/IEEE/untitled folder/Hw3covid_Data_AllCells.h5ad\"\n", + "load_file_demo(file_path)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "aa346737-f100-4684-88b8-d971b013624b", + "metadata": {}, + "outputs": [], + "source": [ + "import scanpy as sc\n", + "\n", + "def preprocess_demo(adata_path):\n", + " adata = sc.read_h5ad(adata_path) # download the saved demo file \n", + " print(\"Data loaded successfully for preprocessing demo.\")\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "8b0be686-d27d-46fa-8142-6ac196f49fcd", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Data loaded successfully for preprocessing demo.\n" + ] + } + ], + "source": [ + "#run\n", + "adata_path = \"adata_demo.h5ad\"\n", + "preprocess_demo(adata_path)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "06a5bd7f-f9d5-42c3-b46a-aeda392a4664", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.12.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From adf7e58ac19dd3ee0a665ed128d5622692a122ed Mon Sep 17 00:00:00 2001 From: AZRA TUNCAY Date: Fri, 4 Apr 2025 15:46:24 +0300 Subject: [PATCH 4/4] Moved file to new location --- .../modules/Load_file&preprocessing_DEMO.ipynb | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Load_file&preprocessing_DEMO.ipynb => src/modules/Load_file&preprocessing_DEMO.ipynb (100%) diff --git a/Load_file&preprocessing_DEMO.ipynb b/src/modules/Load_file&preprocessing_DEMO.ipynb similarity index 100% rename from Load_file&preprocessing_DEMO.ipynb rename to src/modules/Load_file&preprocessing_DEMO.ipynb