Skip to content
Snippets Groups Projects
Commit b57a2d43 authored by Venkat Malladi's avatar Venkat Malladi
Browse files

Update figure.

parent 28e65731
Branches
No related merge requests found
%% Cell type:code id: tags:
``` python
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
raw_data = {'Cell': ['H3K4me1', 'H3K27ac', 'H3K4me1+H3K27ac', 'GRO-seq'],
'1 method': [float((0)),float((0)), float((0)),float((3754))],
'2 method': [float((153327)),float((12510)), float((12510)),float((0))],
'3 method': [float((54616)),float((54556)), float((54767)),float((362))],
'4 method': [float((317)),float((317)),float((317)), float((317))]}
df = pd.DataFrame(raw_data, columns = ['Cell', '1 method', '2 method', '3 method', '4 method'])
# Create a figure with a single subplot
f, ax = plt.subplots(1, figsize=(10,5))
# Set bar width at 1
bar_width = 0.5
# positions of the left bar-boundaries
bar_l = [i for i in range(len(df['1 method']))]
# positions of the x-axis ticks (center of the bars as bar labels)
tick_pos = [i+(bar_width/2) for i in bar_l]
# Create the total enhancers
totals = [i+j+k+l for i,j,k,l in zip(df['1 method'], df['2 method'], df['3 method'], df['4 method'])]
# Create the percentage of the total unmarked enhancers value for each cell was
meth_1 = [i / float(j) * 100 for i,j in zip(df['1 method'], totals)]
# Create the percentage of the total H3K4me1 alone enhancers value for each cell
meth_2 = [i / float(j) * 100 for i,j in zip(df['2 method'], totals)]
# Create the percentage of the total H3K4me1+, H3K27ac+ enhancers value for each cell
meth_3 = [i / float(j) * 100 for i,j in zip(df['3 method'], totals)]
# Create the percentage of the total H3K4me1+, H3K27ac+ enhancers value for each cell
meth_4 = [i / float(j) * 100 for i,j in zip(df['4 method'], totals)]
N = 4
ind = np.arange(N) # the x locations for the groups
width = 0.5 # the width of the bars: can also be len(x) sequence
p1 = plt.bar(ind, meth_1, width, color='#6DA2DB')
p2 = plt.bar(ind, meth_2, width,
bottom=meth_1,color='#D2D5D4')
p3 = plt.bar(ind, meth_3, width,
bottom=[i+j for i,j in zip(meth_1, meth_2)],color='#D52114')
p4 = plt.bar(ind, meth_4, width,
bottom=[i+j+l for i,j,l in zip(meth_1, meth_2, meth_3)],color='orange')
bottom=[i+j+l for i,j,l in zip(meth_1, meth_2, meth_3)],color='#007517')
plt.ylabel('% total enhancers')
plt.title('Stage')
plt.xticks(ind, ('H3K4me1', 'H3K27ac', 'H3K4me1+H3K27ac', 'GR0-seq'))
plt.yticks(np.arange(0, 110, 10))
```
%% Output
([<matplotlib.axis.YTick at 0x10f6ed710>,
<matplotlib.axis.YTick at 0x10fdad550>,
<matplotlib.axis.YTick at 0x10fd9d8d0>,
<matplotlib.axis.YTick at 0x10fee4350>,
<matplotlib.axis.YTick at 0x10fee48d0>,
<matplotlib.axis.YTick at 0x10fee4e50>,
<matplotlib.axis.YTick at 0x10fee4ad0>,
<matplotlib.axis.YTick at 0x10feee210>,
<matplotlib.axis.YTick at 0x10feee790>,
<matplotlib.axis.YTick at 0x10feeed10>,
<matplotlib.axis.YTick at 0x10fef72d0>],
<a list of 11 Text yticklabel objects>)
%% Cell type:code id: tags:
``` python
N = 4
ind = np.arange(N) # the x locations for the groups
width = 0.5 # the width of the bars: can also be len(x) sequence
p1 = plt.bar(ind, meth_1, width, color='#6DA2DB')
p2 = plt.bar(ind, meth_2, width,
bottom=meth_1,color='#D2D5D4')
p3 = plt.bar(ind, meth_3, width,
bottom=[i+j for i,j in zip(meth_1, meth_2)],color='#D52114')
p4 = plt.bar(ind, meth_3, width,
bottom=[i+j for i,j in zip(meth_1, meth_2)],color='#D52114')
plt.ylabel('% total enhancers')
plt.title('Stage')
plt.xticks(ind, ('H3K4me1', 'H3K27ac', 'H3K4me1+H3K27ac' 'GR0-seq'))
plt.yticks(np.arange(0, 110, 10))
plt.savefig('Enhancer_percentages.png')
plt.clf()
```
%% Output
%% Cell type:code id: tags:
``` python
```
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment