<jupyter_start><jupyter_text>Обработка данных<jupyter_code># Загружаю предикшены TargetScan
target = pd.DataFrame(pd.read_csv('TargetScan_Predict.txt', sep='\t'))
target.head()
# Немного форматирую датафрейм под нашу задачу
target.rename(columns={'miRNA_family_ID': 'miRNA', 'a_Gene_ID': 'Virus'}, inplace=True)
target.drop(['species_ID', 'Group_num', 'Group_type',
                 'Species_in_this_group', 'Species_in_this_group_with_this_site_type'],
                axis=1, inplace=True)
cat = np.unique(target['Virus'].values)
print(cat)
# Загружаю предикшены TargetScan
# 4 коронавируса - после выравнивания, остальные - без
sarst = target[target['Virus'] == 'SARS_coronavirus_complete_genome']
merst = target[target['Virus'] == 'Middle_East_respiratory_syndrome_coronavirus']
oc43t = target[target['Virus'] == 'Human_coronavirus_OC43']
sars2t = target[target['Virus'] == 'Severe_acute_respiratory_syndrome_coronavirus_2']
hku1t = pd.read_csv('TargetScan_predictions/HCoV-HKU1.txt', sep='\t')
e229t = pd.read_csv('TargetScan_predictions/HCoV-229E.txt', sep='\t')
nl63t = pd.read_csv('TargetScan_predictions/HCoV-NL63.txt', sep='\t')
sars2t.head()
list_name = [hku1t, e229t, nl63t]
# Немного форматирую датафреймы под нашу задачу
for tar in list_name:
    tar.rename(columns={'miRNA_family_ID': 'miRNA', 'a_Gene_ID': 'Virus'}, inplace=True)
    tar.drop(['species_ID', 'Group_num', 'Group_type',
                 'Species_in_this_group', 'Species_in_this_group_with_this_site_type'],
                axis=1, inplace=True)
sars2t.head()
# Загружаю данные miRDB
sars2m = pd.DataFrame(pd.read_csv('miRDB_predictions/SARS-CoV-2_miRDB.txt', sep='\t'))
sarsm = pd.DataFrame(pd.read_csv('miRDB_predictions/SARS-CoV_miRDB.txt', sep='\t'))
oc43m = pd.DataFrame(pd.read_csv('miRDB_predictions/HCoV-OC43_miRDB.txt', sep='\t'))
mersm = pd.DataFrame(pd.read_csv('miRDB_predictions/MERS-CoV_miRDB.txt', sep='\t'))
hku1m = pd.DataFrame(pd.read_csv('miRDB_predictions/HCoV-HKU1_miRDB.txt', sep='\t'))
e229m = pd.DataFrame(pd.read_csv('miRDB_predictions/HCoV-229E_miRDB.txt', sep='\t'))
nl63m = pd.DataFrame(pd.read_csv('miRDB_predictions/HCoV-NL63_miRDB.txt', sep='\t'))
sars2m.head(1)
# Загружаю данные экспрессии
lungs = pd.DataFrame(pd.read_csv('lungs_expression.txt', sep='\t'))
lungs.head(1)
# Создаю столбец средних арифметических значений экспрессии
lungs['average'] = lungs.sum(axis=1)/(lungs.shape[1]-1)
lungs.head(1)
# Удаляю столбцы по отдельным клеточным линиям, оставляюю только название микроРНК
# и среднее значение экспрессии
lungs.drop(lungs.columns[[i for i in range(1,47)]], axis=1, inplace=True)
lungs.head(1)<jupyter_output><empty_output><jupyter_text>Рабочий поцесс: Cортировка по TargetScore и по экспрессии Все функции описаны в файле Predictions.py<jupyter_code>all_score(sars2m, sars2t, lungs, 
          'Intermediate_results/SARS_CoV_2_FullComparasion_scoresort')
all_exp(sars2m, sars2t, lungs, 
        'Intermediate_results/expsort/SARS_CoV_2_FullComparasion_expsort')
all_score(sarsm, sarst, lungs,
          'Intermediate_results/SARS_CoV_FullComparasion_scoresort')
all_exp(sarsm, sarst, lungs,
        'Intermediate_results/expsort/SARS_CoV_FullComparasion_expsort')
all_score(mersm, merst, lungs,
          'Intermediate_results/MERS_CoV_FullComparasion_scoresort')
all_exp(mersm, merst, lungs,
        'Intermediate_results/expsort/MERS_CoV_FullComparasion_expsort')
all_score(oc43m, oc43t, lungs,
          'Intermediate_results/HCoV_OC43_FullComparasion_scoresort')
all_exp(oc43m, oc43t, lungs,
        'Intermediate_results/expsort/HCoV_OC43_FullComparasion_expsort')
all_score(hku1m, hku1t, lungs,
          'Intermediate_results/HCoV_HKU1_FullComparasion_scoresort')
all_exp(hku1m, hku1t, lungs,
        'Intermediate_results/expsort/HCoV_HKU_FullComparasion_expsort')
all_score(e229m, e229t, lungs,
          'Intermediate_results/HCoV_229E_FullComparasion_scoresort')
all_exp(e229m, e229t, lungs,
        'Intermediate_results/expsort/HCoV_229E_FullComparasion_expsort')
all_score(nl63m, nl63t, lungs,
          'Intermediate_results/HCoV_NL63_FullComparasion_scoresort')
all_exp(nl63m, nl63t, lungs,
        'Intermediate_results/expsort/HCoV_NL63_FullComparasion_expsort')
# фильтрую фрейм с экспрессией по среднему значению экспрессии
lungs.sort_values('average', ascending=False, inplace=True)
save_top(lungs, 'Intermediate_results/expression_sort')<jupyter_output><empty_output><jupyter_text>Первые результаты<jupyter_code>first_result('Intermediate_results/SARS_CoV_2_FullComparasion_scoresort',
             'Results/Result_SARS2', lungs)
first_result('Intermediate_results/SARS_CoV_FullComparasion_scoresort',
             'Results/Result_SARS', lungs)
first_result('Intermediate_results/MERS_CoV_FullComparasion_scoresort',
             'Results/Result_MERS', lungs)
first_result('Intermediate_results/HCoV_OC43_FullComparasion_scoresort',
             'Results/Result_OC43', lungs)
first_result('Intermediate_results/HCoV_HKU1_FullComparasion_scoresort',
             'Results/Result_HKU1', lungs)
first_result('Intermediate_results/HCoV_229E_FullComparasion_scoresort',
             'Results/Result_229E', lungs)
first_result('Intermediate_results/HCoV_NL63_FullComparasion_scoresort',
             'Results/Result_NL63', lungs)<jupyter_output><empty_output><jupyter_text>Сравнение сайтов связывания<jupyter_code>locus(sars2t, 'Result_SARS2', 'SARS2')
locus(sarst, 'Result_SARS', 'SARS')
locus(merst, 'Result_MERS', 'MERS')
locus(oc43t, 'Result_OC43', 'OC43')
locus(hku1t, 'Result_HKU1', 'HKU1')
locus(e229t, 'Result_229E','229E')
locus(nl63t, 'Result_NL63', 'NL63')<jupyter_output>[False]<jupyter_text>Смотрим результаты Результаты пересечений<jupyter_code>pd.DataFrame(pd.read_csv('Results/Result_SARS2.txt', sep='\t'))
pd.DataFrame(pd.read_csv('Results/Result_SARS.txt', sep='\t'))
pd.DataFrame(pd.read_csv('Results/Result_MERS.txt', sep='\t'))
pd.DataFrame(pd.read_csv('Results/Result_OC43.txt', sep='\t'))
pd.DataFrame(pd.read_csv('Results/Result_HKU1.txt', sep='\t'))
pd.DataFrame(pd.read_csv('Results/Result_229E.txt', sep='\t'))
pd.DataFrame(pd.read_csv('Results/Result_NL63.txt', sep='\t'))<jupyter_output><empty_output><jupyter_text>Результаты с сайтами связывания (NaN = UTR в генах)<jupyter_code>locus_sars = pd.DataFrame(pd.read_csv('Results/locus_Result_SARS.txt', sep='\t'))
locus_sars.head()
locus_sars2 = pd.DataFrame(pd.read_csv('Results/locus_Result_SARS2.txt', sep='\t'))
locus_sars2[locus_sars2['Locus_start'].isnull()]
locus_mers = pd.DataFrame(pd.read_csv('Results/locus_Result_MERS.txt', sep='\t'))
locus_mers.head()
locus_oc43 = pd.DataFrame(pd.read_csv('Results/locus_Result_OC43.txt', sep='\t'))
locus_oc43.head()
locus_hku1 = pd.DataFrame(pd.read_csv('Results/locus_Result_HKU1.txt', sep='\t'))
locus_hku1.head()
locus_e229 = pd.DataFrame(pd.read_csv('Results/locus_Result_229E.txt', sep='\t'))
locus_e229.head()
locus_nl63 = pd.DataFrame(pd.read_csv('Results/locus_Result_NL63.txt', sep='\t'))
locus_nl63.head()<jupyter_output><empty_output><jupyter_text>Строим гафики  Сравнение начальных позиций сайта и конечных позиций сайта связывания по РНК геному (генам) (Только по выравненным последовательностям четырех коронавирусов)  Хорошего качества картинка в Graphs/RNA_virus.png код в Graphs/Graph_gene_comparison.py ![RNA_virus.png](attachment:RNA_virus.png)  Сравнение начальных позиций сайта и конечных позиций сайта связывания по белковому сиквенсу (Только по выравненным последовательностям четырех коронавирусов)  Хорошего качества картинка в Graphs/proteins_virus.png код в Graphs/Graph_protein_comparison.py ![proteins_virus.png](attachment:proteins_virus.png)  Сравнение точек начала и конца сайта связывания (Только по выравненным последовательностям четырех коронавирусов)<jupyter_code>import matplotlib.pyplot as plt
mirna = 'miR-21-3p'

x1 = locus_sars[locus_sars['miRNA'] == mirna]['MSA_start'].tolist()
y1 = locus_sars[locus_sars['miRNA'] == mirna]['MSA_end'].tolist()

x2 = locus_oc43[locus_oc43['miRNA'] == mirna]['MSA_start'].tolist()
y2 = locus_oc43[locus_oc43['miRNA'] == mirna]['MSA_end'].tolist()

x3 = locus_sars2[locus_sars2['miRNA'] == mirna]['MSA_start'].tolist()
y3 = locus_sars2[locus_sars2['miRNA'] == mirna]['MSA_end'].tolist()

x4 = locus_mers[locus_mers['miRNA'] == mirna]['MSA_start'].tolist()
y4 = locus_mers[locus_mers['miRNA'] == mirna]['MSA_end'].tolist()

fig, ax = plt.subplots(1, 1, figsize=(25, 25), tight_layout=True)
fig.suptitle('miR-21-3p conserved and nonconserved binding sites',
             va='baseline', color='blue', fontsize=30)

ax.set_xlabel('Start nt of binding site', fontsize=30, color='blue')
ax.set_ylabel('End nt of binding site', fontsize=30, color='blue')
ax.yaxis.set_ticks(np.arange(0, 33001, 1000))
ax.xaxis.set_ticks(np.arange(0, 33001, 1000))
ax.yaxis.set_tick_params(labelsize=30)
ax.xaxis.set_tick_params(labelrotation=45, labelsize=30)
ax.axis([-1000, 33000, -1000, 33000])
ax.grid()

ax = plt.plot(x3, y3, 'og', markersize=12, label='SARS2')
ax = plt.plot(x1, y1, 'or', markersize=9, label='SARS')
ax = plt.plot(x2, y2, 'o', color='orange', markersize=6, label='OC43')
ax = plt.plot(x4, y4, 'o', color='purple', markersize=3, label='MERS')

plt.legend()

plt.show()
mirna = 'miR-16-5p'

x1 = locus_sars[locus_sars['miRNA'] == mirna]['MSA_start'].tolist()
y1 = locus_sars[locus_sars['miRNA'] == mirna]['MSA_end'].tolist()

x2 = locus_oc43[locus_oc43['miRNA'] == mirna]['MSA_start'].tolist()
y2 = locus_oc43[locus_oc43['miRNA'] == mirna]['MSA_end'].tolist()

x3 = locus_sars2[locus_sars2['miRNA'] == mirna]['MSA_start'].tolist()
y3 = locus_sars2[locus_sars2['miRNA'] == mirna]['MSA_end'].tolist()

x4 = locus_mers[locus_mers['miRNA'] == mirna]['MSA_start'].tolist()
y4 = locus_mers[locus_mers['miRNA'] == mirna]['MSA_end'].tolist()

fig, ax = plt.subplots(1, 1, figsize=(25, 25), tight_layout=True)
fig.suptitle('miR-16-5p conserved and nonconserved binding sites',
             va='baseline', color='blue', fontsize=30)

ax.set_xlabel('Start nt of binding site', fontsize=30, color='blue')
ax.set_ylabel('End nt of binding site', fontsize=30, color='blue')
ax.yaxis.set_ticks(np.arange(0, 33001, 1000))
ax.xaxis.set_ticks(np.arange(0, 33001, 1000))
ax.yaxis.set_tick_params(labelsize=30)
ax.xaxis.set_tick_params(labelrotation=45, labelsize=30)
ax.axis([-1000, 33000, -1000, 33000])
ax.grid()

ax = plt.plot(x3, y3, 'og', markersize=12, label='SARS2')
ax = plt.plot(x1, y1, 'or', markersize=9, label='SARS')
ax = plt.plot(x2, y2, 'o', color='orange', markersize=6, label='OC43')
ax = plt.plot(x4, y4, 'o', color='purple', markersize=3, label='MERS')

plt.legend()

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15026296018031554, 'fraction_numerical': 0.036626596543951916, 'mean_word_length': 7.141437308868501, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '433626', 'license': 'CC0-1.0', 'n_tokens_mistral': 4682, 'n_tokens_neox': 4483, 'n_words': 592, 'path': 'TargetScan/With_lungs_comparison.ipynb', 'repo_name': 'alex123012/computer-literacy-2020', 'size': '10648'}