<jupyter_start><jupyter_text>This notebook is used for plotting relative fraction of methylated reads on CENP-A vs non-CENP-A readsThe data in this notebook was copied from DiMeLoseq_in_situ_CENPA_kmer_mA.ipynb<jupyter_code>import sys
import os
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from scipy.stats import kde
%matplotlib inline

import math

import pysam
from Bio import SeqIO

from scipy import sparse

from sklearn import cluster, datasets, mixture, decomposition
#Setup the plotting context
#sns.set(color_codes=True)
#sns.set_context("talk")
#sns.set_style("darkgrid")
import scipy.spatial.distance as ssd
from scipy.cluster import hierarchy
from sklearn.metrics.pairwise import pairwise_distances
colorpal = ['#FFBC0A','#053C5E','#559CAD','#610345','#A9E5BB','#2D1E2F','#BB4420','#5E747F']
sns.color_palette(colorpal)
for i in range(len(colorpal)):
    plt.bar(i,2,color=colorpal[i], label = colorpal[i])
plt.legend(bbox_to_anchor=(1.05, 1), loc='upper left')
plt.show()
names = ['CENP-A-directed', 'IgG-directed', 'free pA-Hia5', 'untreated' ]
CENPAreads = [0.051195,0.014385,0.052007,0.015494]
NonCENPAreads = [0.007017,0.005864,0.102610,0.005813]
df = pd.DataFrame(data=np.array([CENPAreads, NonCENPAreads]).transpose(), index=names, columns = ['CENPA','NonCENPA'])
ind = np.arange(4)
width = 0.4
fig=plt.figure(figsize = (4,3))
plt.bar(ind, df['CENPA'], width, color='#559CAD', label = 'CENP-A reads')
plt.bar(ind+width, df['NonCENPA'], width, color='#610345', label = 'Non-CENP-A reads', alpha = 0.5)
plt.xticks(ind+width, (x for x in names), fontsize = 14, rotation = 45)
#plt.xlabel("chromosome", fontsize=24)
plt.ylabel("% m6A/A", fontsize=14)
#plt.yscale("log")
#plt.title('Centromere Live HOR coverage')
#plt.xticks(ind + width / 2, ('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','X', 'Y'),fontsize=24)
#plt.yticks(fontsize=24)
plt.legend(fontsize=16, bbox_to_anchor=(1.02, 1), loc='upper left')
#plt.show()

#fig.savefig('/home/groups/astraigh/ont_minion/jups/output/kmer_m6A_enrichment.png', dpi = 300, bbox_inches='tight')
ci_lower_CA = [0.050964,0.014259,0.051755,0.015359]
ci_upper_CA = [0.051429,0.014512,0.052260,0.015632]

ci_lower_nonCA = [0.006885,0.005747,0.102175,0.005694]
ci_upper_nonCA = [0.007150,0.005983,0.103048,0.005936]
ci_lower = pd.DataFrame(data=np.array([ci_lower_CA, ci_lower_nonCA]).transpose(), index=names, columns = ['CENPA','NonCENPA'])
ci_upper = pd.DataFrame(data=np.array([ci_upper_CA, ci_upper_nonCA]).transpose(), index=names, columns = ['CENPA','NonCENPA'])
ci_lower
df['CENPA']
df - ci_lower
ci_upper - df
error_CA_reads = (df['CENPA']-ci_lower['CENPA'], ci_upper['CENPA']-df['CENPA'])
error_CA_reads
error_nonCA_reads = (df['NonCENPA']-ci_lower['NonCENPA'], ci_upper['NonCENPA']-df['NonCENPA'])
error_nonCA_reads
ind = np.arange(4)
width = 0.4
fig=plt.figure(figsize = (4,3))
plt.bar(ind, df['CENPA'], width,yerr = error_CA_reads, color='#559CAD', label = 'CENP-A reads',ecolor='black', capsize=5)

plt.bar(ind+width, df['NonCENPA'], width,yerr = error_nonCA_reads, color='#610345', label = 'Non-CENP-A reads', alpha = 0.5,ecolor='black', capsize=5)


plt.xticks(ind+width, (x for x in names), fontsize = 14, rotation = 45)
#plt.xlabel("chromosome", fontsize=24)
plt.ylabel("% m6A/A", fontsize=14)
#plt.yscale("log")
#plt.title('Centromere Live HOR coverage')
#plt.xticks(ind + width / 2, ('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','X', 'Y'),fontsize=24)
#plt.yticks(fontsize=24)
plt.legend(fontsize=16, bbox_to_anchor=(1.02, 1), loc='upper left')
#plt.show()

fig.savefig('/home/groups/astraigh/ont_minion/jups/output/kmer_m6A_enrichment_with_ci.png', dpi = 300, bbox_inches='tight')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20161500390726753, 'fraction_numerical': 0.09195102891377963, 'mean_word_length': 7.495575221238938, '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': '343895', 'license': 'MIT', 'n_tokens_mistral': 1834, 'n_tokens_neox': 1602, 'n_words': 272, 'path': 'invitro_and_cenpa/DiMeLoseq_in_situ_CENPA_kmer_mA_plotting.ipynb', 'repo_name': 'amaslan/dimelo-seq', 'size': '3839'}