<jupyter_start><jupyter_text>Here the samples from BAL are converted into anndata objects to then use them with scanpy<jupyter_code>import anndata2ri
from rpy2.robjects import r
anndata2ri.activate()
%load_ext rpy2.ipython

import matplotlib.pyplot as plt
# Scanpy and scarches
import scanpy as sc
import scarches as sca
sc.settings.set_figure_params(dpi=100, frameon=False, facecolor='white')<jupyter_output>Using TensorFlow backend.<jupyter_text>Import Seurat datasets and check them out- Load the three datasets provided by Saliba<jupyter_code>%%R
library(Seurat)
library(ggplot2)
apc <- readRDS('../data/APC-1_A1A2_rm-LQ-HTO-T-NK-MOI15_cMono.Rds')
bal <- readRDS('../data/BAL_rmLQ-C3.Rds')
bal_mdm <- readRDS('../data/BAL_rmLQ-C3_MDM-AM_rmCD3.Rds')
print(c(apc, bal, bal_mdm))<jupyter_output>[[1]]
An object of class Seurat 
31178 features across 1157 samples within 2 assays 
Active assay: SCT (13249 features)
 1 other assay present: RNA
 34 dimensional reductions calculated: RNA_pca, RNA_pca_umap_20, RNA_pca_umap_25, RNA_pca_umap_30, RNA_pca_umap_35, SCT_pca, SCT_pca_umap_20, SCT_pca_umap_25, SCT_pca_umap_30, SCT_pca_umap_35, RNA_pca_umap_5, RNA_pca_umap_10, RNA_pca_umap_15, RNA_pca_umap_40, RNA_mnn, RNA_mnn_umap_5, RNA_mnn_umap_10, RNA_mnn_umap_15, RNA_mnn_umap_20, RNA_mnn_umap_25, RNA_mnn_umap_30, RNA_mnn_umap_40, SCT_pca_umap_5, SCT_pca_umap_10, SCT_pca_umap_15, SCT_pca_umap_40, SCT_mnn, SCT_mnn_umap_5, SCT_mnn_umap_10, SCT_mnn_umap_15, SCT_mnn_umap_20, SCT_mnn_umap_25, SCT_mnn_umap_30, SCT_mnn_umap_40

[[2]]
An object of class Seurat 
27016 features across 44227 samples within 2 assays 
Active assay: RNA (27007 features)
 1 other assay present: VIRAL
 14 dimensional reductions calculated: RNA_pca, RNA_pca_5_umap, RNA_pca_10_umap, RNA_pca_15_umap, RNA_pca_20_umap, RNA_p[...]<jupyter_text>Convert each of the required dataset iteratively into adata APC-1_A1A2_rm-LQ-HTO-T-NK-MOI15_cMono.Rds<jupyter_code>%%R -o apc
# data(sct, package = 'scRNAseq')
print('starting...')
apc <- as.SingleCellExperiment(apc)
print('done...')<jupyter_output>[1] "starting..."
[1] "done..."<jupyter_text>BAL_rmLQ-C3_MDM-AM_rmCD3.Rds<jupyter_code>%%R -o bal
# data(sct, package = 'scRNAseq')
print('starting...')
bal <- as.SingleCellExperiment(bal)
print('done...')<jupyter_output>[1] "starting..."
[1] "done..."<jupyter_text>BAL_rmLQ-C3_MDM-AM_rmCD3.Rds<jupyter_code>%%R -o bal_mdm
# data(sct, package = 'scRNAseq')
print('starting...')
bal_mdm <- as.SingleCellExperiment(bal_mdm)
print('done...')
bal.write_h5ad('../data/bal/bal.h5ad', compression='lzf')
bal_mdm.write_h5ad('../data/bal/bal_mdm.h5ad', compression='lzf')<jupyter_output><empty_output><jupyter_text>Write metadata (gene -> ensembl)<jupyter_code>%%R -o bal_df
# data(sct, package = 'scRNAseq')
print('starting...')
bal_df <- as.data.frame(bal@misc$features)
print('done...')

bal
print('done...')
bal_df.head()
import pandas as pd
print(bal_df.shape)
bal_df.to_csv('../data/bal/bal_feature_names.tsv.gz', compression='gzip', index=None, sep='\t')
bal_df = pd.read_csv('../data/bal/bal_feature_names.tsv.gz', compression='gzip', sep='\t')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13707363723302518, 'fraction_numerical': 0.04303474657315907, 'mean_word_length': 6.767326732673268, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '300171', 'license': 'MIT', 'n_tokens_mistral': 1504, 'n_tokens_neox': 1372, 'n_words': 237, 'path': 'notebooks/01_3_data_preparation_bal.ipynb', 'repo_name': 'theislab/covid_macrophages_integration', 'size': '3137'}