Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
04ef841
preprocess filtering, qc_metrics, highly_variable_genes kısmı güncell…
Oykupnrbs Apr 2, 2025
6168137
Add files via upload
unsalangulce Apr 4, 2025
52bc8a5
Delete src/modules/visualizecode.py
unsalangulce Apr 4, 2025
b79bb4b
Add files via upload
Ekin-hub-code Apr 4, 2025
c24786e
preproccesing2-demo.py
Ekin-hub-code Apr 4, 2025
53d06a4
Add files via upload
Ekin-hub-code Apr 4, 2025
2608e60
preproccesing2-demo.py
Ekin-hub-code Apr 4, 2025
aec0bb9
preprocessing
Ekin-hub-code Apr 4, 2025
8b19703
preprocessing demo
Oykupnrbs Apr 5, 2025
7b5dbd9
Preprocessing demo
Oykupnrbs Apr 5, 2025
d3ddfc8
This is the demo code for visualization codes. It gives 3 plots.
serayyucetin Apr 5, 2025
881773d
Delete demovisualization.py
serayyucetin Apr 5, 2025
0cac9bb
Added visualization.py and demovisualization.py to src/modules folder
serayyucetin Apr 5, 2025
e5682a6
Mergr branch 'develop' of https://github.com/IEEE-Ege/SingleCellWebAp…
serayyucetin Apr 5, 2025
6971d77
Add modular preprocessing functions: filtering, QC metrics, and HVG s…
Oykupnrbs Apr 6, 2025
4cafacc
necessary changes were made for pca analysis code
eceygtt Apr 6, 2025
888715d
Add demo_pcanlysis.py script
birsenyrtds Apr 7, 2025
a4bb0ef
Rename demo_pcanlysis.py to modules/demo_pcanlysis.py
birsenyrtds Apr 7, 2025
6ac8e58
Rename demo_pcanlysis.py to demo_pcanlysis.py
birsenyrtds Apr 7, 2025
d1ffbea
Move demo_pcanlysis.py into pcaprocess directory
birsenyrtds Apr 7, 2025
caa4524
delete demviz
TRextabat Apr 7, 2025
82c884e
delet
TRextabat Apr 7, 2025
8ff1efb
Add last PCA process files
birsenyrtds Apr 8, 2025
887a0e8
Add preprocessing module
Oykupnrbs Apr 8, 2025
ca37da3
Resolved FileNotFoundError caused by missing dataset file
Oykupnrbs Apr 8, 2025
461d960
Merge pull request #8 from IEEE-Ege/feature/filtering-qc_metrics-high…
TRextabat Apr 9, 2025
a5f5c2f
Add files via upload
Ekin-hub-code Apr 13, 2025
ebbec9a
Add files via upload
Ekin-hub-code Apr 25, 2025
b3dd1e8
Add files via upload
Ekin-hub-code Apr 25, 2025
e784fd5
Add get_scors_and_pvals_demo.py file
eceygtt Apr 26, 2025
6f66907
Added rank_genes_group_demo.py file
eceygtt Apr 26, 2025
e4ead99
one file created two other empty files are now with content
eceygtt Apr 27, 2025
15c1358
Added functions for data processing, embedding, clustering, and savin…
Oykupnrbs Apr 27, 2025
ef6b1fc
Integrated functions for PBMC3K dataset analysis.
Oykupnrbs Apr 27, 2025
4b46d0b
Added functions for data processing, embedding, clustering, and savin…
Oykupnrbs Apr 27, 2025
35fbec1
Update and rename rank_genes_group.py to rankgenesgroup.py
Ekin-hub-code Apr 30, 2025
73ac4a5
four demo codes added.
eceygtt Apr 30, 2025
bc93fbd
Update rank_genes_violin.py
Ekin-hub-code Apr 30, 2025
0edd0d2
demo files are moved.
eceygtt Apr 30, 2025
345dcd3
4 updated files
eceygtt Apr 30, 2025
73cba48
Update get_scors_and_pvals.py
Ekin-hub-code Apr 30, 2025
705facf
Update rankgenesgroup.py
Ekin-hub-code Apr 30, 2025
1692d0a
Update rank_genes_group_demo.py
Ekin-hub-code Apr 30, 2025
47d3653
Update README.md
eceygtt May 23, 2025
f8a78c6
Update README.md
eceygtt May 23, 2025
251a92b
Update get_marker_genes_demo.py
Ekin-hub-code May 23, 2025
dd1d19f
Update src folder with content from pcaprocess
birsenyrtds May 23, 2025
ae678bc
Add final postgresql file
happymealinthebuilding Jun 17, 2025
597f4cd
Do necessary updates.
happymealinthebuilding Jun 18, 2025
6b55a07
3 functions are added
eceygtt Aug 2, 2025
ba4f2fa
Move and rename function files to src/modules/functions
eceygtt Aug 6, 2025
ffd4ae0
Rename function1, function2, function3 to descriptive filenames
eceygtt Aug 6, 2025
e6b2d0f
added oturum.txt to gitignore
eceygtt Aug 11, 2025
e5cc6ce
Updated fetching and reading functions with new code blocks
eceygtt Aug 12, 2025
cce6d3c
Updated file by adding a new code block
eceygtt Aug 12, 2025
54a31d5
Add OOP1 module files
birsenyrtds Nov 26, 2025
f6cabad
Fix: remove unwanted submodule, add as normal folder
birsenyrtds Nov 26, 2025
14f511a
Merge pull request #48 from IEEE-Ege/feature/oop1-module
serayyucetin Nov 29, 2025
facfa3c
Revert "Feature/oop modules"
serayyucetin Nov 29, 2025
3bcd13f
Merge pull request #49 from IEEE-Ege/revert-48-feature/oop1-module
serayyucetin Nov 29, 2025
ac67849
Merge pull request #44 from IEEE-Ege/issue_43
TRextabat Dec 8, 2025
da04c2a
Merge pull request #35 from IEEE-Ege/postgresql_final
TRextabat Dec 8, 2025
fde7d7e
Merge pull request #31 from IEEE-Ege/gene_filtering
TRextabat Dec 8, 2025
8805f24
Merge pull request #26 from IEEE-Ege/feature/computing_embedding_clus…
TRextabat Dec 8, 2025
cf25d95
Merge pull request #11 from IEEE-Ege/last_pca_process
TRextabat Dec 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,4 @@ cython_debug/

# PyPI configuration file
.pypirc
oturum.txt
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
# SingleCellWebApp
Bioinformatic technique team project
Here are the outputs we got from running our codes.

![PHOTO-2025-05-23-22-18-02](https://github.com/user-attachments/assets/052b7fae-295a-41b5-8f4c-9efb99e6365b)
Above is the output from rank genes function

![PHOTO-2025-05-23-22-32-16](https://github.com/user-attachments/assets/f7fe0897-e9b4-4412-be4a-c63479aa43b9)
This one is the violin plot output.

![PHOTO-2025-05-23-22-52-52](https://github.com/user-attachments/assets/62fcd331-dd72-4e4a-930a-e8698a6f8d01)
This one is from marker genes code.

![PHOTO-2025-05-23-21-32-06](https://github.com/user-attachments/assets/30361fa4-fdc4-43cf-83a1-15c57454cbc1)
Lastly, this is the output we got from the get scores p-values function.
1 change: 1 addition & 0 deletions SingleCellWebApp
Submodule SingleCellWebApp added at a9ae78
539 changes: 539 additions & 0 deletions app_final_demo.py

Large diffs are not rendered by default.

Binary file added data/pbmc3k_raw.h5ad
Binary file not shown.
93 changes: 93 additions & 0 deletions pcaprocess/demo_pcanlysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import scanpy as sc
import numpy as np
import matplotlib.pyplot as plt

# Define the PCA functions in the same file or import them correctly
# from pca_functions import run_pca, plot_pca, plot_variance, save_results, get_adata

# Step 1: Create random data
n_cells, n_genes = 100, 2000
np.random.seed(42)

# Generate random gene expression data
data = np.random.rand(n_cells, n_genes)

# Create an AnnData object
adata = sc.AnnData(X=data)

# Adding cell types (obs)
adata.obs['cell_type'] = ['type1' if i < 50 else 'type2' for i in range(n_cells)]
adata.var['gene_id'] = [f"gene{i}" for i in range(n_genes)]

# Step 2: Apply PCA
def run_pca(adata, n_comps=50, svd_solver='arpack'):
"""Runs PCA and stores the computed components."""
try:
if 'X_pca' in adata.obsm:
print("PCA already computed. Overwriting previous results...")

print(f"Running PCA with {n_comps} components using {svd_solver} solver...")
sc.pp.normalize_total(adata, target_sum=1e4) # Normalization
sc.pp.log1p(adata) # Log transformation
sc.pp.scale(adata) # Scaling
sc.tl.pca(adata, n_comps=n_comps, svd_solver=svd_solver)

print("PCA completed.")
except Exception as e:
print(f"Error during PCA: {e}")
raise

run_pca(adata, n_comps=10, svd_solver='arpack')

# Step 3: Plot PCA graph
def plot_pca(adata, color=None):
"""Plots PCA results, colored by a specified attribute (if provided)."""
try:
print(f"Plotting PCA, color by: {color or 'default'}")
sc.pl.pca(adata, color=color, show=False)
plt.title(f"PCA - Colored by {color if color else 'default'}")
plt.show()
except KeyError:
print(f"Warning: '{color}' not found. Using default coloring.")
sc.pl.pca(adata, show=False)
plt.title("PCA - Default Coloring")
plt.show()
except Exception as e:
print(f"Error in PCA plot: {e}")
raise

plot_pca(adata, color='cell_type')

# Step 4: Plot explained variance
def plot_variance(adata, log=True):
"""Plots the variance explained by PCA components."""
try:
print("Plotting explained variance...")
sc.pl.pca_variance_ratio(adata, log=log, show=False)
plt.title("PCA: Explained Variance")
plt.show()
except Exception as e:
print(f"Error in variance plot: {e}")
raise

plot_variance(adata)

# Step 5: Save PCA results
def save_results(adata, results_file="pca_results.h5ad"):
"""Saves the PCA results to an H5AD file."""
try:
print(f"Saving results to {results_file}...")
adata.write(results_file)
print("Save successful.")
except Exception as e:
print(f"Error saving results: {e}")
raise

save_results(adata, "pca_results.h5ad")

# Step 6: Retrieve processed AnnData object
def get_adata(adata):
"""Returns the processed AnnData object."""
return adata

processed_adata = get_adata(adata)
17 changes: 17 additions & 0 deletions rank_genes_violin_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from rank_genes_violin import get_rank_genes_groups_violin
import scanpy as sc

#sample dataset
adata = sc.datasets.pbmc3k()

# calculating neighborhoods
sc.pp.neighbors(adata)

sc.tl.leiden(adata, resolution=1.0)

# Differential expression analysis (with t-test)
sc.tl.rank_genes_groups(adata, groupby='leiden', method='t-test')


# calling the function and visualizing
get_rank_genes_groups_violin(adata, groups='0', n_genes=8)
93 changes: 93 additions & 0 deletions src/demo_pcanlysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import scanpy as sc
import numpy as np
import matplotlib.pyplot as plt

# Define the PCA functions in the same file or import them correctly
# from pca_functions import run_pca, plot_pca, plot_variance, save_results, get_adata

# Step 1: Create random data
n_cells, n_genes = 100, 2000
np.random.seed(42)

# Generate random gene expression data
data = np.random.rand(n_cells, n_genes)

# Create an AnnData object
adata = sc.AnnData(X=data)

# Adding cell types (obs)
adata.obs['cell_type'] = ['type1' if i < 50 else 'type2' for i in range(n_cells)]
adata.var['gene_id'] = [f"gene{i}" for i in range(n_genes)]

# Step 2: Apply PCA
def run_pca(adata, n_comps=50, svd_solver='arpack'):
"""Runs PCA and stores the computed components."""
try:
if 'X_pca' in adata.obsm:
print("PCA already computed. Overwriting previous results...")

print(f"Running PCA with {n_comps} components using {svd_solver} solver...")
sc.pp.normalize_total(adata, target_sum=1e4) # Normalization
sc.pp.log1p(adata) # Log transformation
sc.pp.scale(adata) # Scaling
sc.tl.pca(adata, n_comps=n_comps, svd_solver=svd_solver)

print("PCA completed.")
except Exception as e:
print(f"Error during PCA: {e}")
raise

run_pca(adata, n_comps=10, svd_solver='arpack')

# Step 3: Plot PCA graph
def plot_pca(adata, color=None):
"""Plots PCA results, colored by a specified attribute (if provided)."""
try:
print(f"Plotting PCA, color by: {color or 'default'}")
sc.pl.pca(adata, color=color, show=False)
plt.title(f"PCA - Colored by {color if color else 'default'}")
plt.show()
except KeyError:
print(f"Warning: '{color}' not found. Using default coloring.")
sc.pl.pca(adata, show=False)
plt.title("PCA - Default Coloring")
plt.show()
except Exception as e:
print(f"Error in PCA plot: {e}")
raise

plot_pca(adata, color='cell_type')

# Step 4: Plot explained variance
def plot_variance(adata, log=True):
"""Plots the variance explained by PCA components."""
try:
print("Plotting explained variance...")
sc.pl.pca_variance_ratio(adata, log=log, show=False)
plt.title("PCA: Explained Variance")
plt.show()
except Exception as e:
print(f"Error in variance plot: {e}")
raise

plot_variance(adata)

# Step 5: Save PCA results
def save_results(adata, results_file="pca_results.h5ad"):
"""Saves the PCA results to an H5AD file."""
try:
print(f"Saving results to {results_file}...")
adata.write(results_file)
print("Save successful.")
except Exception as e:
print(f"Error saving results: {e}")
raise

save_results(adata, "pca_results.h5ad")

# Step 6: Retrieve processed AnnData object
def get_adata(adata):
"""Returns the processed AnnData object."""
return adata

processed_adata = get_adata(adata)
64 changes: 64 additions & 0 deletions src/modules/Neighborhood.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import shiny #Only needed if you are planning to use it later
import scanpy as sc
import umap

adata = sc.read("C:/Users/pc/.ipython/HW3/Hw3covid_Data_AllCells.h5ad")

#computing
def compute(adata, n_neighbors=10, n_pcs=40):
"""_summary_

Args:
Hw3covid_Data_AllCells (_type_): _description_
n_neighbors (int, optional): _description_. Defaults to 10.
n_pcs (int, optional): _description_. Defaults to 40.
"""
try:
sc.pp.neighbors(adata, n_neighbors=n_neighbors, n_pcs=n_pcs)
print("Neighbors computed successfully.")
except Exception as e:
print(f"Error in computing neighbors: {e}")

#embedding
def embed(adata, color=['CST3', 'NKG7', 'PPBP']):
"""_summary_

Args:
adata (_type_): _description_
color (list, optional): _description_. Defaults to ['CST3', 'NKG7', 'PPBP'].
"""
try:
sc.pl.umap(adata, color=color)
sc.pl.umap(adata, color=color) # Note: This plots twice; check if you really want this
print("Embedding and plotting successful.")
except Exception as e:
print(f"Error in embedding: {e}")

#clustering
def cluster(adata, color=['leiden', 'CST3', 'NKG7']):
"""_summary_

Args:
adata (_type_): _description_
color (list, optional): _description_. Defaults to ['leiden', 'CST3', 'NKG7'].
"""
try:
sc.tl.leiden(adata)
sc.pl.umap(adata, color=color)
print("Clustering and plotting successful.")
except Exception as e:
print(f"Error in clustering: {e}")

#saving
def save(results_file, adata):
"""_summary_

Args:
results_file (_type_): _description_
adata (_type_): _description_
"""
try:
adata.write(results_file)
print(f"Data saved successfully to {results_file}.")
except Exception as e:
print(f"Error in saving data: {e}")
30 changes: 30 additions & 0 deletions src/modules/Neighborhood_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import scanpy as sc
import Neighborhood as nb # Your functions are here!
import umap

#Load the dataset
print("Loading dataset...")
adata = sc.datasets.pbmc3k()
print(f"Dataset loaded! Number of cells: {adata.n_obs}, Number of genes: {adata.n_vars}\n")

#Compute the neighbor graph
print("Computing the neighborhood graph...")
nb.compute(adata, n_neighbors=10, n_pcs=40)

#Compute UMAP
print("Computing UMAP embedding...")
sc.tl.umap(adata)

#Visualize the embedding
print("Plotting UMAP...")
genes_of_interest = ['CD3D', 'MS4A1', 'GNLY']
nb.embed(adata, color=genes_of_interest)

#Perform clustering
print("Performing Leiden clustering...")
nb.cluster(adata, color=['leiden'] + genes_of_interest)

#Save the results
results_file = "pbmc3k_final_results.h5ad"
print(f"Saving results to {results_file}...")
nb.save(results_file, adata)
1 change: 1 addition & 0 deletions src/modules/SingleCellWebApp
Submodule SingleCellWebApp added at 655ed2
Binary file added src/modules/data/pbmc3k_raw.h5ad
Binary file not shown.
Loading