Skip to content

Commit

Permalink
Merge pull request #8 from rsinghlab/refactor
Browse files Browse the repository at this point in the history
further refactoring and batch improvement
  • Loading branch information
nikolaitennant authored Nov 5, 2024
2 parents 3485f77 + b1d5421 commit f4979fc
Show file tree
Hide file tree
Showing 1,456 changed files with 237 additions and 376,632 deletions.
15 changes: 7 additions & 8 deletions Analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@
"source": [
"# Convert the data to a DataFrame for easier manipulation\n",
"adata.obs = adata.obs.reset_index(drop=False)\n",
"df_expression = pd.DataFrame(\n",
" adata.X.todense(), columns=adata.var_names\n",
")\n",
"df_expression = pd.DataFrame(adata.X.todense(), columns=adata.var_names)\n",
"df_expression[\"sex\"] = adata.obs[\"sex\"]\n",
"df_expression[\"age\"] = adata.obs[\"age\"]\n",
"\n",
Expand Down Expand Up @@ -200,7 +198,6 @@
}
],
"source": [
"\n",
"# Plot gene expression over age by sex in a subplot grid\n",
"import math\n",
"\n",
Expand All @@ -212,7 +209,7 @@
"rows = math.ceil(num_genes / cols)\n",
"\n",
"# Create subplots\n",
"fig, axes = plt.subplots(rows, cols, figsize=(5*cols, 4*rows))\n",
"fig, axes = plt.subplots(rows, cols, figsize=(5 * cols, 4 * rows))\n",
"axes = axes.flatten()\n",
"\n",
"# Colors for sexes\n",
Expand Down Expand Up @@ -387,7 +384,7 @@
"rows = math.ceil(num_genes / cols)\n",
"\n",
"# Create subplots\n",
"fig, axes = plt.subplots(rows, cols, figsize=(4*cols, 4*rows))\n",
"fig, axes = plt.subplots(rows, cols, figsize=(4 * cols, 4 * rows))\n",
"axes = axes.flatten() # Flatten in case of single row\n",
"\n",
"for idx, gene in enumerate(valid_matched_genes):\n",
Expand Down Expand Up @@ -421,7 +418,9 @@
"\n",
"# Calculate total variance explained\n",
"total_variance_explained = sum(adata_vis.uns[\"pca\"][\"variance_ratio\"])\n",
"print(f\"Total variance explained by the first 50 PCs: {total_variance_explained*100:.2f}%\")\n",
"print(\n",
" f\"Total variance explained by the first 50 PCs: {total_variance_explained*100:.2f}%\"\n",
")\n",
"\n",
"# Compute the neighborhood graph and UMAP\n",
"sc.pp.neighbors(adata_vis, n_pcs=50)\n",
Expand Down Expand Up @@ -511,7 +510,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.9.17"
},
"orig_nbformat": 4
},
Expand Down
Binary file removed Analysis/batch_corrected/.DS_Store
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Analysis/uncorrected/.DS_Store
Binary file not shown.

This file was deleted.

Binary file not shown.
Loading

0 comments on commit f4979fc

Please sign in to comment.