<jupyter_start><jupyter_text>Loading data We provide a simple guide in how to load your own data and initialize the adata object for downstream analysis. This tutorial assumes that the files are either in txt or mtx format. After running this pipeline, please see the folder test_data for how exactly each data is stored. For how to convert the clonal barcode fastq file into cell-by-clone matrix or other formats, please consult https://github.com/AllonKleinLab/LARRY<jupyter_code>import cospar as cs
import pandas as pd
import scipy.io as sio
import numpy as np
cs.logging.print_version()<jupyter_output>Running cospar 0.1.8 (python 3.6.13) on 2021-05-31 23:43.<jupyter_text>Download raw data<jupyter_code>cs.settings.data_path='test_data' # This name should be exactly 'text_data' 
cs.datasets.raw_data_for_import_exercise()<jupyter_output><empty_output><jupyter_text>Import method AAssuming that the X_clone data is stored in mtx format<jupyter_code>df_cell_id=pd.read_csv(f'{cs.settings.data_path}/cell_id.txt')
df_cell_id.head()
df_gene=pd.read_csv(f'{cs.settings.data_path}/gene_names.txt')
df_gene.head()
df_time=pd.read_csv(f'{cs.settings.data_path}/time_info.txt')
df_time.head()
RNA_count_matrix=sio.mmread(f'{cs.settings.data_path}/gene_expression_count_matrx.mtx')
RNA_count_matrix
X_clone=sio.mmread(f'{cs.settings.data_path}/cell_by_clone_matrx.mtx')
X_clone
df_state=pd.read_csv(f'{cs.settings.data_path}/state_info.txt')
df_state.head()
df_X_emb=pd.read_csv(f'{cs.settings.data_path}/embedding.txt')
df_X_emb.head()
X_emb=np.array([df_X_emb['x'],df_X_emb['y']]).T<jupyter_output><empty_output><jupyter_text>Now, initialize the adata object<jupyter_code>adata_orig=cs.pp.initialize_adata_object(X_state=RNA_count_matrix,
    gene_names=df_gene['gene_names'],cell_names=df_cell_id['Cell_ID'],
    time_info=df_time['time_info'],X_clone=X_clone,
    state_info=df_state['state_info'], X_emb=X_emb,data_des='my_data')
adata_orig
cs.pl.embedding(adata_orig,color='state_info')<jupyter_output><empty_output><jupyter_text>Import method BAssuming that the X_clone data is stored in a (cell_id, barcode_id) format First, initialize the adata without concerning the clonal data<jupyter_code>df_cell_id=pd.read_csv(f'{cs.settings.data_path}/cell_id.txt')
df_gene=pd.read_csv(f'{cs.settings.data_path}/gene_names.txt')
df_time=pd.read_csv(f'{cs.settings.data_path}/time_info.txt')
RNA_count_matrix=sio.mmread(f'{cs.settings.data_path}/gene_expression_count_matrx.mtx')
df_state=pd.read_csv(f'{cs.settings.data_path}/state_info.txt')
df_X_emb=pd.read_csv(f'{cs.settings.data_path}/embedding.txt')
X_emb=np.array([df_X_emb['x'],df_X_emb['y']]).T
adata_orig=cs.pp.initialize_adata_object(X_state=RNA_count_matrix,
    gene_names=df_gene['gene_names'],cell_names=df_cell_id['Cell_ID'],
    time_info=df_time['time_info'],
    state_info=df_state['state_info'], X_emb=X_emb,data_des='my_data')<jupyter_output>Create new anndata object
WARNING: X_pca not provided. Downstream processing is needed to generate X_pca before computing the transition map.
Time points with clonal info: []
WARNING: Default ascending order of time points are: ['2' '4' '6']. If not correct, run cs.hf.update_time_ordering for correction.
WARNING: Please make sure that the count matrix adata.X is NOT log-transformed.<jupyter_text>Now, load the clonal data. Here, we start with a table of (cell_id, clone_id) pair. The cell_id does not need to be ranked. It should match the cell_id in the ``adata_orig.obs_names``<jupyter_code>df_X_clone=pd.read_csv(f'{cs.settings.data_path}/clonal_data_in_table_format.txt')
df_X_clone
adata_orig.obs_names
cs.pp.get_X_clone(adata_orig,df_X_clone['Cell_ID'],df_X_clone['Clone_ID'])
adata_orig
cs.pl.embedding(adata_orig,color='state_info')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1187202538339503, 'fraction_numerical': 0.005817028027498678, 'mean_word_length': 8.182038834951456, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 1, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '407031', 'license': 'MIT', 'n_tokens_mistral': 1442, 'n_tokens_neox': 1398, 'n_words': 258, 'path': 'docs/source/20210601_Loading_data.ipynb', 'repo_name': 'rbonhamcarter/cospar', 'size': '3782'}