From 878d275c5f14736199fb926dcfacd4fc499d9f67 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Sun, 8 Sep 2024 11:30:26 +0200 Subject: [PATCH] use subset adata --- book/in_memory2.qmd | 15 +-------------- book/in_memory_interoperability.qmd | 14 +------------- book/usecase/index.qmd | 2 ++ 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/book/in_memory2.qmd b/book/in_memory2.qmd index c163b4b..104129d 100644 --- a/book/in_memory2.qmd +++ b/book/in_memory2.qmd @@ -16,7 +16,7 @@ Read in the anndata object ```{r read_in} library(anndata) -adata_path <- "usecase/data/sc_counts_reannotated_with_counts.h5ad" +adata_path <- "usecase/data/sc_counts_subset.h5ad" adata <- anndata::read_h5ad(adata_path) ``` @@ -28,19 +28,6 @@ adata <- anndata::read_h5ad(adata_path) # Usecase -## 3. Subset data - -Subset to a single small molecule and control for computational efficiency: - -```{r select_sm_celltype} -library(dplyr) - -sm_name2 <- "Belinostat" -control_name <- "Dimethyl Sulfoxide" - -# subset obs -adata <- adata[adata$obs$sm_name %in% c(control_name, sm_name), ] -``` ## 4. Compute pseudobulk diff --git a/book/in_memory_interoperability.qmd b/book/in_memory_interoperability.qmd index 827e91d..a687501 100644 --- a/book/in_memory_interoperability.qmd +++ b/book/in_memory_interoperability.qmd @@ -203,22 +203,10 @@ with (robjects.default_converter + pandas2ri.converter).context(): ```{r read_in} library(anndata) -adata_path <- "usecase/data/sc_counts_reannotated_with_counts.h5ad" +adata_path <- "usecase/data/sc_counts_subset.h5ad" adata <- anndata::read_h5ad(adata_path) ``` -Subset to a single small molecule and control for computational efficiency: - -```{r select_sm_celltype} -library(dplyr) - -sm_name <- "Belinostat" -control_name <- "Dimethyl Sulfoxide" - -# subset obs -adata <- adata[adata$obs$sm_name %in% c(control_name, sm_name), adata$var$highly_variable] -``` - ## 4. Compute pseudobulk ```{r import_pandas} diff --git a/book/usecase/index.qmd b/book/usecase/index.qmd index 4dc4812..01603c0 100644 --- a/book/usecase/index.qmd +++ b/book/usecase/index.qmd @@ -67,6 +67,8 @@ adata = adata[ adata.obs["sm_name"].isin([sm_name, control_name]) & adata.obs["cell_type"].isin([cell_type]), ].copy() + +adata.write_h5ad("data/sc_counts_subset.h5ad") ``` We will also subset the genes to the top 2000 most variable genes.