Skip to content

Commit

Permalink
update all notebooks with tvn
Browse files Browse the repository at this point in the history
  • Loading branch information
safiyecelik committed Dec 21, 2023
1 parent af3260b commit 807f85a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 250 deletions.
4 changes: 2 additions & 2 deletions efaar_benchmarking/data_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from efaar_benchmarking.constants import PERISCOPE_PLATE_COL


def load_periscope(cell_type="HeLa", normalized=False) -> tuple[pd.DataFrame, pd.DataFrame]:
def load_periscope(cell_type="HeLa", normalized=True) -> tuple[pd.DataFrame, pd.DataFrame]:
"""
Load PERISCOPE (cpg0021) data for a specific cell type.
Find more information about the dataset here: https://www.biorxiv.org/content/10.1101/2023.08.06.552164v1
Expand All @@ -21,7 +21,7 @@ def load_periscope(cell_type="HeLa", normalized=False) -> tuple[pd.DataFrame, pd
Parameters:
cell_type (str, optional): The cell type to load data for. Defaults to "HeLa".
normalized (bool, optional): Whether to load normalized data. Defaults to False.
normalized (bool, optional): Whether to load normalized data. Defaults to True.
Returns:
tuple[pd.DataFrame, pd.DataFrame]: A tuple containing two DataFrames named `features` and `metadata`,
Expand Down
100 changes: 20 additions & 80 deletions notebooks/jump_map_building.ipynb

Large diffs are not rendered by default.

179 changes: 22 additions & 157 deletions notebooks/periscope_map_building.ipynb

Large diffs are not rendered by default.

31 changes: 20 additions & 11 deletions notebooks/replogle_map_building.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,29 @@
},
"outputs": [],
"source": [
"adata = load_replogle(\"genome_wide\", \"normalized\") # use for PCA Embeddings\n",
"embeddings = embed_by_pca_anndata(adata) # PCA Embeddings\n",
"# adata = load_replogle(\"genome_wide\", \"raw\") # use for scVI Embeddings\n",
"# embeddings = embed_by_scvi_anndata(adata) # scVI Embeddings\n",
"# adata = load_replogle(\"genome_wide\", \"normalized\") # use for PCA Embeddings\n",
"# embeddings = embed_by_pca_anndata(adata) # PCA Embeddings\n",
"adata = load_replogle(\"genome_wide\", \"raw\") # use for scVI Embeddings\n",
"embeddings = embed_by_scvi_anndata(adata) # scVI Embeddings\n",
"metadata = adata.obs\n",
"del adata\n",
"embeddings = align_on_controls(embeddings, metadata, pert_col=REPLOGLE_PERT_LABEL_COL, control_key=REPLOGLE_CONTROL_PERT_LABEL, scale=True)\n",
"phenoprint_pvals = univariate_consistency_benchmark(embeddings, metadata, pert_col=REPLOGLE_PERT_LABEL_COL, keys_to_drop=[REPLOGLE_CONTROL_PERT_LABEL])\n",
"map_data = aggregate(embeddings, metadata, pert_col=REPLOGLE_PERT_LABEL_COL, control_key=REPLOGLE_CONTROL_PERT_LABEL)\n",
"del embeddings, metadata\n",
"metrics = multivariate_benchmark(map_data, recall_thr_pairs=recall_threshold_pairs, pert_col=REPLOGLE_PERT_LABEL_COL)\n",
"plot_recall(metrics)\n",
"metrics.groupby('source')['recall_0.05_0.95'].mean()"
"for fn in [centerscale_on_controls, tvn_on_controls]:\n",
" embeddings = fn(embeddings, metadata, pert_col=REPLOGLE_PERT_LABEL_COL, control_key=REPLOGLE_CONTROL_PERT_LABEL)\n",
" consistency_pvals = univariate_consistency_benchmark(embeddings, metadata, pert_col=REPLOGLE_PERT_LABEL_COL, keys_to_drop=[REPLOGLE_CONTROL_PERT_LABEL])\n",
" map_data = aggregate(embeddings, metadata, pert_col=REPLOGLE_PERT_LABEL_COL, control_key=REPLOGLE_CONTROL_PERT_LABEL)\n",
" for right_sided in [True, False]:\n",
" metrics = multivariate_benchmark(map_data, recall_thr_pairs=recall_threshold_pairs, pert_col=REPLOGLE_PERT_LABEL_COL, n_null_samples = 10000, n_iterations = 1, right_sided=right_sided)\n",
" plot_recall({'Replogle map': metrics}, right_sided=right_sided, title=\"Right tail only\" if right_sided else \"Both tails\")\n",
" print(metrics.groupby('source')['recall_0.05_0.95'].mean())"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fc927454",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 807f85a

Please sign in to comment.