<jupyter_start><jupyter_text>Generate mutation indicator plots for simulated viral samples (Figure 4)<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
from Bio import SeqIO
import seaborn as sns

%matplotlib inline
initial_sequence = SeqIO.read("./rhinoC_virapops_output/DERISI_HRC_100.1", "fasta")
s100 = initial_sequence.seq
seq_95perc = SeqIO.read("./rhinoC_virapops_output/DERISI_HRC_095.1", "fasta")
s95 = seq_95perc.seq.upper()
seq_75perc = SeqIO.read("./rhinoC_virapops_output/DERISI_HRC_075.1", "fasta")
s75 = seq_75perc.seq.upper()
seq_50perc = SeqIO.read("./rhinoC_virapops_output/DERISI_HRC_050.1", "fasta")
s50 = seq_50perc.seq.upper()
mutations_95 = [s95[i] == s100[i] for i in range(len(s95))]
mutations_75 = [s75[i] == s100[i] for i in range(len(s75))]
mutations_50 = [s50[i] == s100[i] for i in range(len(s50))]


def sliding_window_perc_ident(mutations_array):
    ws = 50
    new_mut = [0] * len(mutations_array)
    for i in range(len(mutations_array) - ws):
        new_mut[i] = sum(mutations_array[i:(i+ws)])/len(mutations_array[i:(i+ws)])

    return(new_mut)

avg_mut_95 = sliding_window_perc_ident(mutations_95)
avg_mut_75 = sliding_window_perc_ident(mutations_75)
avg_mut_50 = sliding_window_perc_ident(mutations_50)

colpal_dark = sns.color_palette("husl", 12)
# These features come from this NCBI entry: https://www.ncbi.nlm.nih.gov/nuccore/NC_009996

virus_features =  [1 for i in range(616,817)] + [2 for i in range(817,1600)]  + [3 for i in range(1600,2305)] + [4 for i in range(2305,3127)] + [5 for i in range(3127, 3553)] + [6 for i in range(3553, 3850)] + [7 for i in range(3850, 4828)] + [8 for i in range(4828, 5053)] + [9 for i in range(5053, 5119)]+ [10 for i in range(5119, 5668)]+ [11 for i in range(5668, 7047)]

df = pd.DataFrame({'m95':mutations_95,'m75':mutations_75,'m50':mutations_50})

import seaborn as sns
plt.figure(figsize = (28,4))
pal = sns.light_palette((210, 90, 60), input="husl")
pal.reverse()
sns.heatmap(df.transpose(), cmap=pal)
plt.savefig('rhinoc_mutations_heatmap.pdf')
plt.figure(figsize = (28,4))
sns.heatmap(pd.DataFrame(virus_features).transpose(), cmap=colpal_dark)
plt.savefig('rhinoc_genome_heatmap.pdf')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1487156376746282, 'fraction_numerical': 0.09508787742226228, 'mean_word_length': 6.161290322580645, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '663115', 'license': 'MIT', 'n_tokens_mistral': 1067, 'n_tokens_neox': 920, 'n_words': 185, 'path': 'result_scripts/data/divergent_rhinovirus_hrc_inputs/Rhinovirus_simulation_mutations_plot.ipynb', 'repo_name': 'katrinakalantar/idseq-benchmark-manuscript', 'size': '2219'}