Skip to content

Commit

Permalink
Merge branch 'master' into integration-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Zethson authored Jan 16, 2025
2 parents cceb006 + 53ae3e4 commit 7931c8c
Show file tree
Hide file tree
Showing 34 changed files with 314 additions and 385 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

jobs:
build-book:
runs-on: ubuntu-22-04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -34,7 +34,7 @@ jobs:
run: make

pdfhtml:
runs-on: ubuntu-22-04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
Expand Down
12 changes: 7 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ fail_fast: false
default_language_version:
python: python3
default_stages:
- commit
- push
- pre-commit
- pre-push
minimum_pre_commit_version: 2.16.0
repos:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.5.1
hooks:
- id: prettier
- repo: https://github.com/psf/black
rev: 22.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
hooks:
- id: black-jupyter
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --unsafe-fixes]
- id: ruff-format
exclude: |
(?x)^(
jupyter-book/conditions/differential_gene_expression.ipynb|
Expand Down
20 changes: 7 additions & 13 deletions jupyter-book/air_repertoire/clonotype.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,11 @@
")\n",
"warnings.simplefilter(action=\"ignore\", category=FutureWarning)\n",
"\n",
"from palmotif import compute_motif, svg_logo\n",
"import numpy as np\n",
"import pandas as pd\n",
"import scanpy as sc\n",
"import scirpy as ir\n",
"import pandas as pd\n",
"import numpy as np\n",
"import seaborn as sb\n",
"from palmotif import compute_motif, svg_logo\n",
"\n",
"warnings.simplefilter(action=\"ignore\", category=pd.errors.DtypeWarning)"
]
Expand Down Expand Up @@ -1698,18 +1697,13 @@
")\n",
"warnings.simplefilter(action=\"ignore\", category=FutureWarning)\n",
"\n",
"from palmotif import compute_motif, svg_logo\n",
"import scanpy as sc\n",
"import dandelion as ddl\n",
"import scirpy as ir\n",
"import pandas as pd\n",
"import numpy as np\n",
"import seaborn as sb\n",
"\n",
"import os\n",
"\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import scanpy as sc\n",
"import scirpy as ir\n",
"from palmotif import compute_motif, svg_logo\n",
"\n",
"warnings.simplefilter(action=\"ignore\", category=pd.errors.DtypeWarning)"
]
Expand Down
3 changes: 1 addition & 2 deletions jupyter-book/air_repertoire/ir_profiling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,10 @@
")\n",
"warnings.simplefilter(action=\"ignore\", category=FutureWarning)\n",
"\n",
"import pandas as pd\n",
"import scanpy as sc\n",
"import scirpy as ir\n",
"\n",
"import pandas as pd\n",
"\n",
"warnings.simplefilter(action=\"ignore\", category=pd.errors.DtypeWarning)"
]
},
Expand Down
15 changes: 6 additions & 9 deletions jupyter-book/air_repertoire/multimodal_integration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@
"warnings.simplefilter(action=\"ignore\", category=FutureWarning)\n",
"warnings.simplefilter(action=\"ignore\", category=UserWarning)\n",
"\n",
"import numpy as np\n",
"import pandas as pd\n",
"import scanpy as sc\n",
"import scirpy as ir\n",
"import pandas as pd\n",
"import numpy as np\n",
"import seaborn as sb\n",
"\n",
"warnings.simplefilter(action=\"ignore\", category=pd.errors.DtypeWarning)"
]
Expand Down Expand Up @@ -424,8 +423,8 @@
}
],
"source": [
"from palmotif import compute_pal_motif, mpl_logo, svg_logo\n",
"from IPython.display import SVG\n",
"from palmotif import compute_pal_motif, svg_logo\n",
"\n",
"df_sequences = adata_tc[~adata_tc.obs[\"IR_VDJ_1_junction_aa\"].isna()].obs[\n",
" [\"IR_VDJ_1_junction_aa\", \"elevated_IFNG\"]\n",
Expand Down Expand Up @@ -1017,8 +1016,8 @@
" \"tcr\": f\"{path_tmp}/TESSA_tcrs.csv\",\n",
" \"exp\": f\"{path_tmp}/TESSA_gex.csv\",\n",
" # TESSA models\n",
" \"model\": f\"TESSA/BriseisEncoder/TrainedEncoder.h5\",\n",
" \"embeding_vectors\": f\"TESSA/BriseisEncoder/Atchley_factors.csv\",\n",
" \"model\": \"TESSA/BriseisEncoder/TrainedEncoder.h5\",\n",
" \"embeding_vectors\": \"TESSA/BriseisEncoder/Atchley_factors.csv\",\n",
" # Output files\n",
" \"output_TCR\": f\"{path_res}/TESSA_tcr_embedding.csv\",\n",
" \"output_log\": f\"{path_res}/TESSA_log.log\",\n",
Expand Down Expand Up @@ -1270,8 +1269,6 @@
},
"outputs": [],
"source": [
"import conga\n",
"\n",
"df_tcr = pd.read_csv(\n",
" f\"{path_data}/TCR_00_read_aligned.csv\",\n",
" # index_col='barcode',\n",
Expand Down Expand Up @@ -1418,7 +1415,7 @@
"\n",
"import tcr_embedding.utils_training as utils\n",
"from tcr_embedding.models.model_selection import run_model_selection\n",
"from tcr_embedding.utils_preprocessing import group_shuffle_split, encode_tcr"
"from tcr_embedding.utils_preprocessing import encode_tcr, group_shuffle_split"
]
},
{
Expand Down
12 changes: 5 additions & 7 deletions jupyter-book/air_repertoire/specificity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@
" \".*IProgress not found*\",\n",
")\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import scanpy as sc\n",
"import scirpy as ir\n",
"import pandas as pd\n",
"import seaborn as sb\n",
"import matplotlib.pyplot as plt"
"import seaborn as sb"
]
},
{
Expand Down Expand Up @@ -924,8 +924,7 @@
"metadata": {},
"outputs": [],
"source": [
"from tcrdist.repertoire import TCRrep\n",
"from tcrdist.tree import TCRtree"
"from tcrdist.repertoire import TCRrep"
]
},
{
Expand Down Expand Up @@ -1230,8 +1229,8 @@
}
],
"source": [
"import scipy.spatial as sp\n",
"import scipy.cluster.hierarchy as hc\n",
"import scipy.spatial as sp\n",
"from matplotlib import rcParams\n",
"\n",
"rcParams[\"figure.figsize\"] = (20, 20)\n",
Expand Down Expand Up @@ -1294,7 +1293,6 @@
"\n",
"\n",
"def add_dists(adata, df_dist_alpha, df_dist_beta, name, cutoff):\n",
"\n",
" adata.uns[f\"ir_dist_aa_{name}\"] = {\n",
" \"params\": {\"metric\": f\"{name}\", \"sequence\": \"aa\", \"cutoff\": cutoff}\n",
" }\n",
Expand Down
38 changes: 19 additions & 19 deletions jupyter-book/cellular_structure/annotation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
"\n",
"warnings.filterwarnings(\"ignore\", category=DeprecationWarning)\n",
"\n",
"import numba\n",
"from numba.core.errors import NumbaDeprecationWarning, NumbaPendingDeprecationWarning\n",
"from numba.core.errors import NumbaDeprecationWarning\n",
"\n",
"warnings.simplefilter(\"ignore\", category=NumbaDeprecationWarning)"
]
Expand Down Expand Up @@ -84,17 +83,18 @@
}
],
"source": [
"import scanpy as sc\n",
"import pandas as pd\n",
"import urllib.request\n",
"from pathlib import Path\n",
"\n",
"import celltypist\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import os\n",
"from scipy.sparse import csr_matrix\n",
"import pandas as pd\n",
"import scanpy as sc\n",
"import scarches as sca\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"import celltypist\n",
"from celltypist import models\n",
"import scarches as sca\n",
"import urllib.request"
"from scipy.sparse import csr_matrix"
]
},
{
Expand Down Expand Up @@ -305,9 +305,9 @@
"metadata": {},
"outputs": [],
"source": [
"marker_genes_in_data = dict()\n",
"marker_genes_in_data = {}\n",
"for ct, markers in marker_genes.items():\n",
" markers_found = list()\n",
" markers_found = []\n",
" for marker in markers:\n",
" if marker in adata.var.index:\n",
" markers_found.append(marker)\n",
Expand Down Expand Up @@ -2105,9 +2105,9 @@
"outputs": [],
"source": [
"# loading model.pt from figshare\n",
"if not os.path.exists(\"./reference_model\"):\n",
" os.mkdir(\"./reference_model\")\n",
"elif not os.path.exists(\"./reference_model/model.pt\"):\n",
"if not Path(\"./reference_model\").exists():\n",
" Path(\"./reference_model\").mkdir()\n",
"elif not Path(\"./reference_model/model.pt\").exists():\n",
" urllib.request.urlretrieve(\n",
" \"https://figshare.com/ndownloader/files/41436648\",\n",
" filename=\"reference_model/model.pt\",\n",
Expand Down Expand Up @@ -2198,7 +2198,7 @@
}
],
"source": [
"scarches_model.train(max_epochs=500, plan_kwargs=dict(weight_decay=0.0))"
"scarches_model.train(max_epochs=500, plan_kwargs={\"weight_decay\": 0.0})"
]
},
{
Expand Down Expand Up @@ -2777,9 +2777,9 @@
"outputs": [],
"source": [
"adata.obs[\"transf_cell_type_certain\"] = adata.obs.transf_cell_type.tolist()\n",
"adata.obs.loc[\n",
" adata.obs.transf_cell_type_unc > 0.2, \"transf_cell_type_certain\"\n",
"] = \"Unknown\""
"adata.obs.loc[adata.obs.transf_cell_type_unc > 0.2, \"transf_cell_type_certain\"] = (\n",
" \"Unknown\"\n",
")"
]
},
{
Expand Down
14 changes: 5 additions & 9 deletions jupyter-book/cellular_structure/integration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,17 @@
],
"source": [
"# Python packages\n",
"import scanpy as sc\n",
"import scvi\n",
"import anndata2ri\n",
"import bbknn\n",
"import scib\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib\n",
"import scanpy as sc\n",
"import scib\n",
"import scvi\n",
"\n",
"# R interface\n",
"from rpy2.robjects import pandas2ri\n",
"from rpy2.robjects import r\n",
"import rpy2.rinterface_lib.callbacks\n",
"import anndata2ri\n",
"\n",
"pandas2ri.activate()\n",
"anndata2ri.activate()\n",
Expand Down Expand Up @@ -932,7 +929,6 @@
"sc.pp.highly_variable_genes(\n",
" adata, n_top_genes=2000, flavor=\"cell_ranger\", batch_key=batch_key\n",
")\n",
"adata\n",
"adata.var"
]
},
Expand Down
13 changes: 5 additions & 8 deletions jupyter-book/chromatin_accessibility/quality_control.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,19 @@
],
"source": [
"# Single-cell packages\n",
"import scanpy as sc\n",
"import anndata2ri\n",
"import matplotlib.pyplot as plt\n",
"import muon as mu\n",
"from muon import atac as ac # the module containing function for scATAC data processing\n",
"import numpy as np\n",
"\n",
"# General helpful packages for data analysis and visualization\n",
"import os\n",
"import pandas as pd\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import scanpy as sc\n",
"import seaborn as sns\n",
"from muon import atac as ac # the module containing function for scATAC data processing\n",
"\n",
"# Packages enabling to run R code\n",
"import rpy2.rinterface_lib.callbacks\n",
"import logging\n",
"from rpy2.robjects import pandas2ri\n",
"import anndata2ri\n",
"\n",
"pandas2ri.activate() # Automatically convert rpy2 outputs to pandas DataFrames\n",
"anndata2ri.activate()\n",
Expand Down
Loading

0 comments on commit 7931c8c

Please sign in to comment.