<jupyter_start><jupyter_text>Load and subset the aggregated multiome data<jupyter_code>import scanpy as sc
import pandas as pd
import numpy as np

import os<jupyter_output><empty_output><jupyter_text>Download the annotated h5ad file from the aws bucket:+`aws s3 cp s3://openproblems-bio/neurips2021/multimodal_aggr_output/filtered_feature_bc_matrix.annotated.h5ad`<jupyter_code>os.getcwd()
file_path='/home/jovyan/project/neurips2021-notebooks/data/multiome/raw_data/filtered_feature_bc_matrix.annotated.h5ad'
# Load the h5ad file (for the h5ad you don't need to gex_only argument)
adata = sc.read_h5ad(file_path)
adata.var_names_make_unique()
# Inspect the object
adata
# Check what feature types here are
adata.var['feature_types'].value_counts()
# Print columns in the obs data
print(adata.obs.site.value_counts())
print(adata.obs.donor.value_counts())
adata.obs['donor_single'] = [s+' '+d for s,d in zip(adata.obs.site, adata.obs.donor)]
adata.obs['donor_single'].value_counts()
# Subset to the donor of interest and the feature type

site = 'site1'
donor = 'donor1'

feature_type = 'Peaks'
adata_sub = adata[np.logical_and(adata.obs.site==site,
                                adata.obs.donor==donor),:]
adata_sub = adata_sub[:,adata_sub.var.feature_types==feature_type]
# Let's check whether everthing worked
print(adata_sub.var['feature_types'].value_counts())
print(adata_sub.obs.site.value_counts())
print(adata_sub.obs.donor.value_counts())
# Save subsetted adata

output_path = '/home/jovyan/project/neurips2021-notebooks/data/multiome/raw_data/s1d1/s1d1_subset.h5ad'

adata_sub.write_h5ad(output_path)<jupyter_output>/srv/conda/envs/saturn/lib/python3.9/site-packages/anndata/_core/anndata.py:1228: ImplicitModificationWarning: Initializing view as actual.
  warnings.warn(
Trying to set attribute `.obs` of view, copying.
... storing 'donor_single' as categorical
{'fraction_non_alphanumeric': 0.11673773987206823, 'fraction_numerical': 0.01812366737739872, 'mean_word_length': 6.003731343283582, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '224013', 'license': 'MIT', 'n_tokens_mistral': 706, 'n_tokens_neox': 680, 'n_words': 129, 'path': 'notebooks/templates/Load_aggr_h5ad_data.ipynb', 'repo_name': 'asarigun/NeurIPS2021-Challenge', 'size': '1876'}