<jupyter_start><jupyter_text>Merge with MetadataThis notebook takes a CSV produced by run_pipeline.py and merges it with the SRA Run Table TSV file. It optionally  normalises by Mbases as well if this is required. Note this will override normalisation by number of reads if this has already been done.<jupyter_code>import pandas as pd
import re
df_meta = pd.read_csv('../../accession_lists/allergy_SRARunTable.txt', sep='\t')
df_data = pd.read_csv('../data_files/allergy.allergy.csv', index_col=0)
output_name = 'allergy.meta.mbase_norm.csv'
normalise_with_mbases = True
df_data.head()
def get_srr_accession(df):
    
    pattern = re.compile(r"[DSE]RR[0-9]+")
    
    file = df['file_location']
    
    return re.search(pattern, file).group(0)
df_data['srr_acc'] = df_data.apply(get_srr_accession, axis=1)
df_data.set_index('srr_acc',inplace=True)
df_data.head()
df_meta.set_index('Run', inplace=True)
df_meta.head()
del df_meta.index.name
del df_data.index.name
df_meta.head()
master_df = df_meta.join(df_data)
master_df.columns
if normalise_with_mbases == True:


    master_df['norm_alignment_count'] = master_df['alignment_count'] / (master_df['MBases'])
    master_df['norm_alpha_wt_count'] = master_df['alpha_wt_count'] / (master_df['MBases'])
    master_df['norm_alpha_dup_count'] = master_df['alpha_dup_count'] / (master_df['MBases'])
    master_df['norm_beta_count'] = master_df['beta_count'] / (master_df['MBases'])
    master_df['norm_alpha_read_covers_snps_count_exact'] = master_df['alpha_read_covers_snps_count_exact'] / (master_df['MBases'])
    master_df['norm_alpha_dup_read_covers_snps_count_exact'] = master_df['alpha_dup_read_covers_snps_count_exact'] / (master_df['MBases'])
    master_df['norm_beta_read_covers_snps_count_exact'] = master_df['beta_read_covers_snps_count_exact'] / (master_df['MBases'])
master_df.head()
master_df.to_csv(output_name)
master_df.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1301405517959396, 'fraction_numerical': 0.0026028110359187923, 'mean_word_length': 6.813008130081301, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '100120', 'license': 'MIT', 'n_tokens_mistral': 724, 'n_tokens_neox': 709, 'n_words': 114, 'path': 'analysis/notebooks/merge_with_meta.ipynb', 'repo_name': 'NCBI-Hackathons/Tryptase_Duplication', 'size': '1921'}